Merged conflicts with matej's push

This commit is contained in:
Marty Kraimer
2010-11-02 08:54:15 -04:00
31 changed files with 1541 additions and 445 deletions
+62 -17
View File
@@ -8,6 +8,9 @@
#include "pvData.h"
#include "factory.h"
#include "AbstractPVScalarArray.h"
#include "serializeHelper.h"
using std::min;
namespace epics { namespace pvData {
@@ -32,8 +35,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:
int32 *value;
};
@@ -65,7 +68,7 @@ namespace epics { namespace pvData {
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();
@@ -104,7 +107,7 @@ namespace epics { namespace pvData {
}
PVArray::setLength(length);
PVField::postPut();
return len;
return len;
}
void BasePVIntArray::shareData(
@@ -116,21 +119,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(int32)))+i;
for(; i<maxIndex; i++)
value[i] = pbuffer->getInt();
if(i<size)
pcontrol->ensureData(sizeof(int32)); // 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(int32)))+i;
for(; i<maxIndex; i++)
pbuffer->putInt(value[i]);
if(i<end)
pflusher->flushSerializeBuffer();
else
break;
}
}
void BasePVIntArray::toString(StringBuilder buf)
@@ -145,14 +190,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 */