home *** CD-ROM | disk | FTP | other *** search
/ ftptest.leeds.ac.uk / 2015.02.ftptest.leeds.ac.uk.tar / ftptest.leeds.ac.uk / bionet / CAE-GROUP / SCL-WIN3x / SCL.EXE / EXPDICT.H < prev    next >
C/C++ Source or Header  |  1994-08-06  |  30KB  |  869 lines

  1. #ifndef EXPDICT_H
  2. #define EXPDICT_H
  3.  
  4. /*
  5. * NIST STEP Core Class Library
  6. * clstepcore/ExpDict.h
  7. * February, 1994
  8. * K. C. Morris
  9. * David Sauder
  10.  
  11. * Development of this software was funded by the United States Government,
  12. * and is not subject to copyright.
  13. */
  14.  
  15. /* $Id: ExpDict.h,v 2.0.1.4 1994/04/05 16:36:03 sauderd Exp $  */ 
  16.  
  17.  
  18. class STEPentity;
  19. typedef  STEPentity * (* Creator) () ;
  20. //class StringAggregate;
  21.  
  22. #include <List.h>
  23. #include <sdai.h> 
  24.  
  25. #include <baseType.h>
  26.  
  27. class SchemaDescriptor;
  28. class AttrDescriptor;
  29. class InverseAttrDescriptor;
  30. class EntityDescriptor;
  31. class TypeDescriptor;
  32. class EnumerationTypeDescriptor;
  33. class AggregateTypeDescriptor;
  34. class ArrayTypeDescriptor;
  35. class SetTypeDescriptor;
  36. class ListTypeDescriptor;
  37. class SelectTypeDescriptor;
  38. class StringTypeDescriptor;
  39. class BagTypeDescriptor;
  40. class RealTypeDescriptor;
  41. class EntityDescLinkNode;
  42. class EntityDescriptorList;
  43. class AttrDescLinkNode;
  44. class AttrDescriptorList;
  45. class InverseAttrDescLinkNode;
  46. class InverseAttrDescriptorList;
  47. class TypeDescLinkNode;
  48. class TypeDescriptorList;
  49.  
  50. /*
  51. **  I tried these variations on the TypeDescriptor to get them to be
  52. *   initialized globally.  I couldn\'t do it.  They are now initialized
  53. *   in the Registry constructor (in Registry.inline.cc
  54.  
  55. extern const TypeDescriptor t_INTEGER_TYPE;
  56. extern const TypeDescriptor t_REAL_TYPE;
  57. extern const TypeDescriptor t_NUMBER_TYPE;
  58. extern const TypeDescriptor t_STRING_TYPE;
  59. extern const TypeDescriptor t_BINARY_TYPE;
  60. extern const TypeDescriptor t_BOOLEAN_TYPE;
  61. extern const TypeDescriptor t_LOGICAL_TYPE;
  62.  
  63. #define t_INTEGER_TYPE &_t_INTEGER_TYPE
  64. #define t_REAL_TYPE  &_t_REAL_TYPE
  65. #define t_NUMBER_TYPE &_t_NUMBER_TYPE
  66. #define t_STRING_TYPE &_t_STRING_TYPE
  67. #define t_BINARY_TYPE &_t_BINARY_TYPE
  68. #define t_BOOLEAN_TYPE &_t_BOOLEAN_TYPE
  69. #define t_LOGICAL_TYPE &_t_LOGICAL_TYPE
  70.  
  71. extern const TypeDescriptor * const t_INTEGER_TYPE;
  72. extern const TypeDescriptor * const t_REAL_TYPE;
  73. extern const TypeDescriptor * const t_NUMBER_TYPE;
  74. extern const TypeDescriptor * const t_STRING_TYPE;
  75. extern const TypeDescriptor * const t_BINARY_TYPE;
  76. extern const TypeDescriptor * const t_BOOLEAN_TYPE;
  77. extern const TypeDescriptor * const t_LOGICAL_TYPE;
  78. */
  79.  
  80. extern const TypeDescriptor *  t_INTEGER_TYPE;
  81. extern const TypeDescriptor *  t_REAL_TYPE;
  82. extern const TypeDescriptor *  t_NUMBER_TYPE;
  83. extern const TypeDescriptor *  t_STRING_TYPE;
  84. extern const TypeDescriptor *  t_BINARY_TYPE;
  85. extern const TypeDescriptor *  t_BOOLEAN_TYPE;
  86. extern const TypeDescriptor *  t_LOGICAL_TYPE;
  87.  
  88. ///////////////////////////////////////////////////////////////////////////////
  89. // SchemaDescriptor - a class of this type is generated and contains
  90. // the name of the schema.
  91. ///////////////////////////////////////////////////////////////////////////////
  92.  
  93. class SchemaDescriptor { 
  94.  
  95.   protected:
  96.     const char *  _name ;
  97.   public:  
  98.  
  99.     SchemaDescriptor (const char *schemaName ) { _name = schemaName; }
  100.     virtual ~SchemaDescriptor () { }
  101.  
  102.     const char * Name() const    { return _name; }
  103.     void Name (const char *  n)  { _name = n; }
  104. };
  105.  
  106.  
  107. ///////////////////////////////////////////////////////////////////////////////
  108. // EntityDescriptor
  109. // An instance of this class will be generated for each entity type
  110. // found in the schema.  This should probably be derived from the
  111. // CreatorEntry class (see STEPentity.h).  Then the binary tree that the
  112. // current software  builds up containing the entities in the schema
  113. // will be building the same thing but using the new schema info.
  114. // nodes (i.e. EntityDesc nodes) for each entity.
  115. ///////////////////////////////////////////////////////////////////////////////
  116.  
  117. ///////////////////////////////////////////////////////////////////////////////
  118.  
  119. class EntityDescLinkNode : public SingleLinkNode {
  120.  
  121.   private:
  122.   protected:
  123.     EntityDescriptor * _entityDesc;
  124.  
  125.   public:
  126.     EntityDescLinkNode() { _entityDesc = 0; }
  127.     virtual ~EntityDescLinkNode() { }
  128.  
  129.     EntityDescriptor *EntityDesc() const { return _entityDesc; }
  130.     void EntityDesc(EntityDescriptor *ed) { _entityDesc = ed; }
  131. };
  132.  
  133. class EntityDescriptorList : public SingleLinkList {
  134.  
  135.   private:
  136.   protected:
  137.   public:
  138.     EntityDescriptorList()  { }
  139.     virtual ~EntityDescriptorList() { }
  140.  
  141.     virtual SingleLinkNode * NewNode () { return new EntityDescLinkNode; }
  142.  
  143.     EntityDescLinkNode * AddNode (EntityDescriptor * ed) { 
  144.     EntityDescLinkNode *node = (EntityDescLinkNode *) NewNode();
  145.     node->EntityDesc(ed);
  146.     SingleLinkList::AppendNode(node);
  147.     return node;
  148.     }
  149. };
  150.  
  151. class EntityDescItr
  152. {
  153.   protected:
  154.     const EntityDescriptorList &edl;
  155.     const EntityDescLinkNode *cur;
  156.  
  157.   public:
  158.     EntityDescItr(const EntityDescriptorList &edList) : edl(edList)
  159.     {
  160.     cur = (EntityDescLinkNode *)( edl.GetHead() );
  161.     }
  162.     ~EntityDescItr() { };
  163.  
  164.     void ResetItr() { cur = (EntityDescLinkNode *)( edl.GetHead() ); }
  165.  
  166.     const EntityDescriptor * NextEntityDesc();
  167. };
  168.  
  169. ///////////////////////////////////////////////////////////////////////////////
  170.  
  171. class AttrDescLinkNode : public SingleLinkNode {
  172.   private:
  173.   protected:
  174.     AttrDescriptor *_attrDesc;
  175.   public:
  176.     AttrDescLinkNode()  { _attrDesc = 0; }
  177.     virtual ~AttrDescLinkNode() { }
  178.  
  179.     const class AttrDescriptor *AttrDesc() const { return _attrDesc; }
  180.     void AttrDesc(AttrDescriptor *ad) { _attrDesc = ad; }
  181. };
  182.  
  183. class AttrDescriptorList : public SingleLinkList {
  184.   private:
  185.   protected:
  186.   public:
  187.     AttrDescriptorList()  { }
  188.     virtual ~AttrDescriptorList() { }
  189.  
  190.     virtual SingleLinkNode * NewNode () { return new AttrDescLinkNode; }
  191.     AttrDescLinkNode * AddNode (AttrDescriptor * ad) {
  192.     AttrDescLinkNode *node = (AttrDescLinkNode *) NewNode();
  193.     node->AttrDesc(ad);
  194.     SingleLinkList::AppendNode(node);
  195.     return node;
  196.     }    
  197. };
  198.  
  199. class AttrDescItr
  200. {
  201.   protected:
  202.     const AttrDescriptorList &adl;
  203.     const AttrDescLinkNode *cur;
  204.  
  205.   public:
  206.     AttrDescItr(const AttrDescriptorList &adList) : adl(adList)
  207.     {
  208.     cur = (AttrDescLinkNode *)( adl.GetHead() );
  209.     }
  210.     ~AttrDescItr() { };
  211.  
  212.     void ResetItr() { cur = (AttrDescLinkNode *)( adl.GetHead() ); }
  213.  
  214.     const AttrDescriptor * NextAttrDesc();
  215. };
  216.  
  217. ///////////////////////////////////////////////////////////////////////////////
  218.  
  219. class InverseAttrDescLinkNode : public  AttrDescLinkNode {
  220.   private:
  221.   protected:
  222.     class InverseAttrDescriptor *_invAttrDesc;
  223.   public:
  224.     InverseAttrDescLinkNode() { _invAttrDesc = 0; }
  225.     virtual ~InverseAttrDescLinkNode() { }
  226.  
  227.     const InverseAttrDescriptor *InverseAttrDesc() const { return _invAttrDesc; }
  228.     void InverseAttrDesc(InverseAttrDescriptor *iad) { _invAttrDesc = iad; }
  229. };
  230.  
  231. class InverseAttrDescriptorList : public  AttrDescriptorList {
  232.   private:
  233.   protected:
  234.   public:
  235.     InverseAttrDescriptorList() { }
  236.     virtual ~InverseAttrDescriptorList() { }
  237.     virtual SingleLinkNode * NewNode () { return new InverseAttrDescLinkNode; }
  238. };
  239.  
  240. class InverseADItr
  241. {
  242.   protected:
  243.     const InverseAttrDescriptorList &iadl;
  244.     const InverseAttrDescLinkNode *cur;
  245.  
  246.   public:
  247.     InverseADItr (const InverseAttrDescriptorList &iadList) : iadl(iadList)
  248.     {
  249.     cur = (InverseAttrDescLinkNode *)( iadl.GetHead() );
  250.     }
  251.     ~InverseADItr() { };
  252.  
  253.     void ResetItr() 
  254.     { cur = (InverseAttrDescLinkNode *)( iadl.GetHead() ); }
  255.  
  256.     const InverseAttrDescriptor * NextInverseAttrDesc();
  257. };
  258.  
  259. ///////////////////////////////////////////////////////////////////////////////
  260.  
  261. class TypeDescLinkNode : public SingleLinkNode {
  262.   private:
  263.   protected:
  264.     TypeDescriptor *_typeDesc;
  265.   public:
  266.     TypeDescLinkNode() { _typeDesc = 0; }
  267.     virtual ~TypeDescLinkNode() { }
  268.  
  269.     const TypeDescriptor *TypeDesc() const { return _typeDesc; }
  270.     void TypeDesc(TypeDescriptor *td) { _typeDesc = td; }
  271. };
  272.  
  273. class TypeDescriptorList : public SingleLinkList {
  274.   private:
  275.   protected:
  276.   public:
  277.     TypeDescriptorList() { }
  278.     virtual ~TypeDescriptorList() { }
  279.  
  280.     virtual SingleLinkNode * NewNode () { return new TypeDescLinkNode; }
  281.  
  282.     TypeDescLinkNode * AddNode (TypeDescriptor * td) {
  283.     TypeDescLinkNode *node = (TypeDescLinkNode *) NewNode();
  284.     node->TypeDesc(td);
  285.     SingleLinkList::AppendNode(node);
  286.     return node;
  287.     }    
  288. };
  289.  
  290. class TypeDescItr
  291. {
  292.   protected:
  293.     const TypeDescriptorList &tdl;
  294.     const TypeDescLinkNode *cur;
  295.  
  296.   public:
  297.     TypeDescItr (const TypeDescriptorList &tdList) : tdl(tdList)
  298.     {
  299.     cur = (TypeDescLinkNode *)( tdl.GetHead() );
  300.     }
  301.     ~TypeDescItr() { };
  302.  
  303.     void ResetItr() { cur = (TypeDescLinkNode *)( tdl.GetHead() ); }
  304.  
  305.     const TypeDescriptor * NextTypeDesc();
  306. };
  307.  
  308. ///////////////////////////////////////////////////////////////////////////////
  309. // AttrDescriptor
  310. // An instance of this class will be generated for each attribute for
  311. // an Entity.  They will be pointed to by the EntityTypeDescriptors.
  312. ///////////////////////////////////////////////////////////////////////////////
  313.  
  314. class AttrDescriptor { 
  315.  
  316.   protected:
  317.     const char *  _name ;    // the attributes name
  318.         // this defines the domain of the attribute
  319.     const TypeDescriptor * _domainType ;
  320.     SdaiLogical _optional;
  321.     SdaiLogical _unique;
  322.     SdaiLogical _derived;
  323.     
  324. #ifdef __O3DB__
  325.     const EntityDescriptor * _owner ;  // the owning entityDescriptor
  326. #else
  327.     const EntityDescriptor & _owner ;  // the owning entityDescriptor
  328. #endif
  329.   public:  
  330.  
  331.     AttrDescriptor(
  332.                const char * name,        // i.e. char *
  333.                const TypeDescriptor *domainType, 
  334.                LOGICAL optional,    // i.e. F U or T
  335.                LOGICAL unique,    // i.e. F U or T
  336.                LOGICAL derived,    // i.e. F U or T
  337.                const EntityDescriptor & owner 
  338.            );
  339.     virtual ~AttrDescriptor ();
  340.  
  341.         // the attribute Express def
  342.     const char *AttrExprDefStr(SCLstring & s) const;
  343.  
  344.         // left side of attr def
  345.     const char * Name()    const       { return _name; }
  346.     void     Name (const char *  n) { _name = n; }
  347.  
  348.        // BaseType() is the underlying type of this attribute. 
  349.        // NonRefType() is the first non REFERENCE_TYPE type
  350.        // e.g. Given attributes of each of the following types 
  351.        // TYPE count = INTEGER;
  352.        // TYPE ref_count = count;
  353.        // TYPE count_set = SET OF ref_count;
  354.        //  BaseType() will return INTEGER_TYPE for an attr of each type.
  355.        //  BaseTypeDescriptor() returns the TypeDescriptor for Integer
  356.        //  NonRefType() will return INTEGER_TYPE for the first two. For an
  357.        //    attribute of type count_set NonRefType() would return 
  358.        //    AGGREGATE_TYPE
  359.        //  NonRefTypeDescriptor() returns the TypeDescriptor for Integer
  360.        //     for the first two and a TypeDescriptor for an
  361.        //     aggregate for the last.
  362.  
  363.     const BASE_TYPE BaseType() const;
  364.     const TypeDescriptor *BaseTypeDescriptor() const;
  365.  
  366.        // the first BASE_TYPE that is not REFERENCE_TYPE (the first 
  367.        // TypeDescriptor *_referentType that does not have REFERENCE_TYPE 
  368.        // for it's fundamentalType variable).  This would return the same 
  369.        // as BaseType() for fundamental types.  An aggregate type
  370.        // would return AGGREGATE_TYPE then you could find out the type of
  371.        // an element by calling AggrElemType().  Select types
  372.        // would work the same?
  373.  
  374.     const BASE_TYPE NonRefType() const;
  375.     const TypeDescriptor *NonRefTypeDescriptor() const;
  376.  
  377.     const BASE_TYPE    AggrElemType() const;
  378.     const TypeDescriptor *AggrElemTypeDescriptor() const;
  379.  
  380.         // The type of the attributes TypeDescriptor
  381.     const BASE_TYPE Type() const;
  382.     const char * TypeName() const;    // right side of attr def
  383.  
  384.             // an expanded right side of attr def
  385.     const char *ExpandedTypeName(SCLstring & s) const;
  386.  
  387.     int RefersToType() const    { return !(_domainType == 0); }
  388.  
  389.     const TypeDescriptor * ReferentType() const { return _domainType; }
  390.     const TypeDescriptor * DomainType() const { return _domainType; }
  391.     void DomainType (const TypeDescriptor *td)  { _domainType = td; }
  392.     void ReferentType(const TypeDescriptor *td) { _domainType = td; }
  393.  
  394.     const SdaiLogical & Optional() const { return _optional; }
  395.     void Optional (SdaiLogical &opt)    { _optional.put(opt.asInt()); }
  396.     void Optional (LOGICAL opt)    { _optional.put(opt); }
  397.     void Optional (const char *opt) { _optional.put(opt); }
  398.  
  399.     const SdaiLogical & Unique() const { return _unique; }
  400.     void Unique (SdaiLogical uniq)    { _unique.put(uniq.asInt()); }
  401.     void Unique (LOGICAL uniq)    { _unique.put(uniq); }
  402.     void Unique (const char *uniq)    { _unique.put(uniq); }
  403.  
  404.     const SdaiLogical & Derived() const { return _derived; }
  405.     void Derived (SdaiLogical x)    { _derived.put(x.asInt()); }
  406.     void Derived (LOGICAL x)    { _derived.put(x); }
  407.     void Derived (const char *x)    { _derived.put(x); }
  408.  
  409.     const SdaiLogical & Optionality() const { return _optional; }
  410.     void Optionality (SdaiLogical &opt)  { _optional.put(opt.asInt()); }
  411.     void Optionality (LOGICAL opt)       { _optional.put(opt); }
  412.     void Optionality (const char *opt) { _optional.put(opt); }
  413.  
  414.     const SdaiLogical & Uniqueness() const    { return _unique; }
  415.     void Uniqueness (SdaiLogical uniq)    { _unique.put(uniq.asInt()); }
  416.     void Uniqueness (LOGICAL uniq)        { _unique.put(uniq); }
  417.     void Uniqueness (const char *uniq)    { _unique.put(uniq); }
  418.  
  419. #ifdef __O3DB__
  420.     const EntityDescriptor  & Owner() const    { return *_owner; }
  421. #else
  422.     const EntityDescriptor  & Owner() const    { return _owner; }
  423. #endif
  424. };
  425.  
  426.  
  427. ///////////////////////////////////////////////////////////////////////////////
  428. // InverseAttrDescriptor
  429. ///////////////////////////////////////////////////////////////////////////////
  430.  
  431. class InverseAttrDescriptor  :    public AttrDescriptor  { 
  432.  
  433.   protected:
  434.     AttrDescriptor * _inverseAttr ;
  435.   public:  
  436.  
  437.     InverseAttrDescriptor(
  438.                const char * name,        // i.e. char *
  439.                TypeDescriptor *domainType, 
  440.                LOGICAL optional,    // i.e. F U or T*/
  441.                LOGICAL unique,    // i.e. F U or T
  442. //               LOGICAL derived,    // derived will always be F 
  443.                const EntityDescriptor & owner, 
  444.                AttrDescriptor *inverseAttr =0
  445.            ) : AttrDescriptor( name, domainType, optional, unique, 
  446.                        F, owner ), _inverseAttr (inverseAttr)
  447.         { }
  448.     virtual ~InverseAttrDescriptor () { }
  449.     
  450.     class AttrDescriptor * InverseAttribute() 
  451.                 { return _inverseAttr; } 
  452.         void InverseOf (AttrDescriptor * invAttr) 
  453.                 { _inverseAttr = invAttr; } 
  454. };
  455.  
  456. ///////////////////////////////////////////////////////////////////////////////
  457. // TypeDescriptor
  458. // This class and the classes inherited from this class are used to describe   
  459. // all types (base types and created types).  There will be an instance of this
  460. // class generated for each type found in the schema.  
  461. // A TypeDescriptor will be generated in three contexts:
  462. // 1) to describe a base type - e.g. INTEGER, REAL, STRING.  There is only one 
  463. //    TypeDescriptor created for each Express base type. Each of these will 
  464. //    be pointed to by several other AttrDescriptors and TypeDescriptors)
  465. // 2) to describe a type created by an Express TYPE statement.
  466. //    e.g. TYPE label = STRING END_TYPE;
  467. //    These TypeDescriptors will be pointed to by other AttrDescriptors (and 
  468. //    TypeDescriptors) representing attributes (and Express TYPEs) that are 
  469. //    of the type created by this Express TYPE.
  470. // 3) to describe a type created in an attribute definition
  471. //    e.g. part_label_grouping : ARRAY [1.10] label;
  472. //    or part_codes : ARRAY [1.10] INTEGER;
  473. //    In this #3 context there will not be a name associated with the type.
  474. //    The TypeDescriptor created in this case will only be pointed to by the
  475. //    single AttrDescriptor associated with the attribute it was created for.
  476. ///////////////////////////////////////////////////////////////////////////////
  477.  
  478. class TypeDescriptor { 
  479.  
  480.   protected:
  481.     // The name of the type. 
  482.     // In the case of the TypeDescriptors representing the Express base
  483.     // types this will be the name of the base type.
  484.     // In the case where this TypeDescriptor is representing an Express
  485.     // TYPE it is the LEFT side of an Express TYPE statement (i.e. label 
  486.     // as in TYPE label = STRING END_TYPE;) This name would in turn be 
  487.     // found on the RIGHT side of an Express attribute definition (e.g. 
  488.     // attr defined as part_label : label; )
  489.     // In the case where this TypeDescriptor was generated to describe a
  490.     // type created in an attr definition, it will be a null pointer (e.g
  491.     // attr defined as part_label_grouping : ARRAY [1..10] label)
  492.  
  493.     const char *  _name ;
  494.  
  495.     // this is the 'type' of the type being represented by the
  496.     // TypeDescriptor . i.e. the following 2 stmts
  497.     // would cause 2 TypeDescriptors to be generated both having
  498.     // _fundamentalType set to REFERENCE_TYPE 
  499.     // TYPE label = STRING END_TYPE; 
  500.     // TYPE part_label = label END_TYPE;
  501.     // part_label and label would be the value of the respective
  502.     // _name member variables for the 2 TypeDescriptors. Having a 
  503.     // _fundamentalType of REFERENCE_TYPE means that the _referentType
  504.     // member variable will point to another TypeDescriptor furthur 
  505.     // describing the type. (It also means that this TypeDescriptor 
  506.     // represents the type defined in an Express TYPE statement.)
  507.     // A TypeDescriptor would be generated for each of the EXPRESS base 
  508.     // types (int, string, real, etc) having _fundamentalType member 
  509.     // variables set to match the EXPRESS base type being represented.
  510.  
  511.     BASE_TYPE _fundamentalType ;
  512.  
  513.     // For the TypeDescriptors describing the EXPRESS base types this will
  514.     // be a null pointer.  For all other TypeDescriptors this will point 
  515.     // to another TypeDescriptor which furthur describes the type. e.g.
  516.     // TYPE part_label = label END_TYPE; TYPE label = STRING END_TYPE; 
  517.     // part_label's _referentType will point to the TypeDescriptor for
  518.     // label.  label's _referentType will point to the TypeDescriptor
  519.     // for STRING. Both TypeDescriptors _fundamentalType will be
  520.     // REFERENCE_TYPE.  The _fundamentalType for EXPRESS base type STRING's
  521.     // TypeDescriptor will be STRING_TYPE.
  522.     // If the _fundamentalType is ENTITY_TYPE or SELECT_TYPE the 
  523.     // TypeDescriptor pointed to will be a subtype of TypeDescriptor
  524.     // (e.g. EntityDescriptor and SelectTypeDescriptor) Others will
  525.     // be added to this list in the future.
  526.  
  527.     const TypeDescriptor * _referentType ;
  528.  
  529.     // This is the string description of the type as found in the
  530.     // EXPRESS file. e.g. aggr of [aggr of ...] [list of ...] someType 
  531.     // It is the RIGHT side of an Express TYPE statement 
  532.     // (i.e. LIST OF STRING as in 
  533.     // TYPE label_group = LIST OF STRING END_TYPE;) 
  534.     // It is the same as _name for EXPRESS base types TypeDescriptors (with
  535.     // the possible exception of upper or lower case differences).
  536.  
  537.     const char *  _description ;
  538.  
  539.   public:  
  540.  
  541.     TypeDescriptor (const char * nm, BASE_TYPE ft, const char * d ); 
  542.     TypeDescriptor ( ); 
  543.     virtual ~TypeDescriptor () { }
  544.  
  545.  
  546.         // the name of this type
  547.     const char * Name() const   { return _name; }
  548.  
  549.         // The name that would be found on the right side of an 
  550.         // attribute definition. In the case of a type defined like
  551.         // TYPE name = STRING END_TYPE; 
  552.         // with attribute definition   employee_name : name;
  553.         // it would be the _name member variable. If it was a type
  554.         // defined in an attribute it will be the _description
  555.         // member variable since _name will be null. e.g. attr. def.
  556.         // project_names : ARRAY [1..10] name;
  557.     const char * AttrTypeName() const {
  558.         return _name ? _name : _description;
  559.     }        
  560.  
  561.         // This is a fully expanded description of the type.
  562.         // This returns a string like the _description member variable
  563.         // except it is more thorough of a description where possible
  564.         // e.g. if the description contains a TYPE name it will also
  565.         // be explained.
  566.     const char *TypeString(SCLstring & s) const;
  567.  
  568.         // This TypeDescriptor's type
  569.     const BASE_TYPE Type() const    { return _fundamentalType; }
  570.     void  Type(const BASE_TYPE type)     { _fundamentalType = type; }
  571.  
  572.        // This is the underlying Express base type of this type. It will 
  573.        // be the type of the last TypeDescriptor following the 
  574.        // _referentType member variable pointers. e.g.
  575.        // TYPE count = INTEGER;
  576.        // TYPE ref_count = count;
  577.        // TYPE count_set = SET OF ref_count;
  578.        //  each of the above will generate a TypeDescriptor and for 
  579.        //  each one, BASE_TYPE BaseType() will return INTEGER_TYPE.
  580.        //  TypeDescriptor *BaseTypeDescriptor() returns the TypeDescriptor 
  581.        //  for Integer.
  582.     const BASE_TYPE       BaseType() const;
  583.     const TypeDescriptor *BaseTypeDescriptor() const;
  584.     const char * BaseTypeName () const;
  585.  
  586.        // the first BASE_TYPE that is not REFERENCE_TYPE (the first 
  587.        // TypeDescriptor *_referentType that does not have REFERENCE_TYPE 
  588.        // for it's fundamentalType variable).  This would return the same 
  589.        // as BaseType() for fundamental types.  An aggregate type
  590.        // would return AGGREGATE_TYPE then you could find out the type of
  591.        // an element by calling AggrElemType().  Select types
  592.        // would work the same?
  593.  
  594.     const BASE_TYPE    NonRefType() const;
  595.     const TypeDescriptor *NonRefTypeDescriptor() const;
  596.  
  597.     const BASE_TYPE    AggrElemType() const;
  598.     const TypeDescriptor *AggrElemTypeDescriptor() const;
  599.  
  600.     const BASE_TYPE FundamentalType() const { return _fundamentalType; }
  601.     void FundamentalType (BASE_TYPE ftype) { _fundamentalType = ftype; }
  602.  
  603.         // The TypeDescriptor for the type this type is based on 
  604.     const TypeDescriptor * ReferentType() const { return _referentType; }
  605.     void ReferentType (const TypeDescriptor * rtype) 
  606.             { _referentType = rtype; }
  607.  
  608.         // A description of this type's type. Basically you
  609.         // get the right side of a TYPE statement minus END_TYPE.
  610.         // For base type TypeDescriptors it is the same as _name.
  611.     const char * Description() const    { return _description; }
  612.     void Description (const char * desc) { _description = desc; } 
  613.  
  614.         virtual const TypeDescriptor * IsA (const TypeDescriptor *) const;
  615.         virtual const TypeDescriptor * BaseTypeIsA (const TypeDescriptor *) const;
  616.         virtual const TypeDescriptor * IsA (const char *) const;
  617.         virtual const TypeDescriptor * CanBe (const TypeDescriptor *n) const
  618.                 {  return TypeDescriptor::IsA (n);  }
  619.  
  620. };
  621.  
  622. class EntityDescriptor  :    public TypeDescriptor  { 
  623.  
  624.   protected:
  625.     const SchemaDescriptor * _originatingSchema;
  626.     SdaiLogical _abstractEntity;
  627.  
  628.     EntityDescriptorList _subtypes;   // OPTIONAL
  629.     EntityDescriptorList _supertypes; // OPTIONAL
  630.  
  631.     AttrDescriptorList      _explicitAttr; // OPTIONAL
  632. //    StringAggregate         * _derivedAttr;  // OPTIONAL  
  633.     InverseAttrDescriptorList _inverseAttr;  // OPTIONAL
  634.  
  635.   public:
  636.        // pointer to a function that will create a new instance of a STEPentity
  637.         Creator NewSTEPentity;
  638.  
  639.     EntityDescriptor ( );
  640.     EntityDescriptor (const char * name, // i.e. char *
  641.               SchemaDescriptor *origSchema, 
  642.               LOGICAL abstractEntity, // i.e. F U or T
  643.               Creator f =0          
  644.               );
  645.  
  646.     virtual ~EntityDescriptor ();
  647.  
  648.     const SchemaDescriptor * OriginatingSchema()  const
  649.             { return _originatingSchema; }
  650.     void OriginatingSchema (const SchemaDescriptor * os)
  651.             { _originatingSchema = os; }
  652.  
  653.     SdaiLogical & AbstractEntity()         { return _abstractEntity; } 
  654.     void AbstractEntity (SdaiLogical &ae)
  655.                        { _abstractEntity.put(ae.asInt()); }
  656.     void AbstractEntity (LOGICAL ae)     { _abstractEntity.put(ae); }
  657.     void AbstractEntity (const char *ae) { _abstractEntity.put(ae); }
  658.  
  659.     const EntityDescriptorList& Subtypes() const
  660.       { return _subtypes; } 
  661.  
  662.     const EntityDescriptorList& Supertypes() const
  663.       { return _supertypes; }
  664.  
  665.     const EntityDescriptorList& GetSupertypes()  const 
  666.       { return _supertypes; }
  667.  
  668.     const AttrDescriptorList& ExplicitAttr() const
  669.       { return _explicitAttr; }
  670.  
  671. //    StringAggregate  & DerivedAttr()    { return *_derivedAttr; }
  672.  
  673.     const InverseAttrDescriptorList& InverseAttr() const { return _inverseAttr; }
  674.  
  675.         virtual const EntityDescriptor * IsA (const EntityDescriptor *) const;
  676.         virtual const TypeDescriptor * IsA (const TypeDescriptor * td) const ;
  677.         virtual const TypeDescriptor * IsA (const char * n) const  
  678.                 {  return TypeDescriptor::IsA (n);  }
  679.         virtual const TypeDescriptor * CanBe (const TypeDescriptor *o) const
  680.                 {  return o -> IsA (this);  }
  681.  
  682.     // The following will be used by schema initialization functions
  683.  
  684.     void AddSubtype(EntityDescriptor *ed) 
  685.         { _subtypes.AddNode(ed); }
  686.  
  687.     void AddSupertype(EntityDescriptor *ed) 
  688.         { _supertypes.AddNode(ed); }
  689.  
  690.     void AddExplicitAttr(AttrDescriptor *ad)
  691.         { _explicitAttr.AddNode(ad); }
  692.  
  693.     void AddInverseAttr(InverseAttrDescriptor *ad)
  694.         { _inverseAttr.AddNode(ad); }
  695. };
  696.  
  697.  
  698. ///////////////////////////////////////////////////////////////////////////////
  699. // EnumerationTypeDescriptor
  700. ///////////////////////////////////////////////////////////////////////////////
  701. #ifdef NOT_YET
  702. class EnumerationTypeDescriptor  :    public TypeDescriptor  { 
  703.  
  704.   protected:
  705.     StringAggregate  *_elements ;      //  of  (null)
  706.  
  707.   public:  
  708.     EnumerationTypeDescriptor ( );
  709.     virtual ~EnumerationTypeDescriptor () { } 
  710.  
  711.  
  712.     StringAggregate & Elements() { return *_elements; }
  713. //    void Elements (StringAggregate  e);
  714. };
  715. #endif
  716. ///////////////////////////////////////////////////////////////////////////////
  717. // AggregateTypeDescriptor
  718. // I think we decided on a simplistic representation of aggr. types for now?
  719. // i.e. just have one AggrTypeDesc for Array of [list of] [set of] someType
  720. // the inherited variable _referentType will point to the TypeDesc for someType
  721. // So I don't believe this class was necessary.  If we were to retain
  722. // info for each of the [aggr of]'s in the example above then there would be
  723. // one of these for each [aggr of] above and they would be strung
  724. // together by the _aggrDomainType variables.  If you can make this
  725. // work then go for it.
  726. ///////////////////////////////////////////////////////////////////////////////
  727.  
  728. class AggregateTypeDescriptor  :    public TypeDescriptor  { 
  729.  
  730.   protected:
  731.     SdaiInteger  _bound1 ;
  732.     SdaiInteger  _bound2 ;
  733.     SdaiLogical _uniqueElements ;
  734.     TypeDescriptor * _aggrDomainType ;
  735.   public:  
  736.  
  737.     AggregateTypeDescriptor ( ); 
  738.     AggregateTypeDescriptor(SdaiInteger b1, SdaiInteger b2, 
  739.                 LOGICAL uniqElem, 
  740.                 TypeDescriptor *aggrDomType);
  741.     virtual ~AggregateTypeDescriptor ();
  742.  
  743.  
  744.     SdaiInteger & Bound1()         { return _bound1; }
  745.     void Bound1 (SdaiInteger  b1)    { _bound1 = b1; } 
  746.  
  747.     SdaiInteger & Bound2()         { return _bound2; }
  748.     void Bound2 (SdaiInteger  b2)    { _bound2 = b2; } 
  749.  
  750.     SdaiLogical& UniqueElements()    { return _uniqueElements; } 
  751.     void UniqueElements (SdaiLogical &ue) 
  752.                     { _uniqueElements.put(ue.asInt()); } 
  753.     void UniquesElements (LOGICAL ue)     { _uniqueElements.put(ue); }
  754.     void UniqueElements (const char *ue) { _uniqueElements.put(ue); }
  755.  
  756.     class TypeDescriptor * AggrDomainType()    { return _aggrDomainType; } 
  757.     void AggrDomainType (TypeDescriptor * adt) { _aggrDomainType = adt; }
  758. };
  759.  
  760. ///////////////////////////////////////////////////////////////////////////////
  761. // ArrayTypeDescriptor
  762. ///////////////////////////////////////////////////////////////////////////////
  763.  
  764. class ArrayTypeDescriptor  :    public AggregateTypeDescriptor  { 
  765.  
  766.   protected:
  767.     SdaiLogical _optionalElements ;
  768.   public:  
  769.  
  770.     ArrayTypeDescriptor ( ) : _optionalElements("UNKNOWN_TYPE") { } 
  771.     ArrayTypeDescriptor (LOGICAL optElem) : _optionalElements(optElem) { } 
  772.     virtual ~ArrayTypeDescriptor () {}
  773.  
  774.  
  775.     SdaiLogical& OptionalElements()       { return _optionalElements; } 
  776.     void OptionalElements (SdaiLogical &oe) 
  777.                      { _optionalElements.put(oe.asInt()); } 
  778.     void OptionalElements (LOGICAL oe)     { _optionalElements.put(oe); }
  779.     void OptionalElements (const char *oe) { _optionalElements.put(oe); }
  780. };
  781.  
  782. class SetTypeDescriptor  :    public AggregateTypeDescriptor  { 
  783.  
  784.   protected:
  785.   public:  
  786.  
  787.     SetTypeDescriptor ( ) { } 
  788.     virtual ~SetTypeDescriptor () { }
  789.  
  790. };
  791.  
  792. class ListTypeDescriptor  :    public AggregateTypeDescriptor  { 
  793.  
  794.   protected:
  795.   public:  
  796.  
  797.     ListTypeDescriptor ( ) { }
  798.     virtual ~ListTypeDescriptor () { }
  799.  
  800. };
  801.  
  802. class SelectTypeDescriptor  :    public TypeDescriptor  { 
  803.  
  804.   protected:
  805.     TypeDescriptorList _elements ;      //  of  TYPE_DESCRIPTOR
  806.     int _unique_elements;
  807.  
  808.   public:  
  809.  
  810.         SelectTypeDescriptor (int b, const char * nm, BASE_TYPE ft, char * d ) 
  811.           : TypeDescriptor (nm, ft, d), _unique_elements (b)  { }
  812.     virtual ~SelectTypeDescriptor () { }
  813.  
  814.     TypeDescriptorList& Elements() { return _elements; }
  815.     const TypeDescriptorList& GetElements() const { return _elements; }
  816. //    void Elements (TypeDescriptorList x);
  817.         int UniqueElements () const {  return _unique_elements; }
  818.         virtual const TypeDescriptor * IsA (const TypeDescriptor *) const;
  819.         virtual const TypeDescriptor * IsA (const char * n) const  
  820.                 {  return TypeDescriptor::IsA (n);  }
  821.         virtual const TypeDescriptor * CanBe (const TypeDescriptor *) const;
  822. };
  823.  
  824. class StringTypeDescriptor  :    public TypeDescriptor  { 
  825.  
  826.   protected:
  827.     SdaiInteger  _width ;    //  OPTIONAL
  828.     SdaiLogical _fixedSize ;
  829.   public:  
  830.  
  831.     StringTypeDescriptor ( ) : _fixedSize("UNKNOWN_TYPE") { _width = 0; }
  832.     virtual ~StringTypeDescriptor () { }
  833.  
  834.  
  835.     SdaiInteger Width()        { return _width; }
  836.     void Width (SdaiInteger  w)    { _width = w; }
  837.  
  838.     SdaiLogical& FixedSize()        { return _fixedSize; }
  839.     void FixedSize (SdaiLogical fs)    { _fixedSize.put(fs.asInt()); }
  840.     void FixedSize (LOGICAL fs)    { _fixedSize.put(fs); }
  841.     void FixedSize (char * fs)    { _fixedSize.put(fs); }
  842. };
  843.  
  844. class BagTypeDescriptor  :    public AggregateTypeDescriptor  { 
  845.  
  846.   protected:
  847.   public:  
  848.  
  849.     BagTypeDescriptor ( ) { }
  850.     virtual ~BagTypeDescriptor () { }
  851.  
  852. };
  853.  
  854. class RealTypeDescriptor  :    public TypeDescriptor  { 
  855.  
  856.   protected:
  857.     SdaiInteger  _precisionSpec ;    //  OPTIONAL
  858.   public:  
  859.  
  860.     RealTypeDescriptor ( ) { _precisionSpec = 0; }
  861.     virtual ~RealTypeDescriptor () { }
  862.  
  863.     SdaiInteger PrecisionSpec()        { return _precisionSpec; }
  864.     void PrecisionSpec (SdaiInteger  ps)    { _precisionSpec = ps; }
  865. };
  866.  
  867.  
  868. #endif
  869.