-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathExpDict.h
More file actions
1950 lines (1608 loc) · 63.1 KB
/
ExpDict.h
File metadata and controls
1950 lines (1608 loc) · 63.1 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef EXPDICT_H
#define EXPDICT_H
/*
* NIST STEP Core Class Library
* clstepcore/ExpDict.h
* 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 <scl_export.h>
#include <sdai.h>
#include <deque>
#include <string>
#include <assert.h>
typedef SDAI_Application_instance * ( * Creator )() ;
enum AttrType_Enum {
AttrType_Explicit = 0,
AttrType_Inverse,
AttrType_Deriving,
AttrType_Redefining
};
enum AggrBoundTypeEnum {
bound_unset = 0,
bound_constant,
bound_runtime,
bound_funcall
};
#include <SingleLinkList.h>
#include <baseType.h>
#include <dictdefs.h>
#include <Str.h>
// defined and created in Registry.inline.cc
extern SCL_CORE_EXPORT const TypeDescriptor * t_sdaiINTEGER;
extern SCL_CORE_EXPORT const TypeDescriptor * t_sdaiREAL;
extern SCL_CORE_EXPORT const TypeDescriptor * t_sdaiNUMBER;
extern SCL_CORE_EXPORT const TypeDescriptor * t_sdaiSTRING;
extern SCL_CORE_EXPORT const TypeDescriptor * t_sdaiBINARY;
extern SCL_CORE_EXPORT const TypeDescriptor * t_sdaiBOOLEAN;
extern SCL_CORE_EXPORT const TypeDescriptor * t_sdaiLOGICAL;
///////////////////////////////////////////////////////////////////////////////
// Dictionary_instance
///////////////////////////////////////////////////////////////////////////////
class SCL_CORE_EXPORT Dictionary_instance {
protected:
Dictionary_instance() {}
Dictionary_instance( const Dictionary_instance & ) {}
virtual ~Dictionary_instance();
};
///////////////////////////////////////////////////////////////////////////////
class SCL_CORE_EXPORT TypeDescLinkNode : public SingleLinkNode {
private:
protected:
TypeDescriptor * _typeDesc;
public:
TypeDescLinkNode();
virtual ~TypeDescLinkNode();
const TypeDescriptor * TypeDesc() const {
return _typeDesc;
}
void TypeDesc( TypeDescriptor * td ) {
_typeDesc = td;
}
};
class SCL_CORE_EXPORT TypeDescriptorList : public SingleLinkList {
private:
protected:
public:
TypeDescriptorList();
virtual ~TypeDescriptorList();
virtual SingleLinkNode * NewNode() {
return new TypeDescLinkNode;
}
TypeDescLinkNode * AddNode( TypeDescriptor * td ) {
TypeDescLinkNode * node = ( TypeDescLinkNode * ) NewNode();
node->TypeDesc( td );
SingleLinkList::AppendNode( node );
return node;
}
};
class SCL_CORE_EXPORT TypeDescItr {
protected:
const TypeDescriptorList & tdl;
const TypeDescLinkNode * cur;
public:
TypeDescItr( const TypeDescriptorList & tdList );
virtual ~TypeDescItr();
void ResetItr() {
cur = ( TypeDescLinkNode * )( tdl.GetHead() );
}
const TypeDescriptor * NextTypeDesc();
};
///////////////////////////////////////////////////////////////////////////////
class SCL_CORE_EXPORT EntityDescLinkNode : public SingleLinkNode {
private:
protected:
EntityDescriptor * _entityDesc;
public:
EntityDescLinkNode();
virtual ~EntityDescLinkNode();
EntityDescriptor * EntityDesc() const {
return _entityDesc;
}
void EntityDesc( EntityDescriptor * ed ) {
_entityDesc = ed;
}
};
class SCL_CORE_EXPORT EntityDescriptorList : public SingleLinkList {
private:
protected:
public:
EntityDescriptorList();
virtual ~EntityDescriptorList();
virtual SingleLinkNode * NewNode() {
return new EntityDescLinkNode;
}
EntityDescLinkNode * AddNode( EntityDescriptor * ed ) {
EntityDescLinkNode * node = ( EntityDescLinkNode * ) NewNode();
node->EntityDesc( ed );
SingleLinkList::AppendNode( node );
return node;
}
};
typedef EntityDescriptorList * Entity__set_ptr;
typedef Entity__set_ptr Entity__set_var;
class SCL_CORE_EXPORT EntityDescItr {
protected:
const EntityDescriptorList & edl;
const EntityDescLinkNode * cur;
public:
EntityDescItr( const EntityDescriptorList & edList );
virtual ~EntityDescItr();
void ResetItr() {
cur = ( EntityDescLinkNode * )( edl.GetHead() );
}
const EntityDescriptor * NextEntityDesc();
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Interfaced_item
///////////////////////////////////////////////////////////////////////////////
class SCL_CORE_EXPORT Interfaced_item : public Dictionary_instance {
protected:
Interfaced_item();
Interfaced_item( const Interfaced_item & );
Interfaced_item( const char * foreign_schema );
virtual ~Interfaced_item();
public:
Express_id _foreign_schema;
const Express_id foreign_schema_();
// private:
void foreign_schema_( const Express_id & );
};
///////////////////////////////////////////////////////////////////////////////
// Explicit_item_id
///////////////////////////////////////////////////////////////////////////////
class SCL_CORE_EXPORT Explicit_item_id : public Interfaced_item {
protected:
Explicit_item_id();
Explicit_item_id( const Explicit_item_id & );
Explicit_item_id( const char * foreign_schema, TypeDescriptor * ld,
const char * oi, const char * ni )
: Interfaced_item( foreign_schema ), _local_definition( ld ), _original_id( oi ), _new_id( ni ) {}
virtual ~Explicit_item_id();
public:
// definition in the local schema. The TypeDescriptor (or subtype) is not
// implemented quite right - the name in it is the original (foreign
// schema) name. The USE or REFERENCED renames are listed in
// TypeDescriptor's altNames member variable.
// Warning: This is currently a null ptr for objects other than
// types and entities - that is - if this is a USEd FUNCTION or PROCEDURE
// this ptr will be null.
const TypeDescriptor * _local_definition;
// name in originating schema - only exists if it has been renamed.
Express_id _original_id;
Express_id _new_id; // original or renamed name via USE or REFERENCE (non-SDAI)
const TypeDescriptor * local_definition_() const {
return _local_definition;
}
const Express_id original_id_() const {
return _original_id;
}
// non-sdai, renamed name
const Express_id new_id_() const {
return _new_id;
}
// return string "USE" or "REFERENCE"
virtual const char * EXPRESS_type() = 0;
// private:
void local_definition_( const TypeDescriptor * td ) {
_local_definition = td;
}
void original_id_( const Express_id & ei ) {
_original_id = ei;
}
// non-sdai
void new_id_( const Express_id & ni ) {
_new_id = ni;
}
};
typedef Explicit_item_id * Explicit_item_id_ptr;
class SCL_CORE_EXPORT Used_item : public Explicit_item_id {
public:
Used_item() {}
Used_item( const char * foreign_schema, TypeDescriptor * ld,
const char * oi, const char * ni )
: Explicit_item_id( foreign_schema, ld, oi, ni ) {}
virtual ~Used_item();
const char * EXPRESS_type() {
return "USE";
}
};
typedef Used_item * Used_item_ptr;
class SCL_CORE_EXPORT Referenced_item : public Explicit_item_id {
public:
Referenced_item() {}
Referenced_item( const char * foreign_schema, TypeDescriptor * ld,
const char * oi, const char * ni )
: Explicit_item_id( foreign_schema, ld, oi, ni ) {}
virtual ~Referenced_item();
const char * EXPRESS_type() {
return "REFERENCE";
}
};
typedef Referenced_item * Referenced_item_ptr;
class SCL_CORE_EXPORT Explicit_item_id__set {
public:
Explicit_item_id__set( int = 16 );
~Explicit_item_id__set();
Explicit_item_id_ptr & operator[]( int index );
void Insert( Explicit_item_id_ptr, int index );
void Append( Explicit_item_id_ptr );
void Remove( int index );
int Index( Explicit_item_id_ptr );
int Count();
void Clear();
private:
void Check( int index );
private:
Explicit_item_id_ptr * _buf;
int _bufsize;
int _count;
};
typedef Explicit_item_id__set * Explicit_item_id__set_ptr;
typedef Explicit_item_id__set_ptr Explicit_item_id__set_var;
///////////////////////////////////////////////////////////////////////////////
// Implicit_item_id
///////////////////////////////////////////////////////////////////////////////
class SCL_CORE_EXPORT Implicit_item_id : public Interfaced_item {
protected:
Implicit_item_id();
Implicit_item_id( Implicit_item_id & );
virtual ~Implicit_item_id();
public:
const TypeDescriptor * _local_definition;
const TypeDescriptor * local_definition_() const {
return _local_definition;
}
// private:
void local_definition_( const TypeDescriptor * td ) {
_local_definition = td;
}
};
typedef Implicit_item_id * Implicit_item_id_ptr;
///////////////////////////////////////////////////////////////////////////////
// Implicit_item_id__set
///////////////////////////////////////////////////////////////////////////////
class SCL_CORE_EXPORT Implicit_item_id__set {
public:
Implicit_item_id__set( int = 16 );
~Implicit_item_id__set();
Implicit_item_id_ptr & operator[]( int index );
void Insert( Implicit_item_id_ptr, int index );
void Append( Implicit_item_id_ptr );
void Remove( int index );
int Index( Implicit_item_id_ptr );
int Count();
void Clear();
private:
void Check( int index );
private:
Implicit_item_id_ptr * _buf;
int _bufsize;
int _count;
};
typedef Implicit_item_id__set * Implicit_item_id__set_ptr;
typedef Implicit_item_id__set_ptr Implicit_item_id__set_var;
///////////////////////////////////////////////////////////////////////////////
// Interface_spec
///////////////////////////////////////////////////////////////////////////////
class SCL_CORE_EXPORT Interface_spec : public Dictionary_instance {
public:
Express_id _current_schema_id; // schema containing the USE/REF stmt
// set of objects from USE/REFERENCE stmt(s)
Explicit_item_id__set_var _explicit_items;
Implicit_item_id__set_var _implicit_items; //not yet initialized for schema
// non-SDAI, not useful for SDAI use of Interface_spec (it would need to
// be a list).
// schema that defined the USE/REFd objects
Express_id _foreign_schema_id;
// non-SDAI, not useful for SDAI use of Interface_spec (it would need to
// be a list of ints).
// schema USEs or REFERENCEs all objects from foreign schema
int _all_objects;
Interface_spec();
Interface_spec( Interface_spec & ); // not tested
Interface_spec( const char * cur_sch_id, const char * foreign_sch_id,
int all_objects = 0 );
virtual ~Interface_spec();
Express_id current_schema_id_() {
return _current_schema_id;
}
Express_id foreign_schema_id_() {
return _foreign_schema_id;
}
Explicit_item_id__set_var explicit_items_() {
return _explicit_items;
}
// this is not yet initialized for the schema
Implicit_item_id__set_var implicit_items_() {
return _implicit_items;
}
// private:
void current_schema_id_( const Express_id & ei ) {
_current_schema_id = ei;
}
void foreign_schema_id_( const Express_id & fi ) {
_foreign_schema_id = fi;
}
int all_objects_() {
return _all_objects;
}
void all_objects_( int ao ) {
_all_objects = ao;
}
};
typedef Interface_spec * Interface_spec_ptr;
class SCL_CORE_EXPORT Interface_spec__set {
public:
Interface_spec__set( int = 16 );
~Interface_spec__set();
Interface_spec_ptr & operator[]( int index );
void Insert( Interface_spec_ptr, int index );
void Append( Interface_spec_ptr );
void Remove( int index );
int Index( Interface_spec_ptr );
int Count();
void Clear();
private:
void Check( int index );
private:
Interface_spec_ptr * _buf;
int _bufsize;
int _count;
};
typedef Interface_spec__set * Interface_spec__set_ptr;
typedef Interface_spec__set_ptr Interface_spec__set_var;
class SCL_CORE_EXPORT Type_or_rule : public Dictionary_instance {
public:
Type_or_rule();
Type_or_rule( const Type_or_rule & );
virtual ~Type_or_rule();
};
typedef Type_or_rule * Type_or_rule_ptr;
typedef Type_or_rule_ptr Type_or_rule_var;
class SCL_CORE_EXPORT Where_rule : public Dictionary_instance {
public:
Express_id _label;
Type_or_rule_var _type_or_rule;
// non-SDAI
std::string _comment; // Comment contained in the EXPRESS.
// Should be properly formatted to include (* *)
// Will be written to EXPRESS as-is (w/out formatting)
Where_rule();
Where_rule( const Where_rule & );
Where_rule( const char * label, Type_or_rule_var tor = 0 )
: _label( label ), _type_or_rule( tor ) { }
virtual ~Where_rule();
Express_id label_() const {
return _label;
}
const Type_or_rule_var parent_item() const {
return _type_or_rule;
}
std::string comment_() const {
return _comment;
}
void label_( const Express_id & ei ) {
_label = ei;
}
void parent_item( const Type_or_rule_var & tor ) {
_type_or_rule = tor;
}
void comment_( const char * c ) {
_comment = c;
}
};
typedef Where_rule * Where_rule_ptr;
class SCL_CORE_EXPORT Where_rule__list {
public:
Where_rule__list( int = 16 );
~Where_rule__list();
Where_rule_ptr & operator[]( int index );
void Insert( Where_rule_ptr, int index );
void Append( Where_rule_ptr );
void Remove( int index );
int Index( Where_rule_ptr );
int Count();
void Clear();
private:
void Check( int index );
private:
Where_rule_ptr * _buf;
int _bufsize;
int _count;
};
typedef Where_rule__list * Where_rule__list_ptr;
typedef Where_rule__list_ptr Where_rule__list_var;
class SCL_CORE_EXPORT Global_rule : public Dictionary_instance {
public:
Express_id _name;
Entity__set_var _entities; // not implemented
Where_rule__list_var _where_rules;
Schema_ptr _parent_schema;
std::string _rule_text; // non-SDAI
Global_rule();
Global_rule( const char * n, Schema_ptr parent_sch, const std::string & rt );
Global_rule( Global_rule & ); // not fully implemented
virtual ~Global_rule();
Express_id name_() const {
return _name;
}
const Entity__set_var entities_() const {
return _entities;
}
const Where_rule__list_var where_rules_() const {
return _where_rules;
}
const Schema_ptr parent_schema_() const {
return _parent_schema;
}
const char * rule_text_() {
return const_cast<char *>( _rule_text.c_str() );
}
void name_( Express_id & n ) {
_name = n;
}
void entities_( const Entity__set_var & e ); // not implemented
void where_rules_( const Where_rule__list_var & wrl ); // not implemented
void parent_schema_( const Schema_ptr & s ) {
_parent_schema = s;
}
void rule_text_( const char * rt ) {
_rule_text = rt;
}
};
typedef Global_rule * Global_rule_ptr;
class SCL_CORE_EXPORT Global_rule__set {
public:
Global_rule__set( int = 16 );
~Global_rule__set();
Global_rule_ptr & operator[]( int index );
void Insert( Global_rule_ptr, int index );
void Append( Global_rule_ptr );
void Remove( int index );
int Index( Global_rule_ptr );
int Count();
void Clear();
private:
void Check( int index );
private:
Global_rule_ptr * _buf;
int _bufsize;
int _count;
};
typedef Global_rule__set * Global_rule__set_ptr;
typedef Global_rule__set_ptr Global_rule__set_var;
class SCL_CORE_EXPORT Uniqueness_rule : public Dictionary_instance {
public:
Express_id _label;
const EntityDescriptor * _parent_entity;
// non-SDAI
std::string _comment; // Comment contained in the EXPRESS.
// Should be properly formatted to include (* *)
// Will be written to EXPRESS as-is (w/out formatting)
Uniqueness_rule();
Uniqueness_rule( const Uniqueness_rule & );
Uniqueness_rule( const char * label, EntityDescriptor * pe = 0 )
: _label( label ), _parent_entity( pe ) { }
virtual ~Uniqueness_rule();
Express_id label_() const {
return _label;
}
const EntityDescriptor * parent_() const {
return _parent_entity;
}
std::string & comment_() {
return _comment;
}
void label_( const Express_id & ei ) {
_label = ei;
}
void parent_( const EntityDescriptor * pe ) {
_parent_entity = pe;
}
void comment_( const char * c ) {
_comment = c;
}
};
typedef Uniqueness_rule * Uniqueness_rule_ptr;
class SCL_CORE_EXPORT Uniqueness_rule__set {
public:
Uniqueness_rule__set( int = 16 );
~Uniqueness_rule__set();
Uniqueness_rule_ptr & operator[]( int index );
void Insert( Uniqueness_rule_ptr, int index );
void Append( Uniqueness_rule_ptr );
void Remove( int index );
int Index( Uniqueness_rule_ptr );
int Count();
void Clear();
private:
void Check( int index );
private:
Uniqueness_rule_ptr * _buf;
int _bufsize;
int _count;
};
typedef Uniqueness_rule__set * Uniqueness_rule__set_ptr;
typedef Uniqueness_rule__set_ptr Uniqueness_rule__set_var;
typedef SDAI_Model_contents_ptr( * ModelContentsCreator )() ;
/**
* \class Schema (was SchemaDescriptor) - a class of this type is generated and contains schema info.
*/
class SCL_CORE_EXPORT Schema : public Dictionary_instance {
protected:
const char * _name ;
EntityDescriptorList _entList; // list of entities in the schema
TypeDescriptorList _typeList; // list of types in the schema
TypeDescriptorList _unnamed_typeList; // list of unnamed types in the schema (for cleanup)
Interface_spec _interface; // list of USE and REF interfaces (SDAI)
// non-SDAI lists
Interface_spec__set_var _use_interface_list; // list of USE interfaces
Interface_spec__set_var _ref_interface_list; // list of REFERENCE interfaces
std::deque< std::string > _function_list; // of EXPRESS functions
std::deque< std::string > _procedure_list; // of EXPRESS procedures
Global_rule__set_var _global_rules;
public:
ModelContentsCreator CreateNewModelContents;
Schema( const char * schemaName );
virtual ~Schema();
void AssignModelContentsCreator( ModelContentsCreator f = 0 ) {
CreateNewModelContents = f;
}
const char * Name() const {
return _name;
}
void Name( const char * n ) {
_name = n;
}
Interface_spec & interface_() {
return _interface;
}
Interface_spec__set_var use_interface_list_() {
return
_use_interface_list;
}
Interface_spec__set_var ref_interface_list_() {
return _ref_interface_list;
}
std::deque< std::string > function_list_() {
return _function_list;
}
void AddFunction( const std::string & f );
Global_rule__set_var global_rules_() { // const
return _global_rules;
}
void AddGlobal_rule( Global_rule_ptr gr );
void global_rules_( Global_rule__set_var & grs ); // not implemented
std::deque< std::string > procedure_list_() {
return _procedure_list;
}
void AddProcedure( const std::string & p );
EntityDescLinkNode * AddEntity( EntityDescriptor * ed ) {
return _entList.AddNode( ed );
}
TypeDescLinkNode * AddType( TypeDescriptor * td ) {
return _typeList.AddNode( td );
}
TypeDescLinkNode * AddUnnamedType( TypeDescriptor * td ) {
return _unnamed_typeList.AddNode( td );
}
// the whole schema
void GenerateExpress( ostream & out ) const;
// USE, REFERENCE definitions
void GenerateUseRefExpress( ostream & out ) const;
// TYPE definitions
void GenerateTypesExpress( ostream & out ) const;
// Entity definitions
void GenerateEntitiesExpress( ostream & out ) const;
};
typedef Schema SchemaDescriptor;
///////////////////////////////////////////////////////////////////////////////
class SCL_CORE_EXPORT AttrDescLinkNode : public SingleLinkNode {
private:
protected:
AttrDescriptor * _attrDesc;
public:
AttrDescLinkNode();
virtual ~AttrDescLinkNode();
const AttrDescriptor * AttrDesc() const {
return _attrDesc;
}
void AttrDesc( AttrDescriptor * ad ) {
_attrDesc = ad;
}
};
class SCL_CORE_EXPORT AttrDescriptorList : public SingleLinkList {
private:
protected:
public:
AttrDescriptorList();
virtual ~AttrDescriptorList();
virtual SingleLinkNode * NewNode() {
return new AttrDescLinkNode;
}
AttrDescLinkNode * AddNode( AttrDescriptor * ad );
};
class SCL_CORE_EXPORT AttrDescItr {
protected:
const AttrDescriptorList & adl;
const AttrDescLinkNode * cur;
public:
AttrDescItr( const AttrDescriptorList & adList );
virtual ~AttrDescItr();
void ResetItr() {
cur = ( AttrDescLinkNode * )( adl.GetHead() );
}
const AttrDescriptor * NextAttrDesc();
};
///////////////////////////////////////////////////////////////////////////////
class SCL_CORE_EXPORT Inverse_attributeLinkNode : public SingleLinkNode {
private:
protected:
Inverse_attribute * _invAttr;
public:
Inverse_attributeLinkNode();
virtual ~Inverse_attributeLinkNode();
const Inverse_attribute * Inverse_attr() const {
return _invAttr;
}
void Inverse_attr( Inverse_attribute * ia ) {
_invAttr = ia;
}
};
class SCL_CORE_EXPORT Inverse_attributeList : public SingleLinkList {
private:
protected:
public:
Inverse_attributeList();
virtual ~Inverse_attributeList();
virtual SingleLinkNode * NewNode() {
return new Inverse_attributeLinkNode;
}
Inverse_attributeLinkNode * AddNode( Inverse_attribute * ia );
};
class SCL_CORE_EXPORT InverseAItr {
protected:
const Inverse_attributeList & ial;
const Inverse_attributeLinkNode * cur;
public:
InverseAItr( const Inverse_attributeList & iaList );
virtual ~InverseAItr();
void ResetItr() {
cur = ( Inverse_attributeLinkNode * )( ial.GetHead() );
}
const Inverse_attribute * NextInverse_attribute();
};
/**
* \class AttrDescriptor
* An instance of this class will be generated for each attribute for
* an Entity. They will be pointed to by the EntityTypeDescriptors.
*/
class SCL_CORE_EXPORT AttrDescriptor {
protected:
const char * _name ; // the attributes name
// this defines the domain of the attribute
const TypeDescriptor * _domainType ;
SDAI_LOGICAL _optional;
SDAI_LOGICAL _unique;
AttrType_Enum _attrType; // former attribute _derived
const EntityDescriptor & _owner ; // the owning entityDescriptor
public:
AttrDescriptor(
const char * name, // i.e. char *
const TypeDescriptor * domainType,
Logical optional, // i.e. F U or T
Logical unique, // i.e. F U or T
AttrType_Enum at,// AttrType_Explicit, AttrType_Inverse,
// AttrType_Deriving,AttrType_Redefining
const EntityDescriptor & owner
);
virtual ~AttrDescriptor();
const char * GenerateExpress( std::string & buf ) const;
// the attribute Express def
virtual const char * AttrExprDefStr( std::string & s ) const;
// left side of attr def
const char * Name() const {
return _name;
}
void Name( const char * n ) {
_name = n;
}
// BaseType() is the underlying type of this attribute.
// NonRefType() is the first non REFERENCE_TYPE type
// e.g. Given attributes of each of the following types
// TYPE count = INTEGER;
// TYPE ref_count = count;
// TYPE count_set = SET OF ref_count;
// BaseType() will return INTEGER_TYPE for an attr of each type.
// BaseTypeDescriptor() returns the TypeDescriptor for Integer
// NonRefType() will return INTEGER_TYPE for the first two. For an
// attribute of type count_set NonRefType() would return
// AGGREGATE_TYPE
// NonRefTypeDescriptor() returns the TypeDescriptor for Integer
// for the first two and a TypeDescriptor for an
// aggregate for the last.
const PrimitiveType BaseType() const;
const TypeDescriptor * BaseTypeDescriptor() const;
// the first PrimitiveType that is not REFERENCE_TYPE (the first
// TypeDescriptor *_referentType that does not have REFERENCE_TYPE
// for it's fundamentalType variable). This would return the same
// as BaseType() for fundamental types. An aggregate type
// would return AGGREGATE_TYPE then you could find out the type of
// an element by calling AggrElemType(). Select types
// would work the same?
const PrimitiveType NonRefType() const;
const TypeDescriptor * NonRefTypeDescriptor() const;
int IsAggrType() const;
const PrimitiveType AggrElemType() const;
const TypeDescriptor * AggrElemTypeDescriptor() const;
// The type of the attributes TypeDescriptor
const PrimitiveType Type() const;
const char * TypeName() const; // right side of attr def
// an expanded right side of attr def
const char * ExpandedTypeName( std::string & s ) const;
int RefersToType() const {
return !( _domainType == 0 );
}
const TypeDescriptor * ReferentType() const {
return _domainType;
}
const TypeDescriptor * DomainType() const {
return _domainType;
}
void DomainType( const TypeDescriptor * td ) {
_domainType = td;
}
void ReferentType( const TypeDescriptor * td ) {
_domainType = td;
}
const SDAI_LOGICAL & Optional() const {
return _optional;
}
void Optional( SDAI_LOGICAL & opt ) {
_optional.put( opt.asInt() );
}
void Optional( Logical opt ) {
_optional.put( opt );
}
void Optional( const char * opt ) {
_optional.put( opt );
}
const SDAI_LOGICAL & Unique() const {
return _unique;
}
void Unique( SDAI_LOGICAL uniq ) {
_unique.put( uniq.asInt() );
}
void Unique( Logical uniq ) {
_unique.put( uniq );
}
void Unique( const char * uniq ) {
_unique.put( uniq );
}
void AttrType( enum AttrType_Enum ate ) {
_attrType = ate;
}
enum AttrType_Enum AttrType() const {
return _attrType;
}
Logical Explicit() const;
Logical Inverse() const;
Logical Redefining() const;
Logical Deriving() const;
//outdated functions, use AttrType func above, new support of redefined
Logical Derived() const {
return Deriving();
}
void Derived( Logical x ); // outdated DAS
void Derived( SDAI_LOGICAL x ); // outdated DAS
void Derived( const char * x ); // outdated DAS
const SDAI_LOGICAL & Optionality() const {
return _optional;
}
void Optionality( SDAI_LOGICAL & opt ) {
_optional.put( opt.asInt() );