changes for PVStructureArray
This commit is contained in:
@@ -1067,29 +1067,7 @@ void Convert::copyStructureArray(
|
||||
String message("Convert.copyStructureArray destination is immutable");
|
||||
throw std::invalid_argument(message);
|
||||
}
|
||||
StructureConstPtr xxx = from->getStructureArray()->getStructure();
|
||||
StructureConstPtr yyy = to->getStructureArray()->getStructure();
|
||||
if(!isCopyStructureCompatible(xxx,yyy)) {
|
||||
String message("Convert.copyStructureArray from and to are not compatible");
|
||||
throw std::invalid_argument(message);
|
||||
}
|
||||
size_t length = from->getLength();
|
||||
if(to->getCapacity()<length) to->setCapacity(length);
|
||||
PVStructurePtr * fromArray = from->get();
|
||||
PVStructurePtr * toArray = to->get();
|
||||
for(size_t i=0; i<length; i++) {
|
||||
if(fromArray[i].get()==NULL) {
|
||||
toArray[i] = PVStructurePtr();
|
||||
} else {
|
||||
if(toArray[i].get()==0) {
|
||||
StructureConstPtr structure = to->getStructureArray()->getStructure();
|
||||
toArray[i] = pvDataCreate->createPVStructure(structure);
|
||||
}
|
||||
copyStructure(fromArray[i],toArray[i]);
|
||||
}
|
||||
}
|
||||
to->setLength(length);
|
||||
to->postPut();
|
||||
to->put(0,from->getLength(),from->getVector(),0);
|
||||
}
|
||||
|
||||
String Convert::toString(PVScalarPtr const & pv)
|
||||
|
||||
@@ -178,19 +178,19 @@ void PVStructureArray::deserialize(ByteBuffer *pbuffer,
|
||||
if(size>=0) {
|
||||
// prepare array, if necessary
|
||||
if(size>getCapacity()) setCapacity(size);
|
||||
PVStructurePtrArray pvArray = *value.get();
|
||||
PVStructurePtrArray *pvArray = value.get();
|
||||
for(size_t i = 0; i<size; i++) {
|
||||
pcontrol->ensureData(1);
|
||||
size_t temp = pbuffer->getByte();
|
||||
if(temp==0) {
|
||||
pvArray[i].reset();
|
||||
(*pvArray)[i].reset();
|
||||
}
|
||||
else {
|
||||
if(pvArray[i].get()==NULL) {
|
||||
if((*pvArray)[i].get()==NULL) {
|
||||
StructureConstPtr structure = structureArray->getStructure();
|
||||
pvArray[i] = getPVDataCreate()->createPVStructure(structure);
|
||||
(*pvArray)[i] = getPVDataCreate()->createPVStructure(structure);
|
||||
}
|
||||
pvArray[i]->deserialize(pbuffer, pcontrol);
|
||||
(*pvArray)[i]->deserialize(pbuffer, pcontrol);
|
||||
}
|
||||
}
|
||||
setLength(size);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <pv/requester.h>
|
||||
#include <pv/pvIntrospect.h>
|
||||
#include <pv/pvData.h>
|
||||
#include <pv/convert.h>
|
||||
#include <pv/standardField.h>
|
||||
#include <pv/standardPVField.h>
|
||||
|
||||
@@ -27,6 +28,7 @@ static FieldCreatePtr fieldCreate;
|
||||
static PVDataCreatePtr pvDataCreate;
|
||||
static StandardFieldPtr standardField;
|
||||
static StandardPVFieldPtr standardPVField;
|
||||
static ConvertPtr convert;
|
||||
static String buffer;
|
||||
|
||||
void testPVStructureArray(FILE * fd) {
|
||||
@@ -45,6 +47,11 @@ void testPVStructureArray(FILE * fd) {
|
||||
buffer.clear();
|
||||
pvAlarmStructure->toString(&buffer);
|
||||
fprintf(fd,"pvAlarmStructure\n%s\n",buffer.c_str());
|
||||
PVStructureArrayPtr copy(pvDataCreate->createPVStructureArray(alarm));
|
||||
convert->copyStructureArray(pvAlarmStructure,copy);
|
||||
buffer.clear();
|
||||
copy->toString(&buffer);
|
||||
fprintf(fd,"copy\n%s\n",buffer.c_str());
|
||||
}
|
||||
|
||||
StructureConstPtr getPowerSupplyStructure() {
|
||||
@@ -101,6 +108,7 @@ int main(int argc,char *argv[])
|
||||
pvDataCreate = getPVDataCreate();
|
||||
standardField = getStandardField();
|
||||
standardPVField = getStandardPVField();
|
||||
convert = getConvert();
|
||||
testPVStructureArray(fd);
|
||||
testPowerSupplyArray(fd);
|
||||
return(0);
|
||||
|
||||
Reference in New Issue
Block a user