serialization added
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
#include "byteBuffer.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -21,13 +22,13 @@ namespace epics { namespace pvData {
|
||||
virtual bool get();
|
||||
virtual void put(bool val);
|
||||
virtual void serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher) ;
|
||||
SerializableControl *pflusher);
|
||||
virtual void deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
bool value;
|
||||
};
|
||||
@@ -43,33 +44,34 @@ namespace epics { namespace pvData {
|
||||
void BasePVBoolean::put(bool val){value = val;}
|
||||
|
||||
void BasePVBoolean::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
pflusher->ensureBuffer(1);
|
||||
pbuffer->putBoolean(value);
|
||||
}
|
||||
|
||||
void BasePVBoolean::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
pflusher->ensureData(1);
|
||||
value = pbuffer->getBoolean();
|
||||
}
|
||||
|
||||
void BasePVBoolean::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVBoolean::toString(StringBuilder buf,int indentLevel)
|
||||
void BasePVBoolean::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVBoolean::operator==(PVField *pvField)
|
||||
bool BasePVBoolean::operator==(PVField& pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
return getConvert()->equals(this, &pvField);
|
||||
}
|
||||
|
||||
bool BasePVBoolean::operator!=(PVField *pvField)
|
||||
bool BasePVBoolean::operator!=(PVField& pvField)
|
||||
{
|
||||
return !(getConvert()->equals(this,pvField));
|
||||
return !(getConvert()->equals(this, &pvField));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <epicsTypes.h>
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVScalarArray.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
using std::min;
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -33,8 +37,8 @@ namespace epics { namespace pvData {
|
||||
SerializableControl *pflusher, int offset, int count) ;
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
bool *value;
|
||||
};
|
||||
@@ -42,7 +46,7 @@ namespace epics { namespace pvData {
|
||||
BasePVBooleanArray::BasePVBooleanArray(PVStructure *parent,
|
||||
ScalarArrayConstPtr scalarArray)
|
||||
: PVBooleanArray(parent,scalarArray),value(new bool[0])
|
||||
{ }
|
||||
{ }
|
||||
|
||||
BasePVBooleanArray::~BasePVBooleanArray()
|
||||
{
|
||||
@@ -59,14 +63,14 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
int length = PVArray::getLength();
|
||||
if(length>capacity) length = capacity;
|
||||
bool *newValue = new bool[capacity];
|
||||
bool *newValue = new bool[capacity];
|
||||
for(int i=0; i<length; i++) newValue[i] = value[i];
|
||||
delete[]value;
|
||||
value = newValue;
|
||||
PVArray::setCapacityLength(capacity,length);
|
||||
}
|
||||
|
||||
int BasePVBooleanArray::get(int offset, int len, BooleanArrayData *data)
|
||||
int BasePVBooleanArray::get(int offset, int len, BooleanArrayData *data)
|
||||
{
|
||||
int n = len;
|
||||
int length = PVArray::getLength();
|
||||
@@ -105,7 +109,7 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
PVArray::setLength(length);
|
||||
PVField::postPut();
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
void BasePVBooleanArray::shareData(BooleanArray shareValue,int capacity,int length)
|
||||
@@ -116,21 +120,61 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
|
||||
void BasePVBooleanArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
serialize(pbuffer, pflusher, 0, getLength());
|
||||
}
|
||||
|
||||
void BasePVBooleanArray::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pcontrol) {
|
||||
int size = SerializeHelper::readSize(pbuffer, pcontrol);
|
||||
if(size>=0) {
|
||||
// prepare array, if necessary
|
||||
if(size>getCapacity()) setCapacity(size);
|
||||
// retrieve value from the buffer
|
||||
int i = 0;
|
||||
while(true) {
|
||||
int maxIndex = min(size-i, pbuffer->getRemaining())+i;
|
||||
for(; i<maxIndex; i++)
|
||||
value[i] = pbuffer->getBoolean();
|
||||
if(i<size)
|
||||
pcontrol->ensureData(1); // // TODO is there a better way to ensureData?
|
||||
else
|
||||
break;
|
||||
}
|
||||
// set new length
|
||||
setLength(size);
|
||||
postPut();
|
||||
}
|
||||
// TODO null arrays (size == -1) not supported
|
||||
}
|
||||
|
||||
void BasePVBooleanArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher, int offset, int count) {
|
||||
// cache
|
||||
int length = getLength();
|
||||
|
||||
// check bounds
|
||||
if(offset<0)
|
||||
offset = 0;
|
||||
else if(offset>length) offset = length;
|
||||
if(count<0) count = length;
|
||||
|
||||
int maxCount = length-offset;
|
||||
if(count>maxCount) count = maxCount;
|
||||
|
||||
// write
|
||||
SerializeHelper::writeSize(count, pbuffer, pflusher);
|
||||
int end = offset+count;
|
||||
int i = offset;
|
||||
while(true) {
|
||||
int maxIndex = min(end-i, pbuffer->getRemaining())+i;
|
||||
for(; i<maxIndex; i++)
|
||||
pbuffer->putBoolean(value[i]);
|
||||
if(i<end)
|
||||
pflusher->flushSerializeBuffer();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BasePVBooleanArray::toString(StringBuilder buf)
|
||||
@@ -145,14 +189,14 @@ namespace epics { namespace pvData {
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVBooleanArray::operator==(PVField *pv)
|
||||
bool BasePVBooleanArray::operator==(PVField& pv)
|
||||
{
|
||||
return getConvert()->equals(this,pv);
|
||||
return getConvert()->equals(this, &pv);
|
||||
}
|
||||
|
||||
bool BasePVBooleanArray::operator!=(PVField *pv)
|
||||
bool BasePVBooleanArray::operator!=(PVField& pv)
|
||||
{
|
||||
return !(getConvert()->equals(this,pv));
|
||||
return !(getConvert()->equals(this, &pv));
|
||||
}
|
||||
}}
|
||||
#endif /* BASEPVBOOLEANARRAY_H */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
#include "byteBuffer.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -26,14 +27,14 @@ namespace epics { namespace pvData {
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
epicsInt8 value;
|
||||
};
|
||||
|
||||
BasePVByte::BasePVByte(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVByte(parent,scalar),value(0.0)
|
||||
: PVByte(parent,scalar),value(0)
|
||||
{}
|
||||
|
||||
BasePVByte::~BasePVByte() {}
|
||||
@@ -43,33 +44,33 @@ namespace epics { namespace pvData {
|
||||
void BasePVByte::put(epicsInt8 val){value = val;}
|
||||
|
||||
void BasePVByte::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
pflusher->ensureBuffer(1);
|
||||
pbuffer->putByte(value);
|
||||
}
|
||||
|
||||
void BasePVByte::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pflusher) {
|
||||
pflusher->ensureData(1);
|
||||
value = pbuffer->getByte();
|
||||
}
|
||||
|
||||
void BasePVByte::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVByte::toString(StringBuilder buf,int indentLevel)
|
||||
void BasePVByte::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVByte::operator==(PVField *pvField)
|
||||
bool BasePVByte::operator==(PVField& pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
return getConvert()->equals(this, &pvField);
|
||||
}
|
||||
|
||||
bool BasePVByte::operator!=(PVField *pvField)
|
||||
bool BasePVByte::operator!=(PVField& pvField)
|
||||
{
|
||||
return !(getConvert()->equals(this,pvField));
|
||||
return !(getConvert()->equals(this, &pvField));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <epicsTypes.h>
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVScalarArray.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
using std::min;
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -33,8 +37,8 @@ namespace epics { namespace pvData {
|
||||
SerializableControl *pflusher, int offset, int count) ;
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
epicsInt8 *value;
|
||||
};
|
||||
@@ -42,7 +46,7 @@ namespace epics { namespace pvData {
|
||||
BasePVByteArray::BasePVByteArray(PVStructure *parent,
|
||||
ScalarArrayConstPtr scalarArray)
|
||||
: PVByteArray(parent,scalarArray),value(new epicsInt8[0])
|
||||
{ }
|
||||
{ }
|
||||
|
||||
BasePVByteArray::~BasePVByteArray()
|
||||
{
|
||||
@@ -59,14 +63,14 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
int length = PVArray::getLength();
|
||||
if(length>capacity) length = capacity;
|
||||
epicsInt8 *newValue = new epicsInt8[capacity];
|
||||
epicsInt8 *newValue = new epicsInt8[capacity];
|
||||
for(int i=0; i<length; i++) newValue[i] = value[i];
|
||||
delete[]value;
|
||||
value = newValue;
|
||||
PVArray::setCapacityLength(capacity,length);
|
||||
}
|
||||
|
||||
int BasePVByteArray::get(int offset, int len, ByteArrayData *data)
|
||||
int BasePVByteArray::get(int offset, int len, ByteArrayData *data)
|
||||
{
|
||||
int n = len;
|
||||
int length = PVArray::getLength();
|
||||
@@ -105,7 +109,7 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
PVArray::setLength(length);
|
||||
PVField::postPut();
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
void BasePVByteArray::shareData(ByteArray shareValue,int capacity,int length)
|
||||
@@ -116,21 +120,61 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
|
||||
void BasePVByteArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
serialize(pbuffer, pflusher, 0, getLength());
|
||||
}
|
||||
|
||||
void BasePVByteArray::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pcontrol) {
|
||||
int size = SerializeHelper::readSize(pbuffer, pcontrol);
|
||||
if(size>=0) {
|
||||
// prepare array, if necessary
|
||||
if(size>getCapacity()) setCapacity(size);
|
||||
// retrieve value from the buffer
|
||||
int i = 0;
|
||||
while(true) {
|
||||
int toRead = min(size-i, pbuffer->getRemaining());
|
||||
pbuffer->get(value, i, toRead);
|
||||
i += toRead;
|
||||
if(i<size)
|
||||
pcontrol->ensureData(1); // TODO: is there a better way to ensureData?
|
||||
else
|
||||
break;
|
||||
}
|
||||
// set new length
|
||||
setLength(size);
|
||||
postPut();
|
||||
}
|
||||
// TODO null arrays (size == -1) not supported
|
||||
}
|
||||
|
||||
void BasePVByteArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher, int offset, int count) {
|
||||
// cache
|
||||
int length = getLength();
|
||||
|
||||
// check bounds
|
||||
if(offset<0)
|
||||
offset = 0;
|
||||
else if(offset>length) offset = length;
|
||||
if(count<0) count = length;
|
||||
|
||||
int maxCount = length-offset;
|
||||
if(count>maxCount) count = maxCount;
|
||||
|
||||
// write
|
||||
SerializeHelper::writeSize(count, pbuffer, pflusher);
|
||||
int end = offset+count;
|
||||
int i = offset;
|
||||
while(true) {
|
||||
int maxIndex = min(end-i, pbuffer->getRemaining())+i;
|
||||
for(; i<maxIndex; i++)
|
||||
pbuffer->putByte(value[i]);
|
||||
if(i<end)
|
||||
pflusher->flushSerializeBuffer();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BasePVByteArray::toString(StringBuilder buf)
|
||||
@@ -145,14 +189,14 @@ namespace epics { namespace pvData {
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVByteArray::operator==(PVField *pv)
|
||||
bool BasePVByteArray::operator==(PVField& pv)
|
||||
{
|
||||
return getConvert()->equals(this,pv);
|
||||
return getConvert()->equals(this, &pv);
|
||||
}
|
||||
|
||||
bool BasePVByteArray::operator!=(PVField *pv)
|
||||
bool BasePVByteArray::operator!=(PVField& pv)
|
||||
{
|
||||
return !(getConvert()->equals(this,pv));
|
||||
return !(getConvert()->equals(this, &pv));
|
||||
}
|
||||
}}
|
||||
#endif /* BASEPVBYTEARRAY_H */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
#include "byteBuffer.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -26,8 +27,8 @@ namespace epics { namespace pvData {
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
double value;
|
||||
};
|
||||
@@ -43,33 +44,33 @@ namespace epics { namespace pvData {
|
||||
void BasePVDouble::put(double val){value = val;}
|
||||
|
||||
void BasePVDouble::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
pflusher->ensureBuffer(sizeof(double));
|
||||
pbuffer->putDouble(value);
|
||||
}
|
||||
|
||||
void BasePVDouble::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pflusher) {
|
||||
pflusher->ensureData(sizeof(double));
|
||||
value = pbuffer->getDouble();
|
||||
}
|
||||
|
||||
void BasePVDouble::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVDouble::toString(StringBuilder buf,int indentLevel)
|
||||
void BasePVDouble::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVDouble::operator==(PVField *pvField)
|
||||
bool BasePVDouble::operator==(PVField& pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
return getConvert()->equals(this, &pvField);
|
||||
}
|
||||
|
||||
bool BasePVDouble::operator!=(PVField *pvField)
|
||||
bool BasePVDouble::operator!=(PVField& pvField)
|
||||
{
|
||||
return !(getConvert()->equals(this,pvField));
|
||||
return !(getConvert()->equals(this, &pvField));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <epicsTypes.h>
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVScalarArray.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
using std::min;
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -33,8 +37,8 @@ namespace epics { namespace pvData {
|
||||
SerializableControl *pflusher, int offset, int count) ;
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
double *value;
|
||||
};
|
||||
@@ -42,7 +46,7 @@ namespace epics { namespace pvData {
|
||||
BasePVDoubleArray::BasePVDoubleArray(PVStructure *parent,
|
||||
ScalarArrayConstPtr scalarArray)
|
||||
: PVDoubleArray(parent,scalarArray),value(new double[0])
|
||||
{ }
|
||||
{ }
|
||||
|
||||
BasePVDoubleArray::~BasePVDoubleArray()
|
||||
{
|
||||
@@ -59,14 +63,14 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
int length = PVArray::getLength();
|
||||
if(length>capacity) length = capacity;
|
||||
double *newValue = new double[capacity];
|
||||
double *newValue = new double[capacity];
|
||||
for(int i=0; i<length; i++) newValue[i] = value[i];
|
||||
delete[]value;
|
||||
value = newValue;
|
||||
setCapacityLength(capacity,length);
|
||||
}
|
||||
|
||||
int BasePVDoubleArray::get(int offset, int len, DoubleArrayData *data)
|
||||
int BasePVDoubleArray::get(int offset, int len, DoubleArrayData *data)
|
||||
{
|
||||
int n = len;
|
||||
int length = PVArray::getLength();
|
||||
@@ -105,7 +109,7 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
PVArray::setLength(length);
|
||||
PVField::postPut();
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
void BasePVDoubleArray::shareData(
|
||||
@@ -117,21 +121,63 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
|
||||
void BasePVDoubleArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
serialize(pbuffer, pflusher, 0, getLength());
|
||||
}
|
||||
|
||||
void BasePVDoubleArray::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pcontrol) {
|
||||
int size = SerializeHelper::readSize(pbuffer, pcontrol);
|
||||
if(size>=0) {
|
||||
// prepare array, if necessary
|
||||
if(size>getCapacity()) setCapacity(size);
|
||||
// retrieve value from the buffer
|
||||
int i = 0;
|
||||
while(true) {
|
||||
int maxIndex = min(size-i, (int)(pbuffer->getRemaining()
|
||||
/sizeof(double)))+i;
|
||||
for(; i<maxIndex; i++)
|
||||
value[i] = pbuffer->getDouble();
|
||||
if(i<size)
|
||||
pcontrol->ensureData(sizeof(double));
|
||||
else
|
||||
break;
|
||||
}
|
||||
// set new length
|
||||
setLength(size);
|
||||
postPut();
|
||||
}
|
||||
// TODO null arrays (size == -1) not supported
|
||||
}
|
||||
|
||||
void BasePVDoubleArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher, int offset, int count) {
|
||||
// cache
|
||||
int length = getLength();
|
||||
|
||||
// check bounds
|
||||
if(offset<0)
|
||||
offset = 0;
|
||||
else if(offset>length) offset = length;
|
||||
if(count<0) count = length;
|
||||
|
||||
int maxCount = length-offset;
|
||||
if(count>maxCount) count = maxCount;
|
||||
|
||||
// write
|
||||
SerializeHelper::writeSize(count, pbuffer, pflusher);
|
||||
int end = offset+count;
|
||||
int i = offset;
|
||||
while(true) {
|
||||
int maxIndex = min(end-i, (int)(pbuffer->getRemaining()
|
||||
/sizeof(double)))+i;
|
||||
for(; i<maxIndex; i++)
|
||||
pbuffer->putDouble(value[i]);
|
||||
if(i<end)
|
||||
pflusher->flushSerializeBuffer();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BasePVDoubleArray::toString(StringBuilder buf)
|
||||
@@ -146,14 +192,14 @@ namespace epics { namespace pvData {
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVDoubleArray::operator==(PVField *pv)
|
||||
bool BasePVDoubleArray::operator==(PVField& pv)
|
||||
{
|
||||
return getConvert()->equals(this,pv);
|
||||
return getConvert()->equals(this, &pv);
|
||||
}
|
||||
|
||||
bool BasePVDoubleArray::operator!=(PVField *pv)
|
||||
bool BasePVDoubleArray::operator!=(PVField& pv)
|
||||
{
|
||||
return !(getConvert()->equals(this,pv));
|
||||
return !(getConvert()->equals(this, &pv));
|
||||
}
|
||||
}}
|
||||
#endif /* BASEPVDOUBLEARRAY_H */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
#include "byteBuffer.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -26,8 +27,8 @@ namespace epics { namespace pvData {
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
float value;
|
||||
};
|
||||
@@ -43,33 +44,33 @@ namespace epics { namespace pvData {
|
||||
void BasePVFloat::put(float val){value = val;}
|
||||
|
||||
void BasePVFloat::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
pflusher->ensureBuffer(sizeof(float));
|
||||
pbuffer->putFloat(value);
|
||||
}
|
||||
|
||||
void BasePVFloat::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pflusher) {
|
||||
pflusher->ensureData(sizeof(float));
|
||||
value = pbuffer->getFloat();
|
||||
}
|
||||
|
||||
void BasePVFloat::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVFloat::toString(StringBuilder buf,int indentLevel)
|
||||
void BasePVFloat::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVFloat::operator==(PVField *pvField)
|
||||
bool BasePVFloat::operator==(PVField& pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
return getConvert()->equals(this, &pvField);
|
||||
}
|
||||
|
||||
bool BasePVFloat::operator!=(PVField *pvField)
|
||||
bool BasePVFloat::operator!=(PVField& pvField)
|
||||
{
|
||||
return !(getConvert()->equals(this,pvField));
|
||||
return !(getConvert()->equals(this, &pvField));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,13 +5,17 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <epicsTypes.h>
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVScalarArray.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
using std::min;
|
||||
|
||||
PVFloatArray::~PVFloatArray() {}
|
||||
|
||||
PVFloatArray::PVFloatArray(PVStructure *parent,ScalarArrayConstPtr scalar)
|
||||
@@ -33,8 +37,8 @@ namespace epics { namespace pvData {
|
||||
SerializableControl *pflusher, int offset, int count) ;
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
float *value;
|
||||
};
|
||||
@@ -42,7 +46,7 @@ namespace epics { namespace pvData {
|
||||
BasePVFloatArray::BasePVFloatArray(PVStructure *parent,
|
||||
ScalarArrayConstPtr scalarArray)
|
||||
: PVFloatArray(parent,scalarArray),value(new float[0])
|
||||
{ }
|
||||
{ }
|
||||
|
||||
BasePVFloatArray::~BasePVFloatArray()
|
||||
{
|
||||
@@ -59,14 +63,14 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
int length = PVArray::getLength();
|
||||
if(length>capacity) length = capacity;
|
||||
float *newValue = new float[capacity];
|
||||
float *newValue = new float[capacity];
|
||||
for(int i=0; i<length; i++) newValue[i] = value[i];
|
||||
delete[]value;
|
||||
value = newValue;
|
||||
PVArray::setCapacityLength(capacity,length);
|
||||
}
|
||||
|
||||
int BasePVFloatArray::get(int offset, int len, FloatArrayData *data)
|
||||
int BasePVFloatArray::get(int offset, int len, FloatArrayData *data)
|
||||
{
|
||||
int n = len;
|
||||
int length = PVArray::getLength();
|
||||
@@ -105,7 +109,7 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
PVArray::setLength(length);
|
||||
PVField::postPut();
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
void BasePVFloatArray::shareData(
|
||||
@@ -116,22 +120,64 @@ namespace epics { namespace pvData {
|
||||
PVArray::setCapacityLength(capacity,length);
|
||||
}
|
||||
|
||||
void BasePVFloatArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
void BasePVFloatArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher) {
|
||||
serialize(pbuffer, pflusher, 0, getLength());
|
||||
}
|
||||
|
||||
void BasePVFloatArray::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pcontrol) {
|
||||
int size = SerializeHelper::readSize(pbuffer, pcontrol);
|
||||
if(size>=0) {
|
||||
// prepare array, if necessary
|
||||
if(size>getCapacity()) setCapacity(size);
|
||||
// retrieve value from the buffer
|
||||
int i = 0;
|
||||
while(true) {
|
||||
int maxIndex = min(size-i, (int)(pbuffer->getRemaining()
|
||||
/sizeof(float)))+i;
|
||||
for(; i<maxIndex; i++)
|
||||
value[i] = pbuffer->getFloat();
|
||||
if(i<size)
|
||||
pcontrol->ensureData(sizeof(float)); // TODO: is there a better way to ensureData?
|
||||
else
|
||||
break;
|
||||
}
|
||||
// set new length
|
||||
setLength(size);
|
||||
postPut();
|
||||
}
|
||||
// TODO null arrays (size == -1) not supported
|
||||
}
|
||||
|
||||
void BasePVFloatArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher, int offset, int count) {
|
||||
// cache
|
||||
int length = getLength();
|
||||
|
||||
// check bounds
|
||||
if(offset<0)
|
||||
offset = 0;
|
||||
else if(offset>length) offset = length;
|
||||
if(count<0) count = length;
|
||||
|
||||
int maxCount = length-offset;
|
||||
if(count>maxCount) count = maxCount;
|
||||
|
||||
// write
|
||||
SerializeHelper::writeSize(count, pbuffer, pflusher);
|
||||
int end = offset+count;
|
||||
int i = offset;
|
||||
while(true) {
|
||||
int maxIndex = min(end-i, (int)(pbuffer->getRemaining()
|
||||
/sizeof(float)))+i;
|
||||
for(; i<maxIndex; i++)
|
||||
pbuffer->putFloat(value[i]);
|
||||
if(i<end)
|
||||
pflusher->flushSerializeBuffer();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BasePVFloatArray::toString(StringBuilder buf)
|
||||
@@ -146,14 +192,14 @@ namespace epics { namespace pvData {
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVFloatArray::operator==(PVField *pv)
|
||||
bool BasePVFloatArray::operator==(PVField& pv)
|
||||
{
|
||||
return getConvert()->equals(this,pv);
|
||||
return getConvert()->equals(this, &pv);
|
||||
}
|
||||
|
||||
bool BasePVFloatArray::operator!=(PVField *pv)
|
||||
bool BasePVFloatArray::operator!=(PVField& pv)
|
||||
{
|
||||
return !(getConvert()->equals(this,pv));
|
||||
return !(getConvert()->equals(this, &pv));
|
||||
}
|
||||
}}
|
||||
#endif /* BASEPVFLOATARRAY_H */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
#include "byteBuffer.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -26,14 +27,14 @@ namespace epics { namespace pvData {
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
epicsInt32 value;
|
||||
};
|
||||
|
||||
BasePVInt::BasePVInt(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVInt(parent,scalar),value(0.0)
|
||||
: PVInt(parent,scalar),value(0)
|
||||
{}
|
||||
|
||||
BasePVInt::~BasePVInt() {}
|
||||
@@ -43,33 +44,33 @@ namespace epics { namespace pvData {
|
||||
void BasePVInt::put(epicsInt32 val){value = val;}
|
||||
|
||||
void BasePVInt::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
pflusher->ensureBuffer(sizeof(epicsInt32));
|
||||
pbuffer->putInt(value);
|
||||
}
|
||||
|
||||
void BasePVInt::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pflusher) {
|
||||
pflusher->ensureData(sizeof(epicsInt32));
|
||||
value = pbuffer->getInt();
|
||||
}
|
||||
|
||||
void BasePVInt::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVInt::toString(StringBuilder buf,int indentLevel)
|
||||
void BasePVInt::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVInt::operator==(PVField *pvField)
|
||||
bool BasePVInt::operator==(PVField& pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
return getConvert()->equals(this, &pvField);
|
||||
}
|
||||
|
||||
bool BasePVInt::operator!=(PVField *pvField)
|
||||
bool BasePVInt::operator!=(PVField& pvField)
|
||||
{
|
||||
return !(getConvert()->equals(this,pvField));
|
||||
return !(getConvert()->equals(this, &pvField));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <epicsTypes.h>
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVScalarArray.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
using std::min;
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -33,8 +37,8 @@ namespace epics { namespace pvData {
|
||||
SerializableControl *pflusher, int offset, int count) ;
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
epicsInt32 *value;
|
||||
};
|
||||
@@ -42,7 +46,7 @@ namespace epics { namespace pvData {
|
||||
BasePVIntArray::BasePVIntArray(PVStructure *parent,
|
||||
ScalarArrayConstPtr scalarArray)
|
||||
: PVIntArray(parent,scalarArray),value(new epicsInt32[0])
|
||||
{ }
|
||||
{ }
|
||||
|
||||
BasePVIntArray::~BasePVIntArray()
|
||||
{
|
||||
@@ -59,14 +63,14 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
int length = PVArray::getLength();
|
||||
if(length>capacity) length = capacity;
|
||||
epicsInt32 *newValue = new epicsInt32[capacity];
|
||||
epicsInt32 *newValue = new epicsInt32[capacity];
|
||||
for(int i=0; i<length; i++) newValue[i] = value[i];
|
||||
delete[]value;
|
||||
value = newValue;
|
||||
PVArray::setCapacityLength(capacity,length);
|
||||
}
|
||||
|
||||
int BasePVIntArray::get(int offset, int len, IntArrayData *data)
|
||||
int BasePVIntArray::get(int offset, int len, IntArrayData *data)
|
||||
{
|
||||
int n = len;
|
||||
int length = PVArray::getLength();
|
||||
@@ -105,7 +109,7 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
PVArray::setLength(length);
|
||||
PVField::postPut();
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
void BasePVIntArray::shareData(
|
||||
@@ -117,21 +121,63 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
|
||||
void BasePVIntArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
serialize(pbuffer, pflusher, 0, getLength());
|
||||
}
|
||||
|
||||
void BasePVIntArray::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pcontrol) {
|
||||
int size = SerializeHelper::readSize(pbuffer, pcontrol);
|
||||
if(size>=0) {
|
||||
// prepare array, if necessary
|
||||
if(size>getCapacity()) setCapacity(size);
|
||||
// retrieve value from the buffer
|
||||
int i = 0;
|
||||
while(true) {
|
||||
int maxIndex = min(size-i, (int)(pbuffer->getRemaining()
|
||||
/sizeof(epicsInt32)))+i;
|
||||
for(; i<maxIndex; i++)
|
||||
value[i] = pbuffer->getInt();
|
||||
if(i<size)
|
||||
pcontrol->ensureData(sizeof(epicsInt32)); // TODO: is there a better way to ensureData?
|
||||
else
|
||||
break;
|
||||
}
|
||||
// set new length
|
||||
setLength(size);
|
||||
postPut();
|
||||
}
|
||||
// TODO null arrays (size == -1) not supported
|
||||
}
|
||||
|
||||
void BasePVIntArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher, int offset, int count) {
|
||||
// cache
|
||||
int length = getLength();
|
||||
|
||||
// check bounds
|
||||
if(offset<0)
|
||||
offset = 0;
|
||||
else if(offset>length) offset = length;
|
||||
if(count<0) count = length;
|
||||
|
||||
int maxCount = length-offset;
|
||||
if(count>maxCount) count = maxCount;
|
||||
|
||||
// write
|
||||
SerializeHelper::writeSize(count, pbuffer, pflusher);
|
||||
int end = offset+count;
|
||||
int i = offset;
|
||||
while(true) {
|
||||
int maxIndex = min(end-i, (int)(pbuffer->getRemaining()
|
||||
/sizeof(epicsInt32)))+i;
|
||||
for(; i<maxIndex; i++)
|
||||
pbuffer->putInt(value[i]);
|
||||
if(i<end)
|
||||
pflusher->flushSerializeBuffer();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BasePVIntArray::toString(StringBuilder buf)
|
||||
@@ -146,14 +192,14 @@ namespace epics { namespace pvData {
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVIntArray::operator==(PVField *pv)
|
||||
bool BasePVIntArray::operator==(PVField& pv)
|
||||
{
|
||||
return getConvert()->equals(this,pv);
|
||||
return getConvert()->equals(this, &pv);
|
||||
}
|
||||
|
||||
bool BasePVIntArray::operator!=(PVField *pv)
|
||||
bool BasePVIntArray::operator!=(PVField& pv)
|
||||
{
|
||||
return !(getConvert()->equals(this,pv));
|
||||
return !(getConvert()->equals(this, &pv));
|
||||
}
|
||||
}}
|
||||
#endif /* BASEPVINTARRAY_H */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
#include "byteBuffer.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -26,14 +27,14 @@ namespace epics { namespace pvData {
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
epicsInt64 value;
|
||||
};
|
||||
|
||||
BasePVLong::BasePVLong(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVLong(parent,scalar),value(0.0)
|
||||
: PVLong(parent,scalar),value(0)
|
||||
{}
|
||||
|
||||
BasePVLong::~BasePVLong() {}
|
||||
@@ -43,33 +44,33 @@ namespace epics { namespace pvData {
|
||||
void BasePVLong::put(epicsInt64 val){value = val;}
|
||||
|
||||
void BasePVLong::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
pflusher->ensureBuffer(sizeof(epicsInt64));
|
||||
pbuffer->putLong(value);
|
||||
}
|
||||
|
||||
void BasePVLong::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pflusher) {
|
||||
pflusher->ensureData(sizeof(epicsInt64));
|
||||
value = pbuffer->getLong();
|
||||
}
|
||||
|
||||
void BasePVLong::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVLong::toString(StringBuilder buf,int indentLevel)
|
||||
void BasePVLong::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVLong::operator==(PVField *pvField)
|
||||
bool BasePVLong::operator==(PVField& pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
return getConvert()->equals(this, &pvField);
|
||||
}
|
||||
|
||||
bool BasePVLong::operator!=(PVField *pvField)
|
||||
bool BasePVLong::operator!=(PVField& pvField)
|
||||
{
|
||||
return !(getConvert()->equals(this,pvField));
|
||||
return !(getConvert()->equals(this, &pvField));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <epicsTypes.h>
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVScalarArray.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
using std::min;
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -33,8 +37,8 @@ namespace epics { namespace pvData {
|
||||
SerializableControl *pflusher, int offset, int count) ;
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
epicsInt64 *value;
|
||||
};
|
||||
@@ -42,7 +46,7 @@ namespace epics { namespace pvData {
|
||||
BasePVLongArray::BasePVLongArray(PVStructure *parent,
|
||||
ScalarArrayConstPtr scalarArray)
|
||||
: PVLongArray(parent,scalarArray),value(new epicsInt64[0])
|
||||
{ }
|
||||
{ }
|
||||
|
||||
BasePVLongArray::~BasePVLongArray()
|
||||
{
|
||||
@@ -59,14 +63,14 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
int length = PVArray::getLength();
|
||||
if(length>capacity) length = capacity;
|
||||
epicsInt64 *newValue = new epicsInt64[capacity];
|
||||
epicsInt64 *newValue = new epicsInt64[capacity];
|
||||
for(int i=0; i<length; i++) newValue[i] = value[i];
|
||||
delete[]value;
|
||||
value = newValue;
|
||||
PVArray::setCapacityLength(capacity,length);
|
||||
}
|
||||
|
||||
int BasePVLongArray::get(int offset, int len, LongArrayData *data)
|
||||
int BasePVLongArray::get(int offset, int len, LongArrayData *data)
|
||||
{
|
||||
int n = len;
|
||||
int length = PVArray::getLength();
|
||||
@@ -105,7 +109,7 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
PVArray::setLength(length);
|
||||
PVField::postPut();
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
void BasePVLongArray::shareData(
|
||||
@@ -117,21 +121,63 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
|
||||
void BasePVLongArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
serialize(pbuffer, pflusher, 0, getLength());
|
||||
}
|
||||
|
||||
void BasePVLongArray::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pcontrol) {
|
||||
int size = SerializeHelper::readSize(pbuffer, pcontrol);
|
||||
if(size>=0) {
|
||||
// prepare array, if necessary
|
||||
if(size>getCapacity()) setCapacity(size);
|
||||
// retrieve value from the buffer
|
||||
int i = 0;
|
||||
while(true) {
|
||||
int maxIndex = min(size-i, (int)(pbuffer->getRemaining()
|
||||
/sizeof(epicsInt64)))+i;
|
||||
for(; i<maxIndex; i++)
|
||||
value[i] = pbuffer->getLong();
|
||||
if(i<size)
|
||||
pcontrol->ensureData(sizeof(epicsInt64)); // TODO: is there a better way to ensureData?
|
||||
else
|
||||
break;
|
||||
}
|
||||
// set new length
|
||||
setLength(size);
|
||||
postPut();
|
||||
}
|
||||
// TODO null arrays (size == -1) not supported
|
||||
}
|
||||
|
||||
void BasePVLongArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher, int offset, int count) {
|
||||
// cache
|
||||
int length = getLength();
|
||||
|
||||
// check bounds
|
||||
if(offset<0)
|
||||
offset = 0;
|
||||
else if(offset>length) offset = length;
|
||||
if(count<0) count = length;
|
||||
|
||||
int maxCount = length-offset;
|
||||
if(count>maxCount) count = maxCount;
|
||||
|
||||
// write
|
||||
SerializeHelper::writeSize(count, pbuffer, pflusher);
|
||||
int end = offset+count;
|
||||
int i = offset;
|
||||
while(true) {
|
||||
int maxIndex = min(end-i, (int)(pbuffer->getRemaining()
|
||||
/sizeof(epicsInt64)))+i;
|
||||
for(; i<maxIndex; i++)
|
||||
pbuffer->putLong(value[i]);
|
||||
if(i<end)
|
||||
pflusher->flushSerializeBuffer();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BasePVLongArray::toString(StringBuilder buf)
|
||||
@@ -146,14 +192,14 @@ namespace epics { namespace pvData {
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVLongArray::operator==(PVField *pv)
|
||||
bool BasePVLongArray::operator==(PVField& pv)
|
||||
{
|
||||
return getConvert()->equals(this,pv);
|
||||
return getConvert()->equals(this, &pv);
|
||||
}
|
||||
|
||||
bool BasePVLongArray::operator!=(PVField *pv)
|
||||
bool BasePVLongArray::operator!=(PVField& pv)
|
||||
{
|
||||
return !(getConvert()->equals(this,pv));
|
||||
return !(getConvert()->equals(this, &pv));
|
||||
}
|
||||
}}
|
||||
#endif /* BASEPVLONGARRAY_H */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
#include "byteBuffer.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -26,14 +27,14 @@ namespace epics { namespace pvData {
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
epicsInt16 value;
|
||||
};
|
||||
|
||||
BasePVShort::BasePVShort(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVShort(parent,scalar),value(0.0)
|
||||
: PVShort(parent,scalar),value(0)
|
||||
{}
|
||||
|
||||
BasePVShort::~BasePVShort() {}
|
||||
@@ -43,33 +44,33 @@ namespace epics { namespace pvData {
|
||||
void BasePVShort::put(epicsInt16 val){value = val;}
|
||||
|
||||
void BasePVShort::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
pflusher->ensureBuffer(sizeof(epicsInt16));
|
||||
pbuffer->putShort(value);
|
||||
}
|
||||
|
||||
void BasePVShort::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pflusher) {
|
||||
pflusher->ensureData(sizeof(epicsInt16));
|
||||
value = pbuffer->getShort();
|
||||
}
|
||||
|
||||
void BasePVShort::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVShort::toString(StringBuilder buf,int indentLevel)
|
||||
void BasePVShort::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVShort::operator==(PVField *pvField)
|
||||
bool BasePVShort::operator==(PVField& pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
return getConvert()->equals(this, &pvField);
|
||||
}
|
||||
|
||||
bool BasePVShort::operator!=(PVField *pvField)
|
||||
bool BasePVShort::operator!=(PVField& pvField)
|
||||
{
|
||||
return !(getConvert()->equals(this,pvField));
|
||||
return !(getConvert()->equals(this, &pvField));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <epicsTypes.h>
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVScalarArray.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
using std::min;
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -33,8 +37,8 @@ namespace epics { namespace pvData {
|
||||
SerializableControl *pflusher, int offset, int count) ;
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
epicsInt16 *value;
|
||||
};
|
||||
@@ -42,7 +46,7 @@ namespace epics { namespace pvData {
|
||||
BasePVShortArray::BasePVShortArray(PVStructure *parent,
|
||||
ScalarArrayConstPtr scalarArray)
|
||||
: PVShortArray(parent,scalarArray),value(new epicsInt16[0])
|
||||
{ }
|
||||
{ }
|
||||
|
||||
BasePVShortArray::~BasePVShortArray()
|
||||
{
|
||||
@@ -59,14 +63,14 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
int length = PVArray::getLength();
|
||||
if(length>capacity) length = capacity;
|
||||
epicsInt16 *newValue = new epicsInt16[capacity];
|
||||
epicsInt16 *newValue = new epicsInt16[capacity];
|
||||
for(int i=0; i<length; i++) newValue[i] = value[i];
|
||||
delete[]value;
|
||||
value = newValue;
|
||||
PVArray::setCapacityLength(capacity,length);
|
||||
}
|
||||
|
||||
int BasePVShortArray::get(int offset, int len, ShortArrayData *data)
|
||||
int BasePVShortArray::get(int offset, int len, ShortArrayData *data)
|
||||
{
|
||||
int n = len;
|
||||
int length = PVArray::getLength();
|
||||
@@ -105,7 +109,7 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
PVArray::setLength(length);
|
||||
PVField::postPut();
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
void BasePVShortArray::shareData(
|
||||
@@ -117,21 +121,63 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
|
||||
void BasePVShortArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
serialize(pbuffer, pflusher, 0, getLength());
|
||||
}
|
||||
|
||||
void BasePVShortArray::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pcontrol) {
|
||||
int size = SerializeHelper::readSize(pbuffer, pcontrol);
|
||||
if(size>=0) {
|
||||
// prepare array, if necessary
|
||||
if(size>getCapacity()) setCapacity(size);
|
||||
// retrieve value from the buffer
|
||||
int i = 0;
|
||||
while(true) {
|
||||
int maxIndex = min(size-i, (int)(pbuffer->getRemaining()
|
||||
/sizeof(epicsInt16)))+i;
|
||||
for(; i<maxIndex; i++)
|
||||
value[i] = pbuffer->getShort();
|
||||
if(i<size)
|
||||
pcontrol->ensureData(sizeof(epicsInt16)); // TODO: is there a better way to ensureData?
|
||||
else
|
||||
break;
|
||||
}
|
||||
// set new length
|
||||
setLength(size);
|
||||
postPut();
|
||||
}
|
||||
// TODO null arrays (size == -1) not supported
|
||||
}
|
||||
|
||||
void BasePVShortArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher, int offset, int count) {
|
||||
// cache
|
||||
int length = getLength();
|
||||
|
||||
// check bounds
|
||||
if(offset<0)
|
||||
offset = 0;
|
||||
else if(offset>length) offset = length;
|
||||
if(count<0) count = length;
|
||||
|
||||
int maxCount = length-offset;
|
||||
if(count>maxCount) count = maxCount;
|
||||
|
||||
// write
|
||||
SerializeHelper::writeSize(count, pbuffer, pflusher);
|
||||
int end = offset+count;
|
||||
int i = offset;
|
||||
while(true) {
|
||||
int maxIndex = min(end-i, (int)(pbuffer->getRemaining()
|
||||
/sizeof(epicsInt16)))+i;
|
||||
for(; i<maxIndex; i++)
|
||||
pbuffer->putShort(value[i]);
|
||||
if(i<end)
|
||||
pflusher->flushSerializeBuffer();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BasePVShortArray::toString(StringBuilder buf)
|
||||
@@ -146,14 +192,14 @@ namespace epics { namespace pvData {
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVShortArray::operator==(PVField *pv)
|
||||
bool BasePVShortArray::operator==(PVField& pv)
|
||||
{
|
||||
return getConvert()->equals(this,pv);
|
||||
return getConvert()->equals(this, &pv);
|
||||
}
|
||||
|
||||
bool BasePVShortArray::operator!=(PVField *pv)
|
||||
bool BasePVShortArray::operator!=(PVField& pv)
|
||||
{
|
||||
return !(getConvert()->equals(this,pv));
|
||||
return !(getConvert()->equals(this, &pv));
|
||||
}
|
||||
}}
|
||||
#endif /* BASEPVSHORTARRAY_H */
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
#include "byteBuffer.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -26,8 +28,8 @@ namespace epics { namespace pvData {
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
String value;
|
||||
};
|
||||
@@ -43,33 +45,31 @@ namespace epics { namespace pvData {
|
||||
void BasePVString::put(String val){value = val;}
|
||||
|
||||
void BasePVString::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
SerializeHelper::serializeString(value, pbuffer, pflusher);
|
||||
}
|
||||
|
||||
void BasePVString::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pflusher) {
|
||||
value = SerializeHelper::deserializeString(pbuffer, pflusher);
|
||||
}
|
||||
|
||||
void BasePVString::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVString::toString(StringBuilder buf,int indentLevel)
|
||||
void BasePVString::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVString::operator==(PVField *pvField)
|
||||
bool BasePVString::operator==(PVField& pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
return getConvert()->equals(this, &pvField);
|
||||
}
|
||||
|
||||
bool BasePVString::operator!=(PVField *pvField)
|
||||
bool BasePVString::operator!=(PVField& pvField)
|
||||
{
|
||||
return !(getConvert()->equals(this,pvField));
|
||||
return !(getConvert()->equals(this, &pvField));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVScalarArray.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -33,8 +34,8 @@ namespace epics { namespace pvData {
|
||||
SerializableControl *pflusher, int offset, int count) ;
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual bool operator==(PVField *pv) ;
|
||||
virtual bool operator!=(PVField *pv) ;
|
||||
virtual bool operator==(PVField& pv) ;
|
||||
virtual bool operator!=(PVField& pv) ;
|
||||
private:
|
||||
String *value;
|
||||
};
|
||||
@@ -42,7 +43,7 @@ namespace epics { namespace pvData {
|
||||
BasePVStringArray::BasePVStringArray(PVStructure *parent,
|
||||
ScalarArrayConstPtr scalarArray)
|
||||
: PVStringArray(parent,scalarArray),value(new String[0])
|
||||
{ }
|
||||
{ }
|
||||
|
||||
BasePVStringArray::~BasePVStringArray()
|
||||
{
|
||||
@@ -59,14 +60,14 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
int length = PVArray::getLength();
|
||||
if(length>capacity) length = capacity;
|
||||
String *newValue = new String[capacity];
|
||||
String *newValue = new String[capacity];
|
||||
for(int i=0; i<length; i++) newValue[i] = value[i];
|
||||
delete[]value;
|
||||
value = newValue;
|
||||
PVArray::setCapacityLength(capacity,length);
|
||||
}
|
||||
|
||||
int BasePVStringArray::get(int offset, int len, StringArrayData *data)
|
||||
int BasePVStringArray::get(int offset, int len, StringArrayData *data)
|
||||
{
|
||||
int n = len;
|
||||
int length = PVArray::getLength();
|
||||
@@ -105,7 +106,7 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
PVArray::setLength(length);
|
||||
PVField::postPut();
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
void BasePVStringArray::shareData(
|
||||
@@ -117,21 +118,45 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
|
||||
void BasePVStringArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
serialize(pbuffer, pflusher, 0, getLength());
|
||||
}
|
||||
|
||||
void BasePVStringArray::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
DeserializableControl *pcontrol) {
|
||||
int size = SerializeHelper::readSize(pbuffer, pcontrol);
|
||||
if(size>=0) {
|
||||
// prepare array, if necessary
|
||||
if(size>getCapacity()) setCapacity(size);
|
||||
// retrieve value from the buffer
|
||||
for(int i = 0; i<size; i++)
|
||||
value[i] = SerializeHelper::deserializeString(pbuffer,
|
||||
pcontrol);
|
||||
// set new length
|
||||
setLength(size);
|
||||
postPut();
|
||||
}
|
||||
// TODO null arrays (size == -1) not supported
|
||||
}
|
||||
|
||||
void BasePVStringArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher, int offset, int count) {
|
||||
int length = getLength();
|
||||
|
||||
// check bounds
|
||||
if(offset<0)
|
||||
offset = 0;
|
||||
else if(offset>length) offset = length;
|
||||
if(count<0) count = length;
|
||||
|
||||
int maxCount = length-offset;
|
||||
if(count>maxCount) count = maxCount;
|
||||
|
||||
// write
|
||||
SerializeHelper::writeSize(count, pbuffer, pflusher);
|
||||
int end = offset+count;
|
||||
for(int i = offset; i<end; i++)
|
||||
SerializeHelper::serializeString(value[i], pbuffer, pflusher);
|
||||
}
|
||||
|
||||
void BasePVStringArray::toString(StringBuilder buf)
|
||||
@@ -146,14 +171,14 @@ namespace epics { namespace pvData {
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
bool BasePVStringArray::operator==(PVField *pv)
|
||||
bool BasePVStringArray::operator==(PVField& pv)
|
||||
{
|
||||
return getConvert()->equals(this,pv);
|
||||
return getConvert()->equals(this, &pv);
|
||||
}
|
||||
|
||||
bool BasePVStringArray::operator!=(PVField *pv)
|
||||
bool BasePVStringArray::operator!=(PVField& pv)
|
||||
{
|
||||
return !(getConvert()->equals(this,pv));
|
||||
return !(getConvert()->equals(this, &pv));
|
||||
}
|
||||
}}
|
||||
#endif /* BASEPVSTRINGARRAY_H */
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace epics { namespace pvData {
|
||||
for(int i=0; i<numberFields; i++) {
|
||||
delete pvFields[i];
|
||||
}
|
||||
delete[] pvFields;
|
||||
if (pvFields) delete[] pvFields;
|
||||
}
|
||||
|
||||
static PVField *findSubField(String fieldName,PVStructure *pvStructure);
|
||||
@@ -452,59 +452,115 @@ namespace epics { namespace pvData {
|
||||
toStringPvt(buf,0);
|
||||
}
|
||||
|
||||
void PVStructure::toString(StringBuilder buf,int indentLevel)
|
||||
void PVStructure::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
*buf += "structure ";
|
||||
toStringPvt(buf,indentLevel);
|
||||
}
|
||||
|
||||
void PVStructure::serialize(
|
||||
ByteBuffer *pbuffer,SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void PVStructure::deserialize(
|
||||
ByteBuffer *pbuffer,DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void PVStructure::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void PVStructure::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher,BitSet *pbitSet)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher) {
|
||||
for(int i = 0; i<pImpl->numberFields; i++)
|
||||
pImpl->pvFields[i]->serialize(pbuffer, pflusher);
|
||||
}
|
||||
|
||||
void PVStructure::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl*pflusher,BitSet *pbitSet)
|
||||
{
|
||||
DeserializableControl *pcontrol) {
|
||||
for(int i = 0; i<pImpl->numberFields; i++)
|
||||
pImpl->pvFields[i]->deserialize(pbuffer, pcontrol);
|
||||
|
||||
}
|
||||
|
||||
void PVStructure::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count) {
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
bool PVStructure::operator==(PVField *obj)
|
||||
void PVStructure::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, BitSet *pbitSet) {
|
||||
int offset = getFieldOffset();
|
||||
int numberFields = getNumberFields();
|
||||
int next = pbitSet->nextSetBit(offset);
|
||||
|
||||
// no more changes or no changes in this structure
|
||||
if(next<0||next>=offset+numberFields) return;
|
||||
|
||||
// entire structure
|
||||
if(offset==next) {
|
||||
serialize(pbuffer, pflusher);
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i<pImpl->numberFields; i++) {
|
||||
PVField* pvField = pImpl->pvFields[i];
|
||||
offset = pvField->getFieldOffset();
|
||||
numberFields = pvField->getNumberFields();
|
||||
next = pbitSet->nextSetBit(offset);
|
||||
// no more changes
|
||||
if(next<0) return;
|
||||
// no change in this pvField
|
||||
if(next>=offset+numberFields) continue;
|
||||
|
||||
// serialize field or fields
|
||||
if(numberFields==1)
|
||||
pvField->serialize(pbuffer, pflusher);
|
||||
else
|
||||
((PVStructure*)pvField)->serialize(pbuffer, pflusher,
|
||||
pbitSet);
|
||||
}
|
||||
}
|
||||
|
||||
void PVStructure::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pcontrol, BitSet *pbitSet) {
|
||||
int offset = getFieldOffset();
|
||||
int numberFields = getNumberFields();
|
||||
int next = pbitSet->nextSetBit(offset);
|
||||
|
||||
// no more changes or no changes in this structure
|
||||
if(next<0||next>=offset+numberFields) return;
|
||||
|
||||
// entire structure
|
||||
if(offset==next) {
|
||||
deserialize(pbuffer, pcontrol);
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i<pImpl->numberFields; i++) {
|
||||
PVField* pvField = pImpl->pvFields[i];
|
||||
offset = pvField->getFieldOffset();
|
||||
numberFields = pvField->getNumberFields();
|
||||
next = pbitSet->nextSetBit(offset);
|
||||
// no more changes
|
||||
if(next<0) return;
|
||||
// no change in this pvField
|
||||
if(next>=offset+numberFields) continue;
|
||||
|
||||
// deserialize field or fields
|
||||
if(numberFields==1)
|
||||
pvField->deserialize(pbuffer, pcontrol);
|
||||
else
|
||||
((PVStructure*)pvField)->deserialize(pbuffer, pcontrol,
|
||||
pbitSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool PVStructure::operator==(PVField &obj)
|
||||
{
|
||||
PVStructure *b = dynamic_cast<PVStructure *>(obj);
|
||||
if(b==0) return false;
|
||||
PVFieldPtrArray bFields = b->getPVFields();
|
||||
PVStructure &b = dynamic_cast<PVStructure &>(obj);
|
||||
PVFieldPtrArray bFields = b.pImpl->pvFields;
|
||||
PVFieldPtrArray pvFields = pImpl->pvFields;
|
||||
int len = b->getNumberFields();
|
||||
int len = b.pImpl->numberFields;
|
||||
if(len!=pImpl->numberFields) return false;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!(pvFields[i]==bFields[i])) return false;
|
||||
if (!(*pvFields[i]==*bFields[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PVStructure::operator!=(PVField *pv)
|
||||
bool PVStructure::operator!=(PVField &pv)
|
||||
{
|
||||
return !(this==pv);
|
||||
return !(*this==pv);
|
||||
}
|
||||
|
||||
static PVField *findSubField(String fieldName,PVStructure *pvStructure) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <cstdio>
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -30,8 +31,8 @@ namespace epics { namespace pvData {
|
||||
PVStructurePtrArray from, int fromOffset);
|
||||
virtual void toString(StringBuilder buf) ;
|
||||
virtual void toString(StringBuilder buf,int indentLevel) ;
|
||||
virtual bool operator==(PVField *pv);
|
||||
virtual bool operator!=(PVField *pv);
|
||||
virtual bool operator==(PVField &pv);
|
||||
virtual bool operator!=(PVField &pv);
|
||||
virtual void shareData( PVStructurePtrArray value,int capacity,int length);
|
||||
virtual void serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher);
|
||||
@@ -72,21 +73,21 @@ namespace epics { namespace pvData {
|
||||
int limit = length;
|
||||
if(length>capacity) limit = capacity;
|
||||
for(int i=0; i<limit; i++) newValue[i] = value[i];
|
||||
for(int i=limit; i<capacity; i++) newValue[i] = 0;
|
||||
for(int i=limit; i<capacity; i++) newValue[i] = 0;
|
||||
if(length>capacity) length = capacity;
|
||||
delete[] value;
|
||||
value = newValue;
|
||||
setCapacityLength(capacity,length);
|
||||
}
|
||||
|
||||
|
||||
StructureArrayConstPtr BasePVStructureArray::getStructureArray()
|
||||
|
||||
StructureArrayConstPtr BasePVStructureArray::getStructureArray()
|
||||
{
|
||||
return structureArray;
|
||||
}
|
||||
|
||||
int BasePVStructureArray::get(
|
||||
int offset, int len, StructureArrayData *data)
|
||||
int offset, int len, StructureArrayData *data)
|
||||
{
|
||||
int n = len;
|
||||
int length = getLength();
|
||||
@@ -135,7 +136,7 @@ namespace epics { namespace pvData {
|
||||
value[i+offset] = frompv;
|
||||
}
|
||||
postPut();
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
void BasePVStructureArray::shareData(
|
||||
@@ -148,38 +149,79 @@ namespace epics { namespace pvData {
|
||||
|
||||
void BasePVStructureArray::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVStructureArray::toString(StringBuilder buf,int indentLevel)
|
||||
void BasePVStructureArray::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
void BasePVStructureArray::serialize(
|
||||
ByteBuffer *pbuffer,SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
void BasePVStructureArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher) {
|
||||
serialize(pbuffer, pflusher, 0, getLength());
|
||||
}
|
||||
|
||||
void BasePVStructureArray::deserialize(
|
||||
ByteBuffer *pbuffer,DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
void BasePVStructureArray::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pcontrol) {
|
||||
int size = SerializeHelper::readSize(pbuffer, pcontrol);
|
||||
if(size>=0) {
|
||||
// prepare array, if necessary
|
||||
if(size>getCapacity()) setCapacity(size);
|
||||
for(int i = 0; i<size; i++) {
|
||||
pcontrol->ensureData(1);
|
||||
epicsInt8 temp = pbuffer->getByte();
|
||||
if(temp==0) {
|
||||
value[i] = NULL;
|
||||
}
|
||||
else {
|
||||
if(value[i]==NULL) {
|
||||
value[i] = getPVDataCreate()->createPVStructure(
|
||||
NULL, structureArray->getStructure());
|
||||
}
|
||||
value[i]->deserialize(pbuffer, pcontrol);
|
||||
}
|
||||
}
|
||||
setLength(size);
|
||||
postPut();
|
||||
}
|
||||
}
|
||||
|
||||
void BasePVStructureArray::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher, int offset, int count)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
SerializableControl *pflusher, int offset, int count) {
|
||||
// cache
|
||||
int length = getLength();
|
||||
|
||||
// check bounds
|
||||
if(offset<0)
|
||||
offset = 0;
|
||||
else if(offset>length) offset = length;
|
||||
if(count<0) count = length;
|
||||
|
||||
int maxCount = length-offset;
|
||||
if(count>maxCount) count = maxCount;
|
||||
|
||||
// write
|
||||
SerializeHelper::writeSize(count, pbuffer, pflusher);
|
||||
for(int i = 0; i<count; i++) {
|
||||
if(pbuffer->getRemaining()<1) pflusher->flushSerializeBuffer();
|
||||
PVStructure* pvStructure = value[i+offset];
|
||||
if(pvStructure==NULL) {
|
||||
pbuffer->putByte(0);
|
||||
}
|
||||
else {
|
||||
pbuffer->putByte(1);
|
||||
pvStructure->serialize(pbuffer, pflusher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BasePVStructureArray::operator==(PVField *pvField)
|
||||
bool BasePVStructureArray::operator==(PVField &pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
return getConvert()->equals(this,&pvField);
|
||||
}
|
||||
|
||||
bool BasePVStructureArray::operator!=(PVField *pvField)
|
||||
bool BasePVStructureArray::operator!=(PVField &pvField)
|
||||
{
|
||||
return !(getConvert()->equals(this,pvField));
|
||||
return !(getConvert()->equals(this,&pvField));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -37,6 +37,7 @@ LIBSRCS += StandardPVField.cpp
|
||||
LIBRARY=pvFactory
|
||||
|
||||
pvFactory_LIBS += Com
|
||||
pvFactory_LIBS += pvMisc
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user