forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTEPattribute.inline.cc
More file actions
195 lines (167 loc) · 6.06 KB
/
STEPattribute.inline.cc
File metadata and controls
195 lines (167 loc) · 6.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
* NIST STEP Core Class Library
* clstepcore/STEPattribute.inline.cc
* April 1997
* K. C. Morris
* David Sauder
* Development of this software was funded by the United States Government,
* and is not subject to copyright.
*/
#include <assert.h>
#include <STEPattribute.h>
#include <STEPaggregate.h>
#include <sdai.h>
#include <ExpDict.h>
#include "sc_memmgr.h"
/// This is needed so that STEPattribute's can be passed as references to inline functions
/// NOTE this code only does shallow copies. It may be necessary to do more, in which case
/// the destructor and assignment operator will also need examined.
STEPattribute::STEPattribute( const STEPattribute & a ) : _derive( a._derive ), _mustDeletePtr( false ),
_redefAttr( a._redefAttr ), aDesc( a.aDesc ), refCount( a.refCount ) {
ShallowCopy( & a );
//NOTE may need to do a deep copy for the following types since they are classes
/*
switch( NonRefType() ) {
case BINARY_TYPE:
case STRING_TYPE:
case ENTITY_TYPE:
case AGGREGATE_TYPE:
case ARRAY_TYPE: // DAS
case BAG_TYPE: // DAS
case SET_TYPE: // DAS
case LIST_TYPE: // DAS
case SELECT_TYPE:
case ENUM_TYPE:
case BOOLEAN_TYPE:
case LOGICAL_TYPE:
default:
break;
}
*/
}
/// INTEGER
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Integer * p ): _derive( false ),
_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
ptr.i = p;
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
}
/// BINARY
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Binary * p ): _derive( false ),
_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
ptr.b = p;
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
}
/// STRING
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_String * p ): _derive( false ),
_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
ptr.S = p;
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
}
/// REAL & NUMBER
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Real * p ): _derive( false ),
_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
ptr.r = p;
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
}
/// ENTITY
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Application_instance * *p ):
_derive( false ), _mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
ptr.c = p;
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
}
/// AGGREGATE
STEPattribute::STEPattribute( const class AttrDescriptor & d, STEPaggregate * p ): _derive( false ),
_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
ptr.a = p;
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
}
/// ENUMERATION and Logical
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Enum * p ): _derive( false ),
_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
ptr.e = p;
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
}
/// SELECT
STEPattribute::STEPattribute( const class AttrDescriptor & d, class SDAI_Select * p ): _derive( false ),
_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
ptr.sh = p;
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
}
/// UNDEFINED
STEPattribute::STEPattribute( const class AttrDescriptor & d, SCLundefined * p ): _derive( false ),
_mustDeletePtr( false ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
ptr.u = p;
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
}
/// the destructor conditionally deletes the object in ptr
STEPattribute::~STEPattribute() {
if( _mustDeletePtr ) {
switch( NonRefType() ) {
case AGGREGATE_TYPE:
case ARRAY_TYPE: // DAS
case BAG_TYPE: // DAS
case SET_TYPE: // DAS
case LIST_TYPE: // DAS
if( ptr.a ) {
delete ptr.a;
ptr.a = 0;
}
break;
case BOOLEAN_TYPE:
if( ptr.e ) {
delete ( SDAI_BOOLEAN * ) ptr.e;
ptr.e = 0;
}
case LOGICAL_TYPE:
if( ptr.e ) {
delete ( SDAI_LOGICAL * ) ptr.e;
ptr.e = 0;
}
break;
default:
break;
}
}
}
/// name is the same even if redefined
const char * STEPattribute::Name() const {
return aDesc->Name();
}
const char * STEPattribute::TypeName() const {
if( _redefAttr ) {
return _redefAttr->TypeName();
}
return aDesc->TypeName();
}
BASE_TYPE STEPattribute::Type() const {
if( _redefAttr ) {
return _redefAttr->Type();
}
return aDesc->Type();
}
BASE_TYPE STEPattribute::NonRefType() const {
if( _redefAttr ) {
return _redefAttr->NonRefType();
} else if( aDesc ) {
return aDesc->NonRefType();
}
return UNKNOWN_TYPE;
}
BASE_TYPE STEPattribute::BaseType() const {
if( _redefAttr ) {
return _redefAttr->BaseType();
}
return aDesc->BaseType();
}
const TypeDescriptor * STEPattribute::ReferentType() const {
if( _redefAttr ) {
return _redefAttr->ReferentType();
}
return aDesc->ReferentType();
}
bool STEPattribute::Nullable() const {
if( _redefAttr ) {
return _redefAttr->Nullable();
}
return ( aDesc->Optionality().asInt() == LTrue );
}