This commit is contained in:
Matej Sekoranja
2011-01-10 23:43:52 +01:00
parent 21951b885d
commit b167f78416
12 changed files with 74 additions and 78 deletions

View File

@@ -1,5 +1,5 @@
/*
* constants.hpp
* constants.h
*
* Created on: Oct 8, 2010
* Author: Miha Vitorovic

View File

@@ -12,12 +12,9 @@
#include <iostream>
#endif
#include <cstring>
#include <lock.h>
#include <epicsException.h>
using epics::pvData::Mutex;
using epics::pvData::Lock;
using epics::pvData::BaseException;
#include <epicsAssert.h>
namespace epics {
namespace pvAccess {
@@ -129,7 +126,7 @@ namespace epics {
private:
T* _elements; // array of pointers
size_t _head, _tail, _size;
Mutex _mutex;
epics::pvData::Mutex _mutex;
static int MIN_INITIAL_CAPACITY;
/**
@@ -225,7 +222,7 @@ namespace epics {
template<class T>
void ArrayFIFO<T>::addFirst(const T e) {
Lock lock(&_mutex);
epics::pvData::Lock lock(&_mutex);
_elements[_head = (_head-1)&(_size-1)] = e;
if(_head==_tail) doubleCapacity();
@@ -233,7 +230,7 @@ namespace epics {
template<class T>
void ArrayFIFO<T>::addLast(const T e) {
Lock lock(&_mutex);
epics::pvData::Lock lock(&_mutex);
_elements[_tail] = e;
if((_tail = (_tail+1)&(_size-1))==_head) doubleCapacity();
@@ -241,7 +238,7 @@ namespace epics {
template<class T>
T ArrayFIFO<T>::pollFirst() {
Lock lock(&_mutex);
epics::pvData::Lock lock(&_mutex);
if(isEmpty()) return 0;
@@ -252,7 +249,7 @@ namespace epics {
template<class T>
T ArrayFIFO<T>::pollLast() {
Lock lock(&_mutex);
epics::pvData::Lock lock(&_mutex);
if(isEmpty()) return 0;
@@ -262,7 +259,7 @@ namespace epics {
template<class T>
T ArrayFIFO<T>::peekFirst() {
Lock lock(&_mutex);
epics::pvData::Lock lock(&_mutex);
if(isEmpty()) return 0;
@@ -271,7 +268,7 @@ namespace epics {
template<class T>
T ArrayFIFO<T>::peekLast() {
Lock lock(&_mutex);
epics::pvData::Lock lock(&_mutex);
if(isEmpty()) return 0;
@@ -295,21 +292,21 @@ namespace epics {
template<class T>
size_t ArrayFIFO<T>::size() {
Lock lock(&_mutex);
epics::pvData::Lock lock(&_mutex);
return (_tail-_head)&(_size-1);
}
template<class T>
bool ArrayFIFO<T>::isEmpty() {
Lock lock(&_mutex);
epics::pvData::Lock lock(&_mutex);
return _head==_tail;
}
template<class T>
void ArrayFIFO<T>::clear() {
Lock lock(&_mutex);
epics::pvData::Lock lock(&_mutex);
_head = _tail = 0;
}
@@ -324,8 +321,7 @@ namespace epics {
size_t back = (t-i)&mask;
// Invariant: head <= i < tail mod circularity
if(front>=((t-h)&mask)) THROW_BASE_EXCEPTION(
"Illegal State Exception"); // concurrency problem!!!
assert(front<((t-h)&mask)); // concurrency problem detected
// Optimize for least element motion
if(front<back) {
@@ -358,7 +354,7 @@ namespace epics {
template<class T>
bool ArrayFIFO<T>::remove(const T e) {
Lock lock(&_mutex);
epics::pvData::Lock lock(&_mutex);
if(isEmpty()) return false; // nothing to do

View File

@@ -3,9 +3,13 @@
*/
#include "configuration.h"
#include <epicsException.h>
namespace epics { namespace pvAccess {
using namespace epics::pvData;
using namespace std;
Properties::Properties()
{
_fileName = "";

View File

@@ -5,12 +5,11 @@
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include "pvType.h"
#include "noDefaultMethods.h"
#include "lock.h"
#include "epicsException.h"
#include <pvType.h>
#include <noDefaultMethods.h>
#include <lock.h>
#include "envDefs.h"
#include <envDefs.h>
#include <iostream>
@@ -20,9 +19,6 @@
#include <map>
using namespace epics::pvData;
using namespace std;
namespace epics { namespace pvAccess {
#define MAX_NAME_LENGHT 300
@@ -42,27 +38,27 @@ class Properties
{
public:
Properties();
Properties(const string fileName);
Properties(const std::string fileName);
virtual ~Properties();
void setProperty(const string key,const string value);
string getProperty(const string key);
string getProperty(const string key, const string defaultValue);
void setProperty(const std::string key,const std::string value);
std::string getProperty(const std::string key);
std::string getProperty(const std::string key, const std::string defaultValue);
void store();
void store(const string fileName);
void store(const std::string fileName);
void load();
void load(const string fileName);
void load(const std::string fileName);
void list();
private:
map<const char*,const char* , conf_cmp_str> _properties;
map<const char*,const char* , conf_cmp_str>::iterator _propertiesIterator;
ifstream* _infile;
ofstream* _outfile;
string _fileName;
std::map<const char*,const char* , conf_cmp_str> _properties;
std::map<const char*,const char* , conf_cmp_str>::iterator _propertiesIterator;
std::ifstream* _infile;
std::ofstream* _outfile;
std::string _fileName;
inline void truncate(string& str)
inline void truncate(std::string& str)
{
while(str.length() != 0 && (str.at(0) == ' ' || str.at(0) == '\t'))
{
@@ -80,7 +76,7 @@ private:
/**
* Configuration
*/
class Configuration : private NoDefaultMethods
class Configuration : private epics::pvData::NoDefaultMethods
{
public:
/*
@@ -92,7 +88,7 @@ public:
*
* @return environment variable value as bool or default value if it does not exist.
*/
virtual bool getPropertyAsBoolean(const string name, const bool defaultValue) = 0;
virtual bool getPropertyAsBoolean(const std::string name, const bool defaultValue) = 0;
/*
* Get the environment variable specified by name or return default value
* if it does not exist.
@@ -102,7 +98,7 @@ public:
*
* @return environment variable value as int32 or default value if it does not exist.
*/
virtual int32 getPropertyAsInteger(const string name, const int32 defaultValue) = 0;
virtual epics::pvData::int32 getPropertyAsInteger(const std::string name, const epics::pvData::int32 defaultValue) = 0;
/*
* Get the environment variable specified by name or return default value
* if it does not exist.
@@ -112,7 +108,7 @@ public:
*
* @return environment variable value as float or default value if it does not exist.
*/
virtual float getPropertyAsFloat(const string name, const float defaultValue) = 0;
virtual float getPropertyAsFloat(const std::string name, const float defaultValue) = 0;
/*
* Get the environment variable specified by name or return default value
* if it does not exist.
@@ -122,7 +118,7 @@ public:
*
* @return environment variable value as double or default value if it does not exist.
*/
virtual float getPropertyAsDouble(const string name, const double defaultValue) = 0;
virtual float getPropertyAsDouble(const std::string name, const double defaultValue) = 0;
/*
* Get the environment variable specified by name or return default value
* if it does not exist.
@@ -130,9 +126,9 @@ public:
* @param name name of the environment variable to return.
* @param defualtValue default value to return if environment variable does not exists.
*
* @return environment variable value as string or default value if it does not exist.
* @return environment variable value as std::string or default value if it does not exist.
*/
virtual string getPropertyAsString(const string name, const string defaultValue) = 0;
virtual std::string getPropertyAsString(const std::string name, const std::string defaultValue) = 0;
};
class SystemConfigurationImpl: public Configuration
@@ -140,23 +136,23 @@ class SystemConfigurationImpl: public Configuration
public:
SystemConfigurationImpl();
virtual ~SystemConfigurationImpl();
bool getPropertyAsBoolean(const string name, const bool defaultValue);
int32 getPropertyAsInteger(const string name, const int32 defaultValue);
float getPropertyAsFloat(const string name, const float defaultValue);
float getPropertyAsDouble(const string name, const double defaultValue);
string getPropertyAsString(const string name, string defaultValue);
bool getPropertyAsBoolean(const std::string name, const bool defaultValue);
epics::pvData::int32 getPropertyAsInteger(const std::string name, const epics::pvData::int32 defaultValue);
float getPropertyAsFloat(const std::string name, const float defaultValue);
float getPropertyAsDouble(const std::string name, const double defaultValue);
std::string getPropertyAsString(const std::string name, std::string defaultValue);
Properties* _properties;
private:
ENV_PARAM _envParam;
istringstream _ibuffer;
ostringstream _obuffer;
std::istringstream _ibuffer;
std::ostringstream _obuffer;
};
/**
* Configuration provider.
*/
class ConfigurationProvider : private NoDefaultMethods
class ConfigurationProvider : private epics::pvData::NoDefaultMethods
{
public:
/*
@@ -166,14 +162,14 @@ public:
*
* @return configuration specified by name or NULL if it does not exists.
*/
virtual Configuration* getConfiguration(const string name) = 0;
virtual Configuration* getConfiguration(const std::string name) = 0;
/*
* Register configuration.
*
* @param name name of the configuration to register.
* @param configuration configuration to register.
*/
virtual void registerConfiguration(const string name, const Configuration* configuration) = 0;
virtual void registerConfiguration(const std::string name, const Configuration* configuration) = 0;
};
class ConfigurationProviderImpl: public ConfigurationProvider
@@ -181,18 +177,18 @@ class ConfigurationProviderImpl: public ConfigurationProvider
public:
ConfigurationProviderImpl();
virtual ~ConfigurationProviderImpl();
Configuration* getConfiguration(const string name);
void registerConfiguration(const string name, const Configuration* configuration);
Configuration* getConfiguration(const std::string name);
void registerConfiguration(const std::string name, const Configuration* configuration);
private:
Mutex _mutex;
map<const char*,const Configuration*, conf_cmp_str> _configs;
map<const char*,const Configuration*, conf_cmp_str>::iterator _configsIter;
epics::pvData::Mutex _mutex;
std::map<const char*,const Configuration*, conf_cmp_str> _configs;
std::map<const char*,const Configuration*, conf_cmp_str>::iterator _configsIter;
};
/**
* Configuration factory.
*/
class ConfigurationFactory : private NoDefaultMethods
class ConfigurationFactory : private epics::pvData::NoDefaultMethods
{
public:
/*
@@ -208,7 +204,7 @@ public:
private:
ConfigurationFactory() {};
static ConfigurationProviderImpl* _configurationProvider;
static Mutex _conf_factory_mutex;
static epics::pvData::Mutex _conf_factory_mutex;
};
}}

View File

@@ -8,6 +8,8 @@
#ifndef GROWINGCIRCULARBUFFER_H_
#define GROWINGCIRCULARBUFFER_H_
// TODO remove exception throwing !!!
#include <epicsException.h>
using epics::pvData::BaseException;

View File

@@ -10,8 +10,6 @@
#include <pvType.h>
using namespace epics::pvData;
namespace epics {
namespace pvAccess {
@@ -21,7 +19,7 @@ namespace epics {
* @param bs buffer to dump
* @param len first bytes (length) to dump.
*/
void hexDump(const String name, const int8 *bs, int len);
void hexDump(const epics::pvData::String name, const epics::pvData::int8 *bs, int len);
/**
* Output a buffer in hex format.
@@ -30,7 +28,7 @@ namespace epics {
* @param[in] start dump message using given offset.
* @param[in] len first bytes (length) to dump.
*/
void hexDump(const String name, const int8 *bs, int start, int len);
void hexDump(const epics::pvData::String name, const epics::pvData::int8 *bs, int start, int len);
/**
* Output a buffer in hex format.
@@ -40,7 +38,7 @@ namespace epics {
* @param[in] start dump message using given offset.
* @param[in] len first bytes (length) to dump.
*/
void hexDump(const String prologue, const String name, const int8 *bs,
void hexDump(const epics::pvData::String prologue, const epics::pvData::String name, const epics::pvData::int8 *bs,
int start, int len);
}

View File

@@ -10,8 +10,6 @@
#include <pvType.h>
using epics::pvData::String;
namespace epics {
namespace pvAccess {
@@ -23,7 +21,7 @@ namespace epics {
* @param[in] fname The file to write to. If the file exists, it
* is opened for append.
*/
void createFileLogger( String fname );
void createFileLogger( epics::pvData::String fname );
}
}

View File

@@ -10,6 +10,7 @@
#include <iostream>
using std::cout;
using namespace epics::pvData;
namespace epics {
namespace pvAccess {

View File

@@ -10,8 +10,6 @@
#include <pvType.h>
using epics::pvData::String;
namespace epics {
namespace pvAccess {
@@ -32,7 +30,7 @@ namespace epics {
*
* @return DOCUMENT ME!
*/
bool testSet(const String pattern, int offset, const char ch);
bool testSet(const epics::pvData::String pattern, int offset, const char ch);
/**
* Recursive method for parsing the string. To avoid copying the strings,
@@ -45,7 +43,7 @@ namespace epics {
*
* @return boolean Do the strings match
*/
bool parse(const String pattern, const int ofp, const String str,
bool parse(const epics::pvData::String pattern, const int ofp, const epics::pvData::String str,
const int ofs);
/**
@@ -56,7 +54,7 @@ namespace epics {
*
* @return DOCUMENT ME!
*/
bool match(const String pattern, const String str);
bool match(const epics::pvData::String pattern, const epics::pvData::String str);
}
}

View File

@@ -12,6 +12,7 @@
#include <stdlib.h>
using namespace epics::pvAccess;
using namespace epics::pvData;
using namespace std;
int main(int argc, char *argv[])

View File

@@ -5,10 +5,11 @@
* Author: Miha Vitorovic
*/
#include "hexDump.h"
#include <hexDump.h>
#include <iostream>
using namespace epics::pvData;
using namespace epics::pvAccess;
using std::cout;
using std::endl;

View File

@@ -5,11 +5,12 @@
* Author: Miha Vitorovic
*/
#include "wildcharMatcher.h"
#include <wildcharMatcher.h>
#include <iostream>
#include <epicsAssert.h>
using namespace epics::pvData;
using namespace epics::pvAccess;
using std::cout;