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 / ENUMERAT.H < prev    next >
C/C++ Source or Header  |  1994-08-06  |  3KB  |  130 lines

  1. #ifndef ENUMERATION_H
  2. #define    ENUMERATION_H 
  3.  
  4. /*
  5. * NIST STEP Core Class Library
  6. * clstepcore/Enumeration.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: Enumeration.h,v 2.0.1.6 1994/06/08 19:44:28 ian Exp $ */
  16.  
  17.  
  18. #include <Str.h>
  19. #include <errordesc.h>
  20.  
  21. #define ENUM_NULL -1
  22.  
  23. class STEPenumeration  {
  24.     friend     ostream &operator<< ( ostream&, const STEPenumeration& );
  25.   protected:
  26.     int v;    //  integer value of enumeration instance 
  27.     //  mapped to a symbolic value in the elements
  28.  
  29.     int set_value (const char * n);
  30.     int set_value (const int n);
  31.     virtual ~STEPenumeration ()  {
  32.     }
  33.  
  34.   public:
  35.     
  36.     inline virtual int no_elements () const =0;
  37.     virtual const char * Name () const =0;
  38.     const char * get_value_at (int n) const { return element_at (n);  }
  39.     virtual const char * element_at (int n) const =0; 
  40.  
  41.     Severity EnumValidLevel(const char *value, ErrorDescriptor *err,
  42.                 int optional, char *tokenList,
  43.                 int needDelims = 0, int clearError = 1);
  44.  
  45.     Severity EnumValidLevel(istream &in, ErrorDescriptor *err, 
  46.                 int optional, char *tokenList,
  47.                 int needDelims = 0, int clearError = 1);
  48.  
  49.     const int asInt () const {    return v;    }
  50.     
  51.     const char * asStr (SCLstring &s) const;
  52.     void STEPwrite (ostream& out = cout)  const;
  53.     const char * STEPwrite (SCLstring &s) const;
  54.  
  55.     Severity StrToVal (const char * s, ErrorDescriptor *err, int optional = 1);
  56.     Severity STEPread(istream& in, ErrorDescriptor *err, int optional = 1);
  57.     Severity STEPread(const char *s, ErrorDescriptor *err, int optional = 1);
  58.  
  59.     int put (int val)  {  return set_value (val);    }
  60.     int put (const char * n)    { return set_value (n); }
  61.     int is_null () const    { return ( v == ENUM_NULL ); }
  62.     int set_null()        { return  put (ENUM_NULL); }
  63.     STEPenumeration& operator= (const int);
  64.     STEPenumeration& operator= (const STEPenumeration&);
  65.         
  66.     void DebugDisplay (ostream& out =cout) const;
  67.   protected:
  68.     Severity ReadEnum(istream& in, ErrorDescriptor *err, int AssignVal = 1,
  69.               int needDelims = 1);
  70. };
  71.  
  72.  
  73. enum LOGICAL { sdaiUNKNOWN, sdaiFALSE, sdaiTRUE };
  74.  
  75. #define F sdaiFALSE
  76. #define U sdaiUNKNOWN
  77. #define T sdaiTRUE
  78.  
  79. class Logical  :
  80. public STEPenumeration  {
  81.   public:
  82.     const char * Name () const  {
  83.     return "Logical";
  84.     }
  85.  
  86.     Logical (char * val =0)  {
  87.     set_value (val);
  88.     }
  89.     Logical (LOGICAL val)   {
  90.     set_value (val);
  91.     }
  92.     virtual ~Logical ()  {  
  93.     }
  94.     inline virtual int no_elements () const {
  95.     return 3;
  96.     }
  97.   operator LOGICAL () const;
  98.  
  99.   virtual const char * element_at (int n) const;
  100.  
  101. }
  102. ;
  103.  
  104. class Boolean  :
  105. public STEPenumeration  {
  106.   public:
  107.     const char * Name () const  {
  108.     return "Boolean";
  109.     }
  110.  
  111.     Boolean (char * val =0)  {
  112.     set_value (val);
  113.     }
  114.     Boolean (LOGICAL val);
  115.     virtual ~Boolean ()  {  
  116.     }
  117.     inline virtual int no_elements () const {
  118.     return 2;
  119.     }
  120.   operator LOGICAL () const;
  121.   operator int () const;
  122.  
  123.   virtual const char * element_at (int n) const;
  124.  
  125. }
  126. ;
  127.  
  128.  
  129. #endif 
  130.