add methods append and remove to PVStructureArray

This commit is contained in:
Marty Kraimer
2011-01-31 09:38:12 -05:00
parent ad9633c8f6
commit ca3e22fd81
6 changed files with 112 additions and 83 deletions

View File

@@ -49,33 +49,13 @@ void testPowerSupplyArray(FILE * fd) {
PVStructureArray * powerSupplyArray =
powerSupplyArrayStruct->getStructureArrayField(String("value"));
assert(powerSupplyArray!=0);
PVStructurePtrArray structureArray = new PVStructurePtr[3];
StructureConstPtr structure =
powerSupplyArray->getStructureArray()->getStructure();
structure->incReferenceCount();
structureArray[0] = pvDataCreate->createPVStructure(0,structure);
structure->incReferenceCount();
structureArray[1] = pvDataCreate->createPVStructure(0,structure);
structure->incReferenceCount();
structureArray[2] = pvDataCreate->createPVStructure(0,structure);
powerSupplyArray->put(0,3,structureArray,0);
int offset = powerSupplyArray->append(3);
powerSupplyArray->setLength(offset);
buffer.clear();
powerSupplyArrayStruct->toString(&buffer);
fprintf(fd,"%s\n",buffer.c_str());
buffer.clear();
powerSupplyArrayStruct->getField()->dumpReferenceCount(&buffer,0);
fprintf(fd," reference counts %s\n",buffer.c_str());
buffer.clear();
structure->dumpReferenceCount(&buffer,0);
fprintf(fd,"before incReferenceCount reference counts %s\n",buffer.c_str());
structure->incReferenceCount();
buffer.clear();
structure->dumpReferenceCount(&buffer,0);
fprintf(fd,"after incReferenceCount reference counts %s\n",buffer.c_str());
structure->decReferenceCount();
buffer.clear();
structure->dumpReferenceCount(&buffer,0);
fprintf(fd,"after decReferenceCount reference counts %s\n",buffer.c_str());
StructureConstPtr structure =
powerSupplyArray->getStructureArray()->getStructure();
delete powerSupplyArrayStruct;
}