forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaggrTypeDescriptor.h
More file actions
227 lines (193 loc) · 6.99 KB
/
aggrTypeDescriptor.h
File metadata and controls
227 lines (193 loc) · 6.99 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#ifndef AGGRTYPEDESCRIPTOR_H
#define AGGRTYPEDESCRIPTOR_H
#include "typeDescriptor.h"
#include "create_Aggr.h"
#include "assert.h"
enum AggrBoundTypeEnum {
bound_unset = 0,
bound_constant,
bound_runtime,
bound_funcall
};
/**
* \class AggrTypeDescriptor
* I think we decided on a simplistic representation of aggr. types for now?
* i.e. just have one AggrTypeDesc for Array of [list of] [set of] someType
* the inherited variable _referentType will point to the TypeDesc for someType
* So I don't believe this class was necessary. If we were to retain
* info for each of the [aggr of]'s in the example above then there would be
* one of these for each [aggr of] above and they would be strung
* together by the _aggrDomainType variables. If you can make this
* work then go for it.
*/
class SC_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor {
protected:
SDAI_Integer _bound1, _bound2;
SDAI_LOGICAL _uniqueElements;
TypeDescriptor * _aggrDomainType;
AggregateCreator CreateNewAggr;
AggrBoundTypeEnum _bound1_type, _bound2_type;
boundCallbackFn _bound1_callback, _bound2_callback;
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable: 4251 )
#endif
std::string _bound1_str, _bound2_str;
#ifdef _MSC_VER
#pragma warning( pop )
#endif
public:
void AssignAggrCreator( AggregateCreator f = 0 );
STEPaggregate * CreateAggregate();
AggrTypeDescriptor( );
AggrTypeDescriptor( SDAI_Integer b1, SDAI_Integer b2,
Logical uniqElem,
TypeDescriptor * aggrDomType );
AggrTypeDescriptor( const char * nm, PrimitiveType ft,
Schema * origSchema, const char * d,
AggregateCreator f = 0 )
: TypeDescriptor( nm, ft, origSchema, d ), _bound1( 0 ), _bound2( 0 ), _uniqueElements( 0 ), _aggrDomainType( NULL ), CreateNewAggr( f ), _bound1_type( bound_unset ), _bound2_type( bound_unset ), _bound1_callback( NULL ), _bound2_callback( NULL ) { }
virtual ~AggrTypeDescriptor();
/// find bound type
AggrBoundTypeEnum Bound1Type() const {
return _bound1_type;
}
/// get a constant bound
SDAI_Integer Bound1( ) const {
assert( _bound1_type == bound_constant );
return _bound1;
}
/// get a runtime bound using an object's 'this' pointer
SDAI_Integer Bound1Runtime( SDAI_Application_instance * this_ptr ) const {
assert( this_ptr && ( _bound1_type == bound_runtime ) );
return _bound1_callback( this_ptr ) ;
}
/// get a bound's EXPRESS function call string
std::string Bound1Funcall() const {
return _bound1_str;
}
/// set bound to a constant
void SetBound1( SDAI_Integer b1 ) {
_bound1 = b1;
_bound1_type = bound_constant;
}
///set bound's callback fn. only for bounds dependent on an attribute
void SetBound1FromMemberAccessor( boundCallbackFn callback ) {
_bound1_callback = callback;
_bound1_type = bound_runtime;
}
///set bound from express function call. currently, this only stores the function call as a string.
void SetBound1FromExpressFuncall( std::string s ) {
_bound1_str = s;
_bound1_type = bound_funcall;
}
/// find bound type
AggrBoundTypeEnum Bound2Type() const {
return _bound2_type;
}
/// get a constant bound
SDAI_Integer Bound2( ) const {
assert( _bound2_type == bound_constant );
return _bound2;
}
/// get a runtime bound using an object's 'this' pointer
SDAI_Integer Bound2Runtime( SDAI_Application_instance * this_ptr ) const {
assert( this_ptr && ( _bound2_type == bound_runtime ) );
return _bound2_callback( this_ptr ) ;
}
/// get a bound's EXPRESS function call string
std::string Bound2Funcall() const {
return _bound2_str;
}
/// set bound to a constant
void SetBound2( SDAI_Integer b2 ) {
_bound2 = b2;
_bound2_type = bound_constant;
}
///set bound's callback fn
void SetBound2FromMemberAccessor( boundCallbackFn callback ) {
_bound2_callback = callback;
_bound2_type = bound_runtime;
}
///set bound from express function call. currently, this only stores the function call as a string.
void SetBound2FromExpressFuncall( std::string s ) {
_bound2_str = s;
_bound2_type = bound_funcall;
}
SDAI_LOGICAL & UniqueElements() {
return _uniqueElements;
}
void UniqueElements( SDAI_LOGICAL & ue ) {
_uniqueElements.put( ue.asInt() );
}
void UniqueElements( Logical ue ) {
_uniqueElements.put( ue );
}
void UniqueElements( const char * ue ) {
_uniqueElements.put( ue );
}
class TypeDescriptor * AggrDomainType() {
return _aggrDomainType;
}
void AggrDomainType( TypeDescriptor * adt ) {
_aggrDomainType = adt;
}
};
class SC_CORE_EXPORT ArrayTypeDescriptor : public AggrTypeDescriptor {
protected:
SDAI_LOGICAL _optionalElements;
public:
ArrayTypeDescriptor( ) : _optionalElements( "UNKNOWN_TYPE" ) { }
ArrayTypeDescriptor( Logical optElem ) : _optionalElements( optElem )
{ }
ArrayTypeDescriptor( const char * nm, PrimitiveType ft,
Schema * origSchema, const char * d,
AggregateCreator f = 0 )
: AggrTypeDescriptor( nm, ft, origSchema, d, f ),
_optionalElements( "UNKNOWN_TYPE" )
{ }
virtual ~ArrayTypeDescriptor() {}
SDAI_LOGICAL & OptionalElements() {
return _optionalElements;
}
void OptionalElements( SDAI_LOGICAL & oe ) {
_optionalElements.put( oe.asInt() );
}
void OptionalElements( Logical oe ) {
_optionalElements.put( oe );
}
void OptionalElements( const char * oe ) {
_optionalElements.put( oe );
}
};
class SC_CORE_EXPORT ListTypeDescriptor : public AggrTypeDescriptor {
protected:
public:
ListTypeDescriptor( ) { }
ListTypeDescriptor( const char * nm, PrimitiveType ft,
Schema * origSchema, const char * d,
AggregateCreator f = 0 )
: AggrTypeDescriptor( nm, ft, origSchema, d, f ) { }
virtual ~ListTypeDescriptor() { }
};
class SC_CORE_EXPORT SetTypeDescriptor : public AggrTypeDescriptor {
protected:
public:
SetTypeDescriptor( ) { }
SetTypeDescriptor( const char * nm, PrimitiveType ft,
Schema * origSchema, const char * d,
AggregateCreator f = 0 )
: AggrTypeDescriptor( nm, ft, origSchema, d, f ) { }
virtual ~SetTypeDescriptor() { }
};
class SC_CORE_EXPORT BagTypeDescriptor : public AggrTypeDescriptor {
protected:
public:
BagTypeDescriptor( ) { }
BagTypeDescriptor( const char * nm, PrimitiveType ft,
Schema * origSchema, const char * d,
AggregateCreator f = 0 )
: AggrTypeDescriptor( nm, ft, origSchema, d, f ) { }
virtual ~BagTypeDescriptor() { }
};
#endif //AGGRTYPEDESCRIPTOR_H