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.
103 lines
3.0 KiB
C++
103 lines
3.0 KiB
C++
/*BasePVDoubleArray.h*/
|
|
#ifndef BASEPVDOUBLEARRAY_H
|
|
#define BASEPVDOUBLEARRAY_H
|
|
#include <cstddef>
|
|
#include <cstdlib>
|
|
#include <string>
|
|
#include <cstdio>
|
|
#include "pvData.h"
|
|
#include "factory.h"
|
|
#include "AbstractPVScalarArray.h"
|
|
|
|
namespace epics { namespace pvData {
|
|
|
|
PVDoubleArray::~PVDoubleArray() {}
|
|
|
|
PVDoubleArray::PVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalar)
|
|
: PVScalarArray(parent,scalar) {}
|
|
|
|
class BasePVDoubleArray : public PVDoubleArray {
|
|
public:
|
|
BasePVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
|
|
virtual ~BasePVDoubleArray();
|
|
virtual void setCapacity(int capacity);
|
|
virtual int get(int offset, int length, DoubleArrayData *data) const;
|
|
virtual int put(int offset,int length,DoubleArrayPtr from,
|
|
int fromOffset);
|
|
virtual void shareData(DoubleArrayPtr from);
|
|
// from Serializable
|
|
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const;
|
|
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
|
|
virtual void serialize(ByteBuffer *pbuffer,
|
|
SerializableControl *pflusher, int offset, int count) const;
|
|
virtual void toString(StringBuilder buf)const;
|
|
virtual void toString(StringBuilder buf,int indentLevel)const;
|
|
private:
|
|
double *doubleArray;
|
|
};
|
|
|
|
BasePVDoubleArray::BasePVDoubleArray(PVStructure *parent,
|
|
ScalarArrayConstPtr scalarArray)
|
|
: PVDoubleArray(parent,scalarArray),doubleArray(new double[0])
|
|
{ }
|
|
|
|
BasePVDoubleArray::~BasePVDoubleArray()
|
|
{
|
|
delete[] doubleArray;
|
|
}
|
|
|
|
void BasePVDoubleArray::setCapacity(int capacity)
|
|
{
|
|
throw std::logic_error(notImplemented);
|
|
}
|
|
|
|
int BasePVDoubleArray::get(int offset, int length,
|
|
DoubleArrayData *data) const
|
|
{
|
|
data->data = doubleArray;
|
|
return getLength();
|
|
}
|
|
|
|
int BasePVDoubleArray::put(int offset,int length,
|
|
DoubleArrayPtr from,int fromOffset)
|
|
{
|
|
return getLength();
|
|
}
|
|
|
|
void BasePVDoubleArray::shareData(DoubleArrayPtr from)
|
|
{
|
|
throw std::logic_error(notImplemented);
|
|
}
|
|
|
|
void BasePVDoubleArray::serialize(ByteBuffer *pbuffer,
|
|
SerializableControl *pflusher) const
|
|
{
|
|
throw std::logic_error(notImplemented);
|
|
}
|
|
|
|
void BasePVDoubleArray::deserialize(ByteBuffer *pbuffer,
|
|
DeserializableControl *pflusher)
|
|
{
|
|
throw std::logic_error(notImplemented);
|
|
}
|
|
|
|
void BasePVDoubleArray::serialize(ByteBuffer *pbuffer,
|
|
SerializableControl *pflusher, int offset, int count) const
|
|
{
|
|
throw std::logic_error(notImplemented);
|
|
}
|
|
|
|
void BasePVDoubleArray::toString(StringBuilder buf)const
|
|
{
|
|
toString(buf,1);
|
|
}
|
|
|
|
void BasePVDoubleArray::toString(StringBuilder buf,int indentLevel)const
|
|
{
|
|
convert->getString(buf,this,indentLevel);
|
|
PVArray::toString(buf,indentLevel);
|
|
}
|
|
|
|
}}
|
|
#endif /* BASEPVDOUBLEARRAY_H */
|