1) implemented noDefaultMethods. See effective C++ Item 6. There it is called Uncopyable

2) implemented Lock. See effective C++ item 14.
     This is as easy to use as Java synchronize.
3) wrapper on top of std::string. All usage of string in pvData is one of:
      String - Just a std::string
     StringBuilder - Used where StringBuilder is used in Java
     StringConst - Just a "std::string const". This is used wherever String is used in Java
     StringConstArray - Just like a String[] in Java.
4) The reference counting (incReferenceCount and decReferenceCount) are now private. It is completely handled by the implenentaion.
    NO code that uses pvData needs even know about reference counting.
This commit is contained in:
Marty Kraimer
2010-09-27 08:33:10 -04:00
parent dd6ecf9bec
commit f6c9b0eea3
26 changed files with 377 additions and 522 deletions

View File

@@ -1,7 +1,7 @@
/* Convert.cpp */
#include <string>
#include <stdexcept>
#include <epicsMutex.h>
#include <lock.h>
#include "convert.h"
namespace epics { namespace pvData {
@@ -12,39 +12,39 @@ static std::string notImplemented("not implemented");
Convert::~Convert(){}
void Convert::getFullName(StringConstPtr buf,PVField const *pvField)
void Convert::getFullName(StringConst buf,PVField const *pvField)
{
throw std::logic_error(notImplemented);
}
void Convert::getString(StringPtr buf,PVField const * pvField,int indentLevel)
void Convert::getString(StringBuilder buf,PVField const * pvField,int indentLevel)
{
throw std::logic_error(notImplemented);
}
void Convert::getString(StringPtr buf,PVField const *pvField)
void Convert::getString(StringBuilder buf,PVField const *pvField)
{
throw std::logic_error(notImplemented);
}
void Convert::fromString(PVScalar *pv, StringConstPtr from)
void Convert::fromString(PVScalar *pv, StringConst from)
{
throw std::logic_error(notImplemented);
}
int Convert::fromString(PVScalarArray *pv, StringConstPtr from)
int Convert::fromString(PVScalarArray *pv, StringConst from)
{
throw std::logic_error(notImplemented);
}
int Convert::fromStringArray(PVScalarArray *pv, int offset, int length,
StringPtrArray from, int fromOffset)
StringConstArray from, int fromOffset)
{
throw std::logic_error(notImplemented);
}
int Convert::toStringArray(PVScalarArray const *pv, int offset, int length,
StringPtrArray to, int fromOffset)
StringConstArray to, int fromOffset)
{
throw std::logic_error(notImplemented);
}
@@ -237,7 +237,7 @@ static std::string notImplemented("not implemented");
throw std::logic_error(notImplemented);
}
void Convert::newLine(StringPtr buffer, int indentLevel)
void Convert::newLine(StringBuilder buffer, int indentLevel)
{
*buffer += "\n";
for(int i=0; i<indentLevel; i++) *buffer += " ";
@@ -253,10 +253,10 @@ static std::string notImplemented("not implemented");
};
Convert * getConvert() {
static epicsMutex *lock = new epicsMutex();
lock->lock();
if(instance==0) instance = new ConvertExt();
lock->unlock();
static Mutex *mutex = new Mutex();
Lock xx(mutex);
if(instance==0) instance = new ConvertExt();
return instance;
}