@@ -75,27 +75,29 @@ class lazyRefs {
7575 // 3c - for each item in both _refMap and edL, add it to _referentInstances
7676 potentialReferentInsts ( edL );
7777 // 3d - load each inst
78- invAttrListNode * invNode = invAttr ( _inst, ia /* , iaList*/ );
78+ /* invAttrListNode * invNode*/
79+ iAstruct * ias = invAttr ( _inst, ia /* , iaList*/ );
7980 referentInstances_t::iterator insts = _referentInstances.begin ();
8081 for ( ; insts != _referentInstances.end (); ++insts ) {
81- loadInstIFFreferent ( *insts, invNode );
82+ loadInstIFFreferent ( *insts, ias, ia );
8283 }
8384 // 3f - cache edL - TODO
8485 }
8586
86- void loadInstIFFreferent ( instanceID inst, invAttrListNode * invNode ) {
87+ void loadInstIFFreferent ( instanceID inst, iAstruct * ias, const Inverse_attribute * ia ) {
8788 bool prevLoaded = _lim->isLoaded ( inst );
8889 SDAI_Application_instance * rinst = _lim->loadInstance ( inst );
89- bool ref = refersToCurrentInst ( invNode-> inverseADesc () , rinst );
90+ bool ref = refersToCurrentInst ( ia , rinst );
9091 if ( ref ) {
91- if ( invNode->isAggregate () ) {
92- EntityAggregate * ea = ( ( invAttrListNodeA * )invNode )->getter ()( _inst );
92+ if ( ia->inverted_attr_ ()->IsAggrType () ) {
93+ EntityAggregate * ea = ias->a ;
94+ assert ( ea && " is it possible for this to be null here? if so, must create & assign" );
9395 // TODO check if duplicate
9496 ea->AddNode ( new EntityNode ( rinst ) );
9597 } else {
96- SDAI_Application_instance * ai = ( ( invAttrListNodeI * )invNode )-> getter ()( _inst ) ;
98+ SDAI_Application_instance * ai = ias-> i ;
9799 if ( !ai ) {
98- ( ( invAttrListNodeI * )invNode )-> setter ()( _inst, rinst ) ;
100+ ias-> i = rinst;
99101 } else if ( ai->GetFileId () != inst ) {
100102 std::cerr << " ERROR: two instances (" << rinst << " and " << ai->GetFileId () << " ) refer to inst " ;
101103 std::cerr << _inst->GetFileId () << " , but its inverse attribute is not an aggregation type!" << std::endl;
@@ -110,7 +112,7 @@ class lazyRefs {
110112 }
111113
112114 // /3e - check if actually inverse ref
113- bool refersToCurrentInst ( Inverse_attribute * ia, SDAI_Application_instance * referrer ) {
115+ bool refersToCurrentInst ( const Inverse_attribute * ia, SDAI_Application_instance * referrer ) {
114116 // find the attr
115117 int rindex = attrIndex ( referrer, ia->_inverted_attr_id , ia->_inverted_entity_id );
116118 STEPattribute sa = referrer->attributes [ rindex ];
@@ -155,7 +157,7 @@ class lazyRefs {
155157 return -1 ;
156158 }
157159
158- invAttrListNode * invAttr ( SDAI_Application_instance * inst, const Inverse_attribute * ia /* , iaList_t & iaList */ ) {
160+ iAstruct * invAttr ( SDAI_Application_instance * inst, const Inverse_attribute * ia /* , iaList_t & iaList */ ) {
159161 /* looks for iAttrs in schemas/sdai_ap214e3/entity/SdaiGeometric_representation_context.cc, but the ctors don't populate it
160162 * shouldn't the parent class ctor populate it?
161163ENTITY representation_context;
@@ -171,16 +173,22 @@ SUBTYPE OF (representation_context);
171173 coordinate_space_dimension : dimension_count;
172174END_ENTITY; -- 10303-42: geometry_schema
173175 */
174- invAttrListNode * n = ( invAttrListNode * ) inst->iAttrs .GetHead ();
175- while ( n ) {
176- if ( n->inverseADesc () == ia ) {
177- return n;
176+ SDAI_Application_instance::iAMap_t map = inst->getInvAttrs ();
177+ SDAI_Application_instance::iAMap_t::iterator iai = map.begin ();
178+ while ( iai != map.end () ) {
179+ if ( iai->first == ia ) {
180+ return &( iai->second );
178181 }
179- n = ( invAttrListNode * ) n-> NextNode () ;
182+ ++iai ;
180183 }
181- std::cerr << " Error! inverse attr " << ia->Name () << " (" << ia << " ) not found in iAttrs (" ;
182- std::cerr << ( void * )( & ( inst->iAttrs ) ) << " ) - entity " << inst->eDesc ->Name () << " ." << std::endl;
183- return 0 ;
184+ iai = map.begin ();
185+ // FIXME treat as unrecoverable?
186+ std::cerr << " Error! inverse attr " << ia->Name () << " (" << ia << " ) not found in iAMap for entity " << inst->getEDesc ()->Name () << " . Map contents:" << std::endl;
187+ for ( ; iai != map.end (); ++iai ) {
188+ std::cerr << iai->first ->Name () << " : " << (void *)(iai->second .a ) << " , " ;
189+ }
190+ std::cerr << std::endl;
191+ return NULL ;
184192 }
185193
186194 /* * 3c. compare the type of each item in R with types in A
@@ -208,13 +216,13 @@ END_ENTITY; -- 10303-42: geometry_schema
208216 const Inverse_attribute * iAttr;
209217 for ( ; !supersIter.empty (); ++supersIter ) {
210218 // look at attrs of *si
211- InverseAItr iai ( ( *supersIter )->InverseAttr () );
219+ InverseAItr iai ( &( ( *supersIter )->InverseAttr () ) );
212220 while ( 0 != ( iAttr = iai.NextInverse_attribute () ) ) {
213221 iaList.insert ( iAttr );
214222 }
215223 }
216224 // look at our own attrs
217- InverseAItr invAttrIter ( ed->InverseAttr () );
225+ InverseAItr invAttrIter ( &( ed->InverseAttr () ) );
218226 while ( 0 != ( iAttr = invAttrIter.NextInverse_attribute () ) ) {
219227 iaList.insert ( iAttr );
220228 }
@@ -272,7 +280,7 @@ END_ENTITY; -- 10303-42: geometry_schema
272280
273281
274282 // 1. find inverse attrs with recursion
275- getInverseAttrs ( ai->eDesc , _iaList );
283+ getInverseAttrs ( ai->getEDesc () , _iaList );
276284
277285 // 2. find reverse refs, map id to type (stop if there are no inverse attrs or no refs)
278286 if ( _iaList.size () == 0 || !mapRefsToTypes () ) {
0 commit comments