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 / SFILE.H < prev    next >
C/C++ Source or Header  |  1994-07-26  |  6KB  |  208 lines

  1. #ifndef _SFILE_H
  2. #define    _SFILE_H
  3.  
  4. /*
  5. * NIST STEP Core Class Library
  6. * cleditor/STEPfile.h
  7. * February, 1994
  8. * Peter Carr
  9. * K. C. Morris
  10. * David Sauder
  11.  
  12. * Development of this software was funded by the United States Government,
  13. * and is not subject to copyright.
  14. */
  15.  
  16. /* $Id: STEPfile.h,v 2.0.1.1 1994/04/05 16:41:35 sauderd Exp $ */ 
  17.  
  18. #ifdef __O3DB__
  19. #include <OpenOODB.h>
  20. #endif
  21.  
  22. /*#include <math.h>*/
  23. #include <instmgr.h>
  24. #include <Registry.h>
  25. #include <fstream.h>
  26. //#include <dirobj.h>
  27. #include <errordes.h>
  28. #include <time.h>
  29.  
  30. #include <schemahe.h>
  31.  
  32. //error reporting level
  33. #define READ_COMPLETE    10
  34. #define READ_INCOMPLETE  20
  35.  
  36. enum  FileTypeCode {
  37.     TYPE_UNKNOWN    = -2,
  38.     VERSION_OLD        = -1,
  39.     VERSION_UNKNOWN    =  0,
  40.     VERSION_CURRENT    =  1,
  41.     WORKING_SESSION    =  2,
  42.     OLD_WORKING_SESSION =  3
  43.   };
  44.  
  45. class STEPfile
  46. {
  47.   protected:
  48.     //data members
  49.  
  50. #ifdef __O3DB__
  51.     InstMgr *  _instances;
  52.     Registry * _reg;
  53.  
  54.     InstMgr & instances ()  { return *_instances; }
  55.     Registry & reg () { return *_reg; }
  56. #else
  57.     InstMgr&  _instances;
  58.     Registry& _reg;
  59.  
  60.     InstMgr & instances ()  { return _instances; }
  61.     Registry & reg () { return _reg; }
  62. #endif
  63.     int _fileIdIncr;   //Increment value to be added to FileId Numbers on input
  64.  
  65. //header information
  66.     InstMgr*  _headerInstances;
  67.     Registry *_headerRegistry;
  68. //Registry *_headerUserDefined;
  69. //    Registry *_headerRegistryOld;
  70.     
  71.     int _headerId;     //STEPfile_id given to STEPentity from header section
  72.  
  73. //file information
  74.     char* _currentDir;
  75.     char* _fileName;
  76.  
  77. //error information
  78.     ErrorDescriptor _error;
  79.  
  80.     int _errorCount;
  81.     int _warningCount;
  82.     int _maxErrorCount;
  83.  
  84.   protected:
  85.     
  86. //file type information
  87.     FileTypeCode _fileType;
  88.     char ENTITY_NAME_DELIM;
  89.     char* FILE_DELIM;    
  90.     char* END_FILE_DELIM;
  91.     
  92. //public member functions
  93.   public:
  94.  
  95. //public access to member variables
  96. //header information
  97.     InstMgr* HeaderInstances() { return _headerInstances; }
  98.  
  99. //file information
  100.     const char* FileName() const { return _fileName; }
  101.     const char* SetFileName (const char* name = "");
  102.     const char* TruncFileName (const char* name) const;
  103.  
  104. //error information
  105.     ErrorDescriptor& Error() /* const */  { return _error;        }
  106.     int ErrorCount() const  { return _errorCount;   }
  107.     int WarningCount() const { return _warningCount; }
  108.     Severity AppendEntityErrorMsg (ErrorDescriptor *e);    
  109.     
  110. //version information
  111.     FileTypeCode FileType() const   { return _fileType; }
  112.     void FileType (FileTypeCode ft) { _fileType = ft; }    
  113.     int SetFileType (FileTypeCode ft = VERSION_CURRENT);
  114.     
  115. //Reading and Writing 
  116.     Severity ReadExchangeFile (const char* filename =0);
  117.     Severity AppendExchangeFile (const char* filename =0); 
  118.  
  119.     Severity ReadWorkingFile (const char* filename =0);
  120.     Severity AppendWorkingFile (const char* filename =0);
  121.  
  122.     Severity AppendFile (istream* in) ;
  123.  
  124.     Severity WriteExchangeFile (ostream& out, int validate =1);
  125.     Severity WriteExchangeFile (const char* filename =0, int validate =1);
  126.  
  127.     Severity WriteWorkingFile (ostream& out);
  128.     Severity WriteWorkingFile (const char* filename =0);
  129.  
  130.     void Renumber ();
  131.  
  132. //constructors
  133.     STEPfile (Registry& r, InstMgr& i, const char *filename = (const char*)0);
  134.     ~STEPfile();
  135.  
  136.  protected:    
  137. //member functions
  138.     
  139. //called by ReadExchangeFile
  140.     istream* OpenInputFile (const char* filename = "");
  141.     void CloseInputFile(istream* in);
  142.     
  143.     Severity ReadHeader(istream& in);
  144.  
  145.     InstMgr* HeaderConvertToNew(InstMgr& oldinst);
  146.     Severity HeaderVerifyInstances(InstMgr* im);
  147.     void HeaderMergeInstances(InstMgr* im);
  148.     STEPentity* HeaderDefaultFileName();    
  149.     STEPentity* HeaderDefaultFileDescription();    
  150.     STEPentity* HeaderDefaultFileSchema();    
  151.   
  152.     int HeaderId (int increment =1);
  153.     int HeaderId (const char* nm ="\0");
  154.     int HeaderIdOld (const char* nm ="\0");
  155.  
  156.     int ReadData1 (istream& in);
  157.     int ReadWorkingData1 (istream& in);
  158.     int ReadData2 (istream& in);
  159.     int ReadWorkingData2 (istream& in);
  160.     void ReadRestOfFile(istream& in);
  161.  
  162.     STEPentity *  CreateInstance(istream& in);
  163.     STEPentity * ReadInstance (istream& in);
  164.  
  165.   //  reading scopes and subsuper instances is still incomplete
  166.   //  these functions are stubs
  167.     Severity CreateScopeInstances(istream& in, STEPentityH ** scopelist);
  168.     Severity CreateSubSuperInstance(istream& in, int fileid);
  169.     Severity ReadScopeInstances(istream& in);
  170.     Severity ReadSubSuperInstance(istream& in);
  171.  
  172.   //  used for instances that aren\'t valid - reads to next \';\'
  173.     Severity SkipInstance (istream& in, SCLstring & buf); 
  174.  
  175.     int FindDataSection (istream& in);
  176.     int FindHeaderSection (istream& in);
  177.     void ReadComment(istream& in);
  178.     void ReadCommentTail (char c, istream& in);
  179.     void ReadWhiteSpace(istream& in);
  180.     Severity ReadPcd(istream& in);   //print control directive
  181.  
  182. // writing working session files
  183.     void WriteWorkingData(ostream& out);
  184.  
  185. //called by WriteExchangeFile
  186.     ofstream* OpenOutputFile(const char* filename =0);
  187.     void CloseOutputFile(ostream* out);
  188.  
  189.     void WriteHeader (ostream& out);
  190.     void WriteHeaderInstance (STEPentity *obj, ostream& out);
  191.     void WriteHeaderInstanceFileName (ostream& out);
  192.     void WriteHeaderInstanceFileDescription (ostream& out);
  193.     void WriteHeaderInstanceFileSchema (ostream& out);
  194.  
  195.     void WriteData (ostream& out);
  196.     
  197.     int IncrementFileId (int fileid);
  198.     int FileIdIncr() { return _fileIdIncr; }
  199.     void SetFileIdIncrement ();
  200.     void MakeBackupFile();
  201.     const char* GetKeyword(istream& in, const char* delims);
  202.     int ReadTokenSeparator(istream& in);
  203. };
  204.  
  205. //inline functions
  206.  
  207. #endif /* _STEPFILE_H */
  208.