void PVField::computeOffset(const PVField * pvField,size_t offset) { size_t beginOffset = offset; size_t nextOffset = offset + 1; const PVStructure *pvStructure = static_cast<const PVStructure *>(pvField); const PVFieldPtrArray & pvFields = pvStructure->getPVFields(); for(size_t i=0; i < pvStructure->getStructure()->getNumberFields(); i++) { offset = nextOffset; PVField *pvSubField = pvFields[i].get(); FieldConstPtr field = pvSubField->getField(); switch(field->getType()) { case scalar: case scalarArray: case structureArray: case union_: case unionArray: { nextOffset++; pvSubField->fieldOffset = offset; pvSubField->nextFieldOffset = nextOffset; break; } case structure: { pvSubField->computeOffset(pvSubField,offset); nextOffset = pvSubField->getNextFieldOffset(); } } } PVField *xxx = const_cast<PVField *>(pvField); xxx->fieldOffset = beginOffset; xxx->nextFieldOffset = nextOffset; }
void PVField::computeOffset(const PVField * pvField) { const PVStructure * pvTop = pvField->getParent(); if(pvTop==NULL) { if(pvField->getField()->getType()!=structure) { PVField *xxx = const_cast<PVField *>(pvField); xxx->fieldOffset = 0; xxx->nextFieldOffset = 1; return; } pvTop = static_cast<const PVStructure *>(pvField); } else { while(pvTop->getParent()!=NULL) pvTop = pvTop->getParent(); } size_t offset = 0; size_t nextOffset = 1; const PVFieldPtrArray & pvFields = pvTop->getPVFields(); for(size_t i=0; i < pvTop->getStructure()->getNumberFields(); i++) { offset = nextOffset; PVField *pvField = pvFields[i].get(); FieldConstPtr field = pvField->getField(); switch(field->getType()) { case scalar: case scalarArray: case structureArray: case union_: case unionArray: { nextOffset++; pvField->fieldOffset = offset; pvField->nextFieldOffset = nextOffset; break; } case structure: { pvField->computeOffset(pvField,offset); nextOffset = pvField->getNextFieldOffset(); } } } PVField *top = (PVField *)pvTop; PVField *xxx = const_cast<PVField *>(top); xxx->fieldOffset = 0; xxx->nextFieldOffset = nextOffset; }