00001
00052
00053 #ifndef CLDAQ__TOBJECTFILE_HH
00054 #define CLDAQ__TOBJECTFILE_HH
00055
00056 #include "Tglobals.h"
00057 #include "TFileProperty.hh"
00058
00059
00079 class TObjectFile
00080 {
00081
00082 public:
00083 enum {
00084 ERROR = -1
00085 };
00086
00087 enum {
00088 tSeekBegin = SEEK_SET,
00089 tSeekCurrent = SEEK_CUR,
00090 tSeekEnd = SEEK_END
00091 };
00092
00093 protected:
00094 Tstring theFileName;
00095 Tstring theMode;
00096 TFileStream* theFileStream;
00097 TFileProperty theFileProperty;
00098
00099 public:
00100 TObjectFile( const Tstring& filename, const Tstring& mode );
00101
00102 protected:
00103 virtual ~TObjectFile();
00104
00105 public:
00106 const Tstring& GetFileName() const;
00107 const Tstring& GetMode() const;
00108 TFileStream* GetFileStream() const;
00109 Tvoid SetFileName( const Tstring& filename );
00110 Tvoid SetMode( const Tstring& mode );
00111 const TFileProperty& GetFileProperty() const;
00112
00113 public:
00114
00115 Tvoid SetOffset( Tint offset, Tint whence = tSeekCurrent );
00116 Tint GetOffset();
00117 Tbool IsEnd() const;
00118 Tbool IsError() const;
00119
00120
00122
00123
00125 Tint Size() const;
00126
00128 Tint FindDataRecord( const Tstring& id, Tint offset = 0 ) const;
00129
00131 Tint FindDataRecord( Tint index, Tint offset = 0 ) const;
00132
00134 Tint Find( const Tstring& id, Tint offset = 0 ) const;
00135
00137 Tint Find( Tint index, Tint offset = 0 ) const;
00138
00139 #ifdef __CLDAQ_ROOT_DLL
00140 ClassDef(TObjectFile,0)
00141 #endif
00142
00143 };
00144
00145 inline const Tstring& TObjectFile::GetFileName() const
00146 {
00147 return theFileName;
00148 }
00149
00150 inline const Tstring& TObjectFile::GetMode() const
00151 {
00152 return theMode;
00153 }
00154
00155 inline TFileStream* TObjectFile::GetFileStream() const
00156 {
00157 return theFileStream;
00158 }
00159
00160 inline Tvoid TObjectFile::SetFileName( const Tstring& filename )
00161 {
00162 theFileName = filename;
00163 return;
00164 }
00165
00166 inline Tvoid TObjectFile::SetMode( const Tstring& mode )
00167 {
00168
00169 theMode = mode;
00170 return;
00171 }
00172
00173 inline Tvoid TObjectFile::SetOffset( Tint offset, Tint whence )
00174 {
00175 fseek( theFileStream, (Tlong)offset, whence );
00176 return;
00177 }
00178
00179 inline Tint TObjectFile::GetOffset()
00180 {
00181 return (Tint)( ftell( theFileStream ) );
00182 }
00183
00184 inline const TFileProperty& TObjectFile::GetFileProperty() const
00185 {
00186 return theFileProperty;
00187 }
00188
00189 inline Tbool TObjectFile::IsEnd() const
00190 {
00191 return ( feof( theFileStream ) != 0 );
00192 }
00193
00194 inline Tbool TObjectFile::IsError() const
00195 {
00196 return ( ferror( theFileStream ) != 0 );
00197 }
00198
00199 inline Tint TObjectFile::Find( const Tstring& id, Tint offset ) const
00200 {
00201 return FindDataRecord( id, offset );
00202 }
00203
00204 inline Tint TObjectFile::Find( Tint index, Tint offset ) const
00205 {
00206 return FindDataRecord( index, offset );
00207 }
00208
00209 #endif