working on PVStructureArray

This commit is contained in:
Marty Kraimer
2012-07-06 13:03:37 -04:00
parent 5d57e9bbcf
commit 27c4da5b73
2 changed files with 30 additions and 3 deletions

View File

@@ -32,9 +32,10 @@ size_t PVStructureArray::append(size_t number)
size_t newLength = currentLength + number;
setCapacity(newLength);
StructureConstPtr structure = structureArray->getStructure();
PVStructurePtrArray vec = *value.get();
for(size_t i=currentLength; i<newLength; i++) {
PVStructurePtrArray vec = *value.get();
vec[i] = getPVDataCreate()->createPVStructure(structure);
PVStructurePtr pvStructure(getPVDataCreate()->createPVStructure(structure));
vec[i].swap(pvStructure);
}
return newLength;
}
@@ -151,7 +152,8 @@ size_t PVStructureArray::put(size_t offset,size_t len,
"Element is not a compatible structure"));
}
}
to[i+offset] = frompv;
PVStructurePtr pvStructure(frompv);
to[i+offset].swap(pvStructure);
}
postPut();
setLength(length);

View File

@@ -29,6 +29,30 @@ static StandardFieldPtr standardField;
static StandardPVFieldPtr standardPVField;
static String buffer;
void testPVStructureArray(FILE * fd) {
StructureArrayConstPtr alarm(
fieldCreate->createStructureArray(standardField->alarm()));
PVStructureArrayPtr pvAlarmStructure(
pvDataCreate->createPVStructureArray(alarm));
PVStructurePtrArray palarms;
size_t na=2;
palarms.reserve(na);
for(size_t i=0; i<na; i++) {
palarms.push_back(
pvDataCreate->createPVStructure(standardField->alarm()));
}
PVStructurePtr *xxx = &palarms[0];
for(size_t i=0;i<na; i++) {
buffer.clear();
xxx[i]->toString(&buffer);
printf("xxx[%d]\n%s\n",(int)i,buffer.c_str());
}
pvAlarmStructure->put(0,2,xxx,0);
buffer.clear();
pvAlarmStructure->toString(&buffer);
fprintf(fd,"pvAlarmStructure\n%s\n",buffer.c_str());
}
StructureConstPtr getPowerSupplyStructure() {
String properties("alarm");
FieldConstPtrArray fields;
@@ -83,6 +107,7 @@ int main(int argc,char *argv[])
pvDataCreate = getPVDataCreate();
standardField = getStandardField();
standardPVField = getStandardPVField();
testPVStructureArray(fd);
testPowerSupplyArray(fd);
return(0);
}