Skip to content

Commit 921de86

Browse files
committed
closer...
1 parent 5df2f69 commit 921de86

3 files changed

Lines changed: 28 additions & 45 deletions

File tree

src/cllazyfile/lazyRefs.h

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -77,36 +77,36 @@ class lazyRefs {
7777
potentialReferentInsts( edL );
7878
//3d - load each inst
7979
/*invAttrListNode * invNode*/
80-
iAstruct * ias = invAttr( _inst, ia );
80+
iAstruct ias = invAttr( _inst, ia );
8181
referentInstances_t::iterator insts = _referentInstances.begin();
8282
for( ; insts != _referentInstances.end(); ++insts ) {
8383
loadInstIFFreferent( *insts, ias, ia );
8484
}
8585
//3f - cache edL - TODO
8686
}
8787

88-
void loadInstIFFreferent( instanceID inst, iAstruct * ias, const Inverse_attribute * ia ) {
88+
void loadInstIFFreferent( instanceID inst, iAstruct ias, const Inverse_attribute * ia ) {
8989
std::cout << "liir for inst #" << _inst->STEPfile_id << ", referent #" << inst << ", ia " << ia->Name() << "(" << (void*) ia;
90-
std::cout << "), ias " << (void *) ias << std::endl;
90+
std::cout << "), ias " << (void *) &ias << std::endl;
9191
bool prevLoaded = _lim->isLoaded( inst );
9292
SDAI_Application_instance * rinst = _lim->loadInstance( inst );
9393
bool ref = refersToCurrentInst( ia, rinst );
9494
if( ref ) {
9595
if( ia->inverted_attr_()->IsAggrType() ) {
96-
if( !ias->a ) {
97-
ias->a = new EntityAggregate;
98-
_inst->setInvAttr( ia, *ias );
99-
assert( invAttr( _inst, ia )->a == ias->a );
96+
if( !ias.a ) {
97+
ias.a = new EntityAggregate;
98+
_inst->setInvAttr( ia, ias );
99+
assert( invAttr( _inst, ia ).a == ias.a );
100100
}
101-
EntityAggregate * ea = ias->a;
101+
EntityAggregate * ea = ias.a;
102102
// assert( ias->a && "is it possible for this to be null here? if so, must create & assign");
103103
//FIXME InitIAttrs has been called, but this is null. what to do? init here? if not, where???
104104
//TODO check if duplicate
105105
ea->AddNode( new EntityNode( rinst ) );
106106
} else {
107-
SDAI_Application_instance * ai = ias->i;
107+
SDAI_Application_instance * ai = ias.i;
108108
if( !ai ) {
109-
ias->i = rinst;
109+
ias.i = rinst;
110110
} else if( ai->GetFileId() != inst ) {
111111
std::cerr << "ERROR: two instances (" << rinst << " and " << ai->GetFileId() << ") refer to inst ";
112112
std::cerr << _inst->GetFileId() << ", but its inverse attribute is not an aggregation type!" << std::endl;
@@ -166,27 +166,12 @@ class lazyRefs {
166166
return -1;
167167
}
168168

169-
iAstruct * invAttr( SDAI_Application_instance * inst, const Inverse_attribute * ia /*, iaList_t & iaList */ ) {
170-
/* looks for iAttrs in schemas/sdai_ap214e3/entity/SdaiGeometric_representation_context.cc, but the ctors don't populate it
171-
* shouldn't the parent class ctor populate it?
172-
ENTITY representation_context;
173-
context_identifier : identifier;
174-
context_type : text;
175-
INVERSE
176-
representations_in_context : SET [1:?] OF representation FOR context_of_items
177-
;
178-
END_ENTITY; -- 10303-43: representation_schema
179-
180-
ENTITY geometric_representation_context
181-
SUBTYPE OF (representation_context);
182-
coordinate_space_dimension : dimension_count;
183-
END_ENTITY; -- 10303-42: geometry_schema
184-
*/
169+
iAstruct invAttr( SDAI_Application_instance * inst, const Inverse_attribute * ia /*, iaList_t & iaList */ ) {
185170
SDAI_Application_instance::iAMap_t map = inst->getInvAttrs();
186171
SDAI_Application_instance::iAMap_t::iterator iai = map.begin();
187172
while( iai != map.end() ) {
188173
if( iai->first == ia ) {
189-
return &( iai->second );
174+
return iai->second;
190175
}
191176
++iai;
192177
}
@@ -198,8 +183,10 @@ END_ENTITY; -- 10303-42: geometry_schema
198183
std::cerr << iai->first->Name() << ": " << (void*)(iai->second.a) << ", ";
199184
}
200185
std::cerr << std::endl;
201-
abort();
202-
// // return NULL;
186+
// abort();
187+
iAstruct nil;
188+
memset( &nil, 0, sizeof( nil ) );
189+
return nil;
203190
}
204191

205192
/** 3c. compare the type of each item in R with types in A

src/clstepcore/sdaiApplication_instance.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,5 +960,10 @@ const SDAI_Application_instance::iAMap_t::value_type SDAI_Application_instance::
960960

961961
void SDAI_Application_instance::setInvAttr( const Inverse_attribute * const ia, const iAstruct ias ) {
962962
// assert( validIAS( ia, ias ) && "Exactly one member of iAstruct must be non-null, and this must match the type of the Inverse_Attribute." );
963-
iAMap.insert( iAMap_t::value_type( ia, ias ) );
963+
iAMap_t::iterator it = iAMap.find(ia);
964+
if( it != iAMap.end() ) {
965+
it->second = ias;
966+
} else {
967+
iAMap.insert( iAMap_t::value_type( ia, ias ) );
968+
}
964969
}

test/cpp/schema_specific/inverse_attr3.cc

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extern void SchemaInit( class Registry & );
2424
#include "schema.h"
2525

2626
int main( int argc, char * argv[] ) {
27+
int exitStatus = EXIT_SUCCESS;
2728
if( argc != 2 ) {
2829
cerr << "Wrong number of args!" << endl;
2930
exit( EXIT_FAILURE );
@@ -46,37 +47,27 @@ int main( int argc, char * argv[] ) {
4647
}
4748
cout << "instance #" << instance->StepFileId() << endl;
4849

49-
// superInvAttrIter it( instance->getEDesc() );
50-
// // const Inverse_attributeList * l = &( instance->getEDesc()->InverseAttr() );
51-
// // InverseAItr iai(l);
52-
// const Inverse_attribute * ia;
53-
// bool found = false;
54-
// while( !found && ( ia = it.next() ) ) {
55-
// if( !strcmp( ia->Name(), "isdefinedby" ) ) {
56-
// found = true;
57-
// }
58-
// }
59-
// if( found ) {
6050
SDAI_Application_instance::iAMap_t::value_type v = instance->getInvAttr("isdefinedby");
6151
iAstruct attr = v.second; //instance->getInvAttr(ia);
6252
if( attr.a && attr.a->EntryCount() ) {
6353
cout << "Map: found " << attr.a->EntryCount() << " inverse references." << endl;
6454
} else {
6555
cout << "Map: found no inverse references. ias " << (void *) &(v.second) << ", ia " << (void*) v.first << endl;
56+
exitStatus = EXIT_FAILURE;
6657
}
67-
// }
6858

6959
EntityAggregate * aggr = instance->isdefinedby_(); //should be filled in when the file is loaded? not sure how to do it using STEPfile...
70-
//fails because isdefinedby_ uses old data member rather than map lookup
60+
//FIXME FIXME FIXME fails because isdefinedby_ uses old data member rather than map lookup
7161
if( attr.a != aggr ) {
7262
cout << "Error! got different EntityAggregate's when using map vs method" << endl;
63+
exitStatus = EXIT_FAILURE;
7364
}
7465
if( aggr && aggr->EntryCount() ) {
7566
cout << "Found " << aggr->EntryCount() << " inverse references." << endl;
76-
exit( EXIT_SUCCESS );
7767
} else {
7868
cout << "inverse attr is not defined" << endl;
79-
exit( EXIT_FAILURE );
69+
exitStatus = EXIT_FAILURE;
8070
}
71+
exit( exitStatus );
8172
}
8273

0 commit comments

Comments
 (0)