Skip to content

Commit bd402b2

Browse files
committed
add STEPinvAttrList for inv attr descs and setter/getter pointers
this will allow access to inverse attr values even with late binding, and is necessary to set these attr values when the instances are being loaded
1 parent ca56023 commit bd402b2

File tree

3 files changed

+112
-3
lines changed

3 files changed

+112
-3
lines changed

src/clstepcore/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
set(LIBSTEPCORE_SRCS
33
sdaiApplication_instance.cc
44
STEPcomplex.cc
5+
STEPaggregate.cc
56
STEPattribute.cc
67
STEPattribute.inline.cc
8+
STEPattributeList.cc
9+
STEPinvAttrList.cc
10+
STEPundefined.cc
711
sdai.cc
812
sdaiSelect.cc
9-
STEPaggregate.cc
10-
STEPundefined.cc
11-
STEPattributeList.cc
1213
SingleLinkList.cc
1314
SingleLinkList.inline.cc
1415
Registry.inline.cc
@@ -48,6 +49,7 @@ set(SC_CLSTEPCORE_HDRS
4849
STEPaggregate.h
4950
STEPattribute.h
5051
STEPattributeList.h
52+
STEPinvAttrList.h
5153
STEPcomplex.h
5254
STEPundefined.h
5355
instmgr.h

src/clstepcore/STEPinvAttrList.cc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
/** \file STEPinvAttrList.cc
3+
* derived from STEPattributeList.cc
4+
*/
5+
6+
#include <STEPinvAttrList.h>
7+
#include <ExpDict.h>
8+
#include "sc_memmgr.h"
9+
10+
invAttrListNode::invAttrListNode( Inverse_attribute * a, setter_t s, getter_t g ): attr( a ), set( s ), get( g ) {}
11+
12+
invAttrListNode::~invAttrListNode() {}
13+
14+
STEPinvAttrList::STEPinvAttrList() {}
15+
16+
STEPinvAttrList::~STEPinvAttrList() {}
17+
18+
invAttrListNode * STEPinvAttrList::operator []( int n ) {
19+
int x = 0;
20+
invAttrListNode * a = ( invAttrListNode * )head;
21+
int cnt = EntryCount();
22+
if( n < cnt ) {
23+
while( a && ( x < n ) ) {
24+
a = ( invAttrListNode * )( a->next );
25+
x++;
26+
}
27+
}
28+
if( !a ) {
29+
cerr << "\nERROR in STEP Core library: " << __FILE__ << ":"
30+
<< __LINE__ << "\n" << _POC_ << "\n\n";
31+
}
32+
return a;
33+
}
34+
35+
int STEPinvAttrList::list_length() {
36+
return EntryCount();
37+
}
38+
39+
void STEPinvAttrList::push( Inverse_attribute * a, setter_t s, getter_t g ) {
40+
invAttrListNode * an = ( invAttrListNode * )head;
41+
42+
// if the attribute already exists in the list, don't push it
43+
while( an ) {
44+
if( a == ( an -> attr ) ) {
45+
return;
46+
}
47+
an = ( invAttrListNode * )( an->next );
48+
}
49+
invAttrListNode * ialn = new invAttrListNode( a, s, g );
50+
AppendNode( ialn );
51+
}

src/clstepcore/STEPinvAttrList.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
#ifndef _STEPinvAttrList_h
3+
#define _STEPinvAttrList_h 1
4+
5+
/** \file STEPinvAttrList.h
6+
* derived from STEPattributeList.h
7+
*
8+
* Similar to Inverse_attributeList, but this list also contains pointers to the setter and getter.
9+
*
10+
* \sa Inverse_attributeList
11+
*/
12+
13+
class Inverse_attribute;
14+
15+
#include <sc_export.h>
16+
#include <SingleLinkList.h>
17+
18+
class STEPinvAttrList;
19+
class EntityAggregate;
20+
class SDAI_Application_instance;
21+
typedef void ( *setter_t )( SDAI_Application_instance*, EntityAggregate * );
22+
typedef EntityAggregate * ( *getter_t )( const SDAI_Application_instance * );
23+
24+
/// Similar to Inverse_attributeList, but this list also contains pointers to the setter and getter.
25+
class SC_CORE_EXPORT invAttrListNode : public SingleLinkNode {
26+
friend class STEPinvAttrList;
27+
protected:
28+
Inverse_attribute * attr;
29+
setter_t set;
30+
getter_t get;
31+
public:
32+
invAttrListNode( Inverse_attribute * a, setter_t s, getter_t g );
33+
virtual ~invAttrListNode();
34+
setter_t setter() {
35+
return set;
36+
}
37+
getter_t getter() {
38+
return get;
39+
}
40+
Inverse_attribute * inverseADesc() {
41+
return attr;
42+
}
43+
};
44+
45+
/// Similar to Inverse_attributeList, but this list also contains pointers to the setter and getter.
46+
class SC_CORE_EXPORT STEPinvAttrList : public SingleLinkList {
47+
public:
48+
STEPinvAttrList();
49+
virtual ~STEPinvAttrList();
50+
invAttrListNode * operator []( int n );
51+
int list_length();
52+
void push( Inverse_attribute * a, setter_t s, getter_t g );
53+
};
54+
55+
56+
#endif

0 commit comments

Comments
 (0)