Advertisement Jump to content
Sign in to follow this  

function pointers class and xml

This topic is 3337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hy. I would read an xml with sax and parse it. This xml have IDs and Refs string attribute and if is a id some data. The refs are related with the id. in practice i would process all the id fill they(have some primitives vars)from the xml and i would replace the refs with the related filled id. Now i created some classes that have the xml structure(the data and the refs) of the id and refs , because an id can be: this is an id: <IfcWallStandardCase id="i1705"> <GlobalId>211JbZETT979Gd3O5MEDvu</GlobalId> <OwnerHistory> <IfcOwnerHistory xsi:nil="true" ref="i1568"/> </OwnerHistory> <Name>Wall-002</Name> <ObjectPlacement> <IfcLocalPlacement xsi:nil="true" ref="i1702"/> </ObjectPlacement> <Representation> <IfcProductDefinitionShape id="i1771"> <Representations ex:cType="list"> <IfcShapeRepresentation pos="0" xsi:nil="true" ref="i1739"/> <IfcShapeRepresentation pos="1" xsi:nil="true" ref="i1766"/> </Representations> </IfcProductDefinitionShape> </Representation> </IfcWallStandardCase> that have a related class CIfcWallStandardCase with all the data. and this is a ref related to the id <IfcWallStandardCase xsi:nil="true" ref="i1705"/> <IfcRelContainedInSpatialStructure id="i16070"> <GlobalId>0Sf6h5xh9E3g1zOZLdpyCE</GlobalId> <OwnerHistory> <IfcOwnerHistory xsi:nil="true" ref="i1568"/> </OwnerHistory> <name>name</name> <description>description</description> <Name>BuildingStoreyContainer</Name> <Description>BuildingStoreyContainer for Building Elements</Description> <RelatedElements ex:cType="set"> <IfcWallStandardCase pos="0" xsi:nil="true" ref="i1705"/><----<------------------------<--------------------<------------<-- also have the same class but is in another id class with different type as reference . for ex: Class RelatedBuilding{ CIfcWallStandardCase * refWallStandardCase; . . . } now i would set this reference with the id filled reference for resolve the ref. The problem is that i have a lot of classes and ids and for each class i must define a set refxxxx. Is bad!!! I would crate an automatism like this: bool CRelContainedInSpatialStructure::GetData(wstring tag, wstring value, int pos, CBaseIfc** pIfcValue, CBaseIfc** pVar) { if( { m_bHasData = false; return false; } if("Name") == 0) m_Name = value; else if("Description") == 0) m_Description = value; if("IfcWallStandardCase") == 0){ void (CRelContainedInSpatialStructure::*my_memfunc_ptr)(CWallStandardCaseIfc*, int); my_memfunc_ptr = &CRelContainedInSpatialStructure::SetWalls; } void CRelContainedInSpatialStructure::SetWalls(CWallStandardCaseIfc* pwall, int pos) { m_pCIfcWallsStandardCases[pos] = pwall; } i call this function from the xml parsers and i get the tags related to the class and i would pass the mymemfunc_ptr out of the function. now i would insert the mymemberfunc in a map : mapIds[id] =my_memfunc_ptr and when i find a ref i call the function in the map like: (mapIds[id])(wallfilled) i would call the setfunctionxxx of this class for the id and set the id. How i can implement this? Advice ?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!