FileObject.hh

Go to the documentation of this file.
00001 #ifndef FILETYPE_HH
00002 #define FILETYPE_HH
00003 
00004 //---------------------------------------------------------------------------
00005 // Copyright (c) 1995-2005 Ohio Board of Regents and the University of
00006 // Cincinnati.  All Rights Reserved.
00007 
00008 // You may modify, distribute, and use the software contained in this package
00009 // under the terms of the "GNU LIBRARY GENERAL PUBLIC LICENSE" version 2,
00010 // June 1991. A copy of this license agreement can be found in the file
00011 // "LGPL", distributed with this archive.
00012 //---------------------------------------------------------------------------
00013 
00014 #include "tyvis/ObjectBase.hh"
00015 #include "tyvis/EnumerationLiteral.hh"
00016 
00017 #include <fstream>
00018 using std::fstream;
00019 using std::ios;
00020 
00021 class AccessObject;
00022 class FileTypeInfo;
00023 class SimulationStream;
00024 
00025 class FileObject : public ObjectBase {
00026 public:
00027   FileObject(const FileTypeInfo &);
00028 
00029   FileObject(const FileObject &);
00030 
00031   FileObject( const FileTypeInfo &,
00032               const string &fileName,
00033               const EnumerationLiteral &openMode );
00034 
00035   FileObject( const FileTypeInfo &,
00036               const Slice &,
00037               const EnumerationLiteral &openMode );
00038   
00039   virtual ~FileObject();
00040 
00041   ObjectBase* getObject() const {
00042     return NULL;
00043   }
00044 
00045   virtual void print(ostream& = cout) const;
00046   
00047   RValue *clone() const;
00048 
00050 
00051   void writeline( LValue &line );
00052   void readline(  AccessObject &);
00053   void readline(  AccessObject &, int &numRead );
00055 
00057 
00058   void open( const string &fileName, const RValue &openMode );
00059   void open( const string &fileName, const RValue &openMode, LValue &status );
00060   void close();
00061   void read( LValue &readInto );
00062   void write( const RValue &value );
00063   UniversalInteger endfile();
00065 
00066   int getHandle() const;
00067   const EnumerationLiteral &getFileOpenKind();
00068   void setFileOpenKind(const EnumerationLiteral &);
00069 
00070   RValue &operator=(const RValue &);
00071   FileObject &operator=(const FileObject &);
00072 
00073   bool operator==( const RValue & ) const;
00074   bool operator!=( const RValue & ) const;
00075   bool operator>( const RValue & ) const;
00076   bool operator>=( const RValue & ) const;
00077   bool operator<( const RValue & ) const;
00078   bool operator<=( const RValue & ) const;
00079 
00080   const RValue &readVal() const;
00081   RValue &readVal();
00082   void updateVal( const RValue &newValue );
00083 
00084   const FileTypeInfo &getFileTypeInfo() const;
00085 
00089   string nextToken();
00090 
00091 private:  
00092   static fstream &openFile( const string &fileName, 
00093                             const RValue &openMode );
00094   
00095   static fstream &openFile( const Slice &fileName, 
00096                             const RValue &openMode );
00097 
00101   static ios::openmode getOpenMode( const RValue &mode );
00102 
00104   fstream *fileHandle;
00105   EnumerationLiteral openKind;
00106 };
00107 
00109 
00117 int
00118 savantfile_open( VHDLKernel *processPtr,
00119                  LValue &fileObject,
00120                  const RValue &openMode );
00121 
00125 int
00126 savantfile_open( VHDLKernel *processPtr,
00127                  LValue &fileOpenStatus,
00128                  LValue &fileObject,
00129                  const RValue &fileName,
00130                  const RValue &openMode );
00131 
00135 int
00136 savantfile_close( VHDLKernel *processPtr, LValue &fileObject );
00137 
00141 int savantread( VHDLKernel *processPtr, LValue &fileObject, LValue &readValue );
00142 
00146 int savantread( VHDLKernel *processPtr, LValue &fileObject, LValue &readValue, LValue &length );
00147 
00151 int savantwrite( VHDLKernel *processPtr, LValue &fileObject, const RValue &toWrite );
00152 
00156 Value savantendfile( VHDLKernel *processPtr, LValue &fileObject );
00158 
00159 #endif

Generated on Fri Mar 31 11:05:08 2006 for Tyvis by  doxygen 1.4.6