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 / AGGREGAT.H < prev    next >
C/C++ Source or Header  |  1994-08-06  |  18KB  |  605 lines

  1. #ifndef AGGREGATE_H
  2. #define AGGREGATE_H
  3.  
  4. /*
  5. * NIST STEP Core Class Library
  6. * clstepcore/STEPaggregate.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: STEPaggregate.h,v 2.0.1.2 1994/04/05 16:36:11 sauderd Exp $ */
  16.  
  17.  
  18.  
  19. class InstMgr;
  20. class STEPaggregate;
  21. class Logical;
  22. class TypeDescriptor;
  23.  
  24. #include <errordesc.h>
  25. #include <List.h>
  26. #include <sdai.h>
  27. #include <baseType.h>
  28. #include <Binary.h>
  29. #include <undefined.h>
  30. #include <scl_string.h>
  31.  
  32. class STEPentity;
  33. #define     S_ENTITY_NULL    &NilSTEPentity
  34. extern STEPentity NilSTEPentity;
  35.  
  36.  
  37. #define     AGGR_NULL    &NilSTEPaggregate
  38. extern STEPaggregate NilSTEPaggregate;
  39.  
  40. typedef unsigned short BOOLEAN;
  41. class SingleLinkNode;
  42.  
  43. #define  Node     SingleLinkNode;
  44.  
  45. /******************************************************************************
  46.  **
  47.  *****************************************************************************/
  48.  
  49. typedef STEPaggregate * STEPaggregateH;
  50. class STEPaggregate :  public SingleLinkList 
  51. {
  52.   protected:
  53.     int _null;
  54.  
  55.   protected:
  56.  
  57.     virtual Severity ReadValue(istream &in, ErrorDescriptor *err, 
  58.                    const TypeDescriptor *elem_type, 
  59.                    InstMgr *insts, int addFileId =0, 
  60.                    int assignVal =1, int ExchangeFileFormat =1);
  61.   public:
  62.  
  63.     int is_null() { return _null; } 
  64.  
  65.     virtual Severity AggrValidLevel(const char *value, ErrorDescriptor *err, 
  66.                 const TypeDescriptor *elem_type, InstMgr *insts, 
  67.                 int optional, char *tokenList, int addFileId =0, 
  68.                 int clearError =0);
  69.     
  70.  
  71.     virtual Severity AggrValidLevel(istream &in, ErrorDescriptor *err, 
  72.                 const TypeDescriptor *elem_type, InstMgr *insts, 
  73.                 int optional, char *tokenList, int addFileId =0, 
  74.                 int clearError =0);
  75.  
  76. // INPUT
  77.     virtual Severity StrToVal(const char *s, ErrorDescriptor *err =0, 
  78.                   const TypeDescriptor *elem_type =0,
  79.                   InstMgr *insts =0, int addFileId = 0);
  80.     virtual Severity STEPread (istream& in, ErrorDescriptor *err, 
  81.                    const TypeDescriptor *elem_type =0,
  82.                    InstMgr *insts =0, int addFileId =0);
  83. // OUTPUT
  84.     virtual const char *asStr(SCLstring & s) const;
  85.     virtual void STEPwrite  (ostream& out =cout) const;
  86.  
  87. //    SingleLinkNode * GetHead () const
  88. //    { return (STEPnode *) SingleLinkList::GetHead(); }
  89.  
  90.     virtual SingleLinkNode * NewNode ();  
  91.     void AddNode (SingleLinkNode *);
  92.     void Empty ();
  93.     
  94.     STEPaggregate ();
  95.     virtual ~STEPaggregate ();
  96.  
  97. // COPY - defined in subtypes
  98.     virtual STEPaggregate& ShallowCopy (const STEPaggregate&);
  99.  
  100. };                                          
  101.  
  102. /******************************************************************
  103.  ** Class:  GenericAggregate
  104.  ** Description:  This class supports LIST OF: 
  105.  **    SELECT_TYPE, BINARY_TYPE, GENERIC_TYPE, ENUM_TYPE, UNKNOWN_TYPE type
  106.  ******************************************************************/
  107.  
  108. class GenericAggregate  :  public STEPaggregate 
  109. {
  110.   public:
  111.     virtual SingleLinkNode *NewNode();
  112.     virtual STEPaggregate& ShallowCopy (const STEPaggregate&);
  113.  
  114.     GenericAggregate  () {     }
  115.     virtual ~GenericAggregate () {     }
  116. };
  117. typedef  GenericAggregate * GenericAggregateH;
  118.  
  119. /******************************************************************************
  120.  **
  121.  *****************************************************************************/
  122.  
  123. class EntityAggregate  :  public  STEPaggregate 
  124. {
  125.   public:
  126.     virtual Severity ReadValue(istream &in, ErrorDescriptor *err, 
  127.                    const TypeDescriptor *elem_type, 
  128.                    InstMgr *insts, int addFileId =0, 
  129.                    int assignVal =1, int ExchangeFileFormat =1);
  130.  
  131.     virtual  SingleLinkNode *NewNode();
  132.     virtual  STEPaggregate&  ShallowCopy (const STEPaggregate&);
  133.  
  134.     EntityAggregate ();
  135.     virtual ~EntityAggregate ();
  136. };
  137. typedef   EntityAggregate * EntityAggregateH;
  138.  
  139. /******************************************************************
  140.  ** Class:  SelectAggregate
  141.  ** Description:  this is a minimal representions for a collection of 
  142.  **    STEPenumerations
  143.  ******************************************************************/
  144. class SelectAggregate  :  public STEPaggregate 
  145. {
  146.   public:
  147.     virtual Severity ReadValue(istream &in, ErrorDescriptor *err, 
  148.                    const TypeDescriptor *elem_type, 
  149.                    InstMgr *insts, int addFileId =0, 
  150.                    int assignVal =1, int ExchangeFileFormat =1);
  151.  
  152.     virtual SingleLinkNode *NewNode ();
  153.     virtual STEPaggregate& ShallowCopy  (const STEPaggregate&);
  154.  
  155.     SelectAggregate ();
  156.     virtual ~SelectAggregate ();
  157. };
  158. typedef  SelectAggregate *  SelectAggregateH;
  159.  
  160. /******************************************************************
  161.  ** Class:  StringAggregate
  162.  ** Description:  This class supports LIST OF STRING type
  163.  ******************************************************************/
  164. class StringAggregate  :  public STEPaggregate 
  165. {
  166.   public:
  167.     virtual SingleLinkNode *NewNode();
  168.     virtual STEPaggregate& ShallowCopy (const STEPaggregate&);
  169.  
  170.     StringAggregate  () {     }
  171.     virtual ~StringAggregate () {     }
  172. };
  173. typedef  StringAggregate * StringAggregateH;
  174.  
  175.  
  176. /******************************************************************
  177.  ** Class:  BinaryAggregate
  178.  ** Description:  This class supports LIST OF BINARY type
  179.  ******************************************************************/
  180. class BinaryAggregate  :  public STEPaggregate 
  181. {
  182.   public:
  183.     virtual SingleLinkNode *NewNode();
  184.     virtual STEPaggregate& ShallowCopy (const STEPaggregate&);
  185.  
  186.     BinaryAggregate  () {     }
  187.     virtual ~BinaryAggregate () {     }
  188. };
  189. typedef  BinaryAggregate * BinaryAggregateH;
  190.  
  191. /******************************************************************
  192.  ** Class:  EnumAggregate
  193.  ** Description:  this is a minimal representions for a collection of 
  194.  **    STEPenumerations
  195.  ******************************************************************/
  196. class EnumAggregate  :  public STEPaggregate 
  197. {
  198.   public:
  199.     virtual SingleLinkNode *NewNode ();
  200.     virtual STEPaggregate& ShallowCopy  (const STEPaggregate&);
  201.  
  202.     EnumAggregate ();
  203.   virtual ~EnumAggregate ();
  204. };
  205. typedef  EnumAggregate *  EnumAggregateH;
  206.  
  207. class Logicals  : public EnumAggregate  
  208. {
  209.   public:
  210.     virtual SingleLinkNode * NewNode ();  
  211.  
  212.     Logicals  () { }
  213.     virtual ~Logicals () { }
  214. };
  215. typedef  Logicals *  LogicalsH;
  216.  
  217. class RealAggregate  : public STEPaggregate  {
  218.  
  219.   public:
  220.     virtual SingleLinkNode *NewNode();
  221.     virtual STEPaggregate& ShallowCopy  (const STEPaggregate&);
  222.  
  223.     RealAggregate  () {     }
  224.     virtual ~RealAggregate () {     }
  225. };
  226. typedef  RealAggregate *  RealAggregateH;
  227.  
  228. class IntAggregate  : public STEPaggregate  {
  229.  
  230.   public:
  231.     virtual SingleLinkNode *NewNode();
  232.     virtual STEPaggregate& ShallowCopy  (const STEPaggregate&);
  233.  
  234.     IntAggregate  () {     }
  235.     virtual ~IntAggregate () {     }
  236. };
  237. typedef  IntAggregate *  IntAggregateH;
  238.  
  239. ///////////////////////////////////////////////////////////////////////////////
  240.  
  241. ///////////////////////////////////////////////////////////////////////////////
  242.  
  243. ///////////////////////////////////////////////////////////////////////////////
  244.  
  245. class STEPnode :  public SingleLinkNode  {
  246.   protected:
  247.     int _null;
  248.  
  249.   public:
  250.     int is_null() { return _null; } 
  251.     void set_null() { _null = 1; } 
  252.  
  253. //    INPUT
  254.     virtual Severity StrToVal(const char *s, ErrorDescriptor *err);
  255.     virtual Severity StrToVal(istream &in, ErrorDescriptor *err);
  256.  
  257.     virtual Severity STEPread(const char *s, ErrorDescriptor *err);
  258.     virtual Severity STEPread(istream &in, ErrorDescriptor *err);
  259.  
  260. //    OUTPUT
  261.     virtual const char *asStr(SCLstring & s);
  262.     virtual const char *STEPwrite(SCLstring &s);
  263.     virtual void STEPwrite (ostream& out =cout);
  264. };
  265. typedef  STEPnode *  STEPnodeH;
  266.  
  267. /******************************************************************
  268.  ** Class:  GenericNode
  269.  ** Description:  This class is for the Nodes of GenericAggregates
  270.  ******************************************************************/
  271.  
  272. class GenericAggrNode  : public STEPnode {
  273.   public:
  274.  
  275.     SCLundefined value;
  276.  
  277.   public:
  278. //    INPUT
  279.     virtual Severity StrToVal(const char *s, ErrorDescriptor *err);
  280.     virtual Severity StrToVal(istream &in, ErrorDescriptor *err);
  281.  
  282.     virtual Severity STEPread(const char *s, ErrorDescriptor *err);
  283.     virtual Severity STEPread(istream &in, ErrorDescriptor *err);
  284.  
  285. //    OUTPUT
  286.     virtual const char *asStr(SCLstring & s);
  287.     virtual const char *STEPwrite(SCLstring &s);
  288.     virtual void     STEPwrite (ostream& out =cout);
  289.  
  290. //    CONSTRUCTORS
  291.     GenericAggrNode (const char *str);
  292.     GenericAggrNode (GenericAggrNode& gan);
  293.     GenericAggrNode ();
  294.     ~GenericAggrNode ();
  295.  
  296.     virtual SingleLinkNode *    NewNode ();
  297.  
  298. };
  299.  
  300. /////////////////////////////////////////////////////////////////////////////
  301.  
  302. class EntityNode  : public STEPnode {
  303.   public:
  304.     STEPentity * node;
  305.  
  306. // INPUT
  307.     virtual Severity StrToVal(const char *s, ErrorDescriptor *err, 
  308.                   const TypeDescriptor *elem_type,
  309.                   InstMgr *insts, int addFileId = 0);
  310.     virtual Severity StrToVal(istream &in, ErrorDescriptor *err, 
  311.                   const TypeDescriptor *elem_type,
  312.                   InstMgr *insts, int addFileId = 0);
  313.  
  314.     virtual Severity STEPread(const char *s, ErrorDescriptor *err, 
  315.                   const TypeDescriptor *elem_type,
  316.                   InstMgr *insts, int addFileId = 0);
  317.     virtual Severity STEPread(istream &in, ErrorDescriptor *err, 
  318.                   const TypeDescriptor *elem_type,
  319.                   InstMgr *insts, int addFileId = 0);
  320. //    OUTPUT
  321.     virtual const char *asStr(SCLstring & s);
  322.     virtual const char *STEPwrite (SCLstring &s);
  323.     virtual void     STEPwrite (ostream& out =cout);
  324.  
  325. //    CONSTRUCTORS
  326.     EntityNode (STEPentity * e);
  327.     EntityNode ()  {    }
  328.     ~EntityNode ()  {    }
  329.  
  330.     virtual SingleLinkNode *    NewNode ();
  331.  
  332.     // Calling these funtions is an error.
  333.     Severity StrToVal(const char *s, ErrorDescriptor *err)
  334.     {
  335.     cerr << "Internal error:  " << __FILE__ <<  __LINE__
  336.         << "\n" << _POC_ "\n";
  337.     return StrToVal(s, err, 0, 0, 0);
  338.     }
  339.     Severity StrToVal(istream &in, ErrorDescriptor *err)
  340.     {
  341.     cerr << "Internal error:  " << __FILE__ <<  __LINE__
  342.         << "\n" << _POC_ "\n";
  343.     return StrToVal(in, err, 0, 0, 0);
  344.     }
  345.  
  346.     Severity STEPread(const char *s, ErrorDescriptor *err)
  347.     {
  348.     cerr << "Internal error:  " << __FILE__ <<  __LINE__
  349.         << "\n" << _POC_ "\n";
  350.     return STEPread(s, err, 0, 0, 0);
  351.     }
  352.     Severity STEPread(istream &in, ErrorDescriptor *err)
  353.     {
  354.     cerr << "Internal error:  " << __FILE__ <<  __LINE__
  355.         << "\n" << _POC_ "\n";
  356.     return STEPread(in, err, 0, 0, 0);
  357.     }
  358. };
  359.  
  360. ///////////////////////////////////////////////////////////////////////////
  361.  
  362. /******************************************************************
  363.  ** Class:  SelectNode
  364.  ** Description:  this is a minimal representions for node in lists of
  365.  **    STEPenumerations
  366.  ******************************************************************/
  367.  
  368. class SelectNode  : public STEPnode {
  369.   public:
  370.  
  371.     SdaiSelect * node;
  372.  
  373.   public:
  374. //    INPUT
  375.     virtual Severity StrToVal(const char *s, ErrorDescriptor *err, 
  376.                   const TypeDescriptor *elem_type,
  377.                   InstMgr *insts, int addFileId = 0);
  378.     virtual Severity StrToVal(istream &in, ErrorDescriptor *err, 
  379.                   const TypeDescriptor *elem_type,
  380.                   InstMgr *insts, int addFileId = 0);
  381.  
  382.     virtual Severity STEPread(const char *s, ErrorDescriptor *err, 
  383.                   const TypeDescriptor *elem_type,
  384.                   InstMgr *insts, int addFileId = 0);
  385.     virtual Severity STEPread(istream &in, ErrorDescriptor *err, 
  386.                   const TypeDescriptor *elem_type,
  387.                   InstMgr *insts, int addFileId = 0);
  388. //    OUTPUT
  389.     virtual const char *asStr(SCLstring & s);
  390.     virtual const char *STEPwrite (SCLstring &s);
  391.     virtual void     STEPwrite (ostream& out =cout);
  392.  
  393. //    CONSTRUCTORS
  394.     SelectNode (SdaiSelect * s) :  node (s) {    }
  395.     SelectNode ()  {    }
  396.     ~SelectNode ()  {    }
  397.  
  398.     virtual SingleLinkNode *    NewNode ();
  399.  
  400.     // Calling these funtions is an error.
  401.     Severity StrToVal(const char *s, ErrorDescriptor *err)
  402.     {
  403.     cerr << "Internal error:  " << __FILE__ <<  __LINE__
  404.         << "\n" << _POC_ "\n";
  405.     return StrToVal(s, err, 0, 0, 0);
  406.     }
  407.     Severity StrToVal(istream &in, ErrorDescriptor *err)
  408.     {
  409.     cerr << "Internal error:  " << __FILE__ <<  __LINE__
  410.         << "\n" << _POC_ "\n";
  411.     return StrToVal(in, err, 0, 0, 0);
  412.     }
  413.  
  414.     Severity STEPread(const char *s, ErrorDescriptor *err)
  415.     {
  416.     cerr << "Internal error:  " << __FILE__ <<  __LINE__
  417.         << "\n" << _POC_ "\n";
  418.     return STEPread(s, err, 0, 0, 0);
  419.     }
  420.     Severity STEPread(istream &in, ErrorDescriptor *err)
  421.     {
  422.     cerr << "Internal error:  " << __FILE__ <<  __LINE__
  423.         << "\n" << _POC_ "\n";
  424.     return STEPread(in, err, 0, 0, 0);
  425.     }
  426. };
  427.  
  428. ///////////////////////////////////////////////////////////////////////////
  429.  
  430. /******************************************************************
  431.  ** Class:  StringNode
  432.  ** Description:  This class is for the Nodes of StringAggregates
  433.  ******************************************************************/
  434.  
  435. class StringNode  : public STEPnode {
  436.   public:
  437.  
  438.     SdaiString value;
  439.  
  440.   public:
  441. //    INPUT
  442.     virtual Severity StrToVal(const char *s, ErrorDescriptor *err);
  443.     virtual Severity StrToVal(istream &in, ErrorDescriptor *err);
  444.  
  445.     virtual Severity STEPread(const char *s, ErrorDescriptor *err);
  446.     virtual Severity STEPread(istream &in, ErrorDescriptor *err);
  447.  
  448. //    OUTPUT
  449.     virtual const char *asStr(SCLstring & s);
  450.     virtual const char *STEPwrite (SCLstring &s);
  451.     virtual void     STEPwrite (ostream& out =cout);
  452.  
  453. //    CONSTRUCTORS
  454.     StringNode(StringNode& sn);
  455.     StringNode (const char * sStr);
  456.     StringNode ()   { value = 0; }
  457.     ~StringNode ()  { }
  458.  
  459.     virtual SingleLinkNode *    NewNode ();
  460. };
  461.  
  462. ///////////////////////////////////////////////////////////////////////////
  463.  
  464. /******************************************************************
  465.  ** Class:  BinaryNode
  466.  ** Description:  This class is for the Nodes of BinaryAggregates
  467.  ******************************************************************/
  468.  
  469. class BinaryNode  : public STEPnode {
  470.   public:
  471.  
  472.     SdaiBinary value;
  473.  
  474.   public:
  475. //    INPUT
  476.     virtual Severity StrToVal(const char *s, ErrorDescriptor *err);
  477.     virtual Severity StrToVal(istream &in, ErrorDescriptor *err);
  478.  
  479.     virtual Severity STEPread(const char *s, ErrorDescriptor *err);
  480.     virtual Severity STEPread(istream &in, ErrorDescriptor *err);
  481.  
  482. //    OUTPUT
  483.     virtual const char *asStr(SCLstring & s);
  484.     virtual const char *STEPwrite (SCLstring &s);
  485.     virtual void     STEPwrite (ostream& out =cout);
  486.  
  487. //    CONSTRUCTORS
  488.     BinaryNode(BinaryNode& bn);
  489.     BinaryNode (const char * sStr);
  490.     BinaryNode ()   { value = 0; }
  491.     ~BinaryNode ()  { }
  492.  
  493.     virtual SingleLinkNode *    NewNode ();
  494. };
  495.  
  496. /******************************************************************
  497.  ** Class:  EnumNode
  498.  ** Description:  this is a minimal representions for node in lists of
  499.  **    STEPenumerations
  500.  ******************************************************************/
  501.  
  502. class EnumNode  : public STEPnode {
  503.   public:
  504.  
  505.     STEPenumeration * node;
  506.  
  507.   public:
  508. //    INPUT
  509.     virtual Severity StrToVal(const char *s, ErrorDescriptor *err);
  510.     virtual Severity StrToVal(istream &in, ErrorDescriptor *err);
  511.  
  512.     virtual Severity STEPread(const char *s, ErrorDescriptor *err);
  513.     virtual Severity STEPread(istream &in, ErrorDescriptor *err);
  514.  
  515. //    OUTPUT
  516.     virtual const char *asStr(SCLstring & s);
  517.     virtual const char *STEPwrite (SCLstring &s);
  518.     virtual void     STEPwrite (ostream& out =cout);
  519.  
  520. //    CONSTRUCTORS
  521.     EnumNode (STEPenumeration * e) :  node (e) {    }
  522.     EnumNode ()  {    }
  523.     ~EnumNode ()  {    }
  524.  
  525.     virtual SingleLinkNode *    NewNode ();
  526. };
  527.  
  528. class RealNode  : public STEPnode {
  529.   public:
  530.     SdaiReal value; // double
  531.  
  532.   public:
  533. //    INPUT
  534.     virtual Severity StrToVal(const char *s, ErrorDescriptor *err);
  535.     virtual Severity StrToVal(istream &in, ErrorDescriptor *err);
  536.  
  537.     virtual Severity STEPread(const char *s, ErrorDescriptor *err);
  538.     virtual Severity STEPread(istream &in, ErrorDescriptor *err);
  539.  
  540. //    OUTPUT
  541.     virtual const char *asStr(SCLstring & s);
  542.     virtual const char *STEPwrite (SCLstring &s);
  543.     virtual void     STEPwrite (ostream& out =cout);
  544.  
  545. //    CONSTRUCTORS
  546.     RealNode ()  { value = S_REAL_NULL; }
  547.     ~RealNode ()  {    }
  548.  
  549.     virtual SingleLinkNode *    NewNode ();
  550. };
  551.  
  552. class IntNode  : public STEPnode {
  553.   public:
  554.     SdaiInteger value; // long int
  555.  
  556.   public:
  557. //    INPUT
  558.     virtual Severity StrToVal(const char *s, ErrorDescriptor *err);
  559.     virtual Severity StrToVal(istream &in, ErrorDescriptor *err);
  560.  
  561.     virtual Severity STEPread(const char *s, ErrorDescriptor *err);
  562.     virtual Severity STEPread(istream &in, ErrorDescriptor *err);
  563.  
  564. //    OUTPUT
  565.     virtual const char *asStr(SCLstring & s);
  566.     virtual const char *STEPwrite (SCLstring &s);
  567.     virtual void     STEPwrite (ostream& out =cout);
  568.  
  569. //    CONSTRUCTORS
  570.     IntNode ()  { value = S_INT_NULL; }
  571.     ~IntNode ()  {    }
  572.  
  573.     virtual SingleLinkNode *    NewNode ();
  574. };
  575.  
  576. /******************************************************************
  577.  **    The following classes are currently stubs
  578.  **                            
  579. **/
  580.  
  581. class Array  :  public STEPaggregate  {    
  582.   public:                                      
  583.     int lowerBound;                                  
  584.     int upperBound;                                  
  585. };
  586.                                           
  587. class Bag  :  public STEPaggregate  {                                      
  588.   public:                                      
  589.     int min_ele;                                  
  590.     int max_ele;                                  
  591. };
  592.                                           
  593. class List :  public STEPaggregate  {                                      
  594.     int min_ele;                                  
  595.     int max_ele;                                  
  596.     List *prev;                                      
  597. };
  598.                                           
  599. class Set :                                      
  600. public STEPaggregate  {                                      
  601.     int cnt;                                      
  602. };
  603.  
  604. #endif 
  605.