frameutils/FrameF.hh

00001 /* -*- mode: c++; c-basic-offset: 4; -*- */
00002 #ifndef FRAMEF_HH
00003 #define FRAMEF_HH
00004 
00005 #include "fferrors.hh"
00006 #include <string>
00007 #include <iostream>
00008 
00017 class FrameF {
00018 public:
00019 
00022     typedef long long int8_t;
00023 
00026     typedef int       int4_t;
00027 
00030     typedef short     int2_t;
00031 
00032 
00033 public:
00036     struct StrHdr {
00039         long  length;
00042         short ID;
00045         int   Instance;
00046     };
00047 
00050     struct StrLink {
00053         int2_t ID;
00056         int4_t Instance;
00057 };
00058 
00059 public:
00064   FrameF(std::istream& in);
00065 
00068   ~FrameF(void);
00069 
00070   //------------------------------------  Accessors
00075   bool   isOK(void) const;
00076 
00081   short  getID(void) const;
00082 
00087   short  getInstance(void) const;
00088 
00094   int    getLength(void) const;
00095 
00100   int    getPatch(void) const;
00101 
00107   int    getStrucHdrLen(void) const;
00108 
00113   int    getVersion(void) const;
00114 
00115   //------------------------------------  Mutators
00119   void   ReadHeader(void) throw (BadFile);
00120 
00124   bool   NxStruct(void) throw (BadFile);
00125 
00130   char   getChar(void) throw (BadFile);
00131 
00137   short  getShort(void) throw (BadFile);
00138 
00144   float  getFloat(void) throw (BadFile);
00145 
00151   int    getInt(void) throw (BadFile);
00152 
00157   void   getLink(StrLink& link) throw(BadFile);
00158 
00164   long   getLong(void) throw (BadFile);
00165 
00171   std::string getString(void) throw (BadFile);
00172 
00178   double getDouble(void) throw (BadFile);
00179 
00184   void   resetHeader(void);
00185 
00191   void   Seek(int off, std::ios::seekdir mode);
00192 
00197   void   Skip(int off);
00198      
00199 private:
00200   std::istream& mIn;
00201   bool     mSwap;
00202   bool     mHeaderOK;
00203   char     mData[40];
00204   int      mVersion;
00205   StrHdr   mSHdr;
00206   long     mOffset;
00207   long     mHdrSz;
00208 };
00209 
00210 inline int 
00211 FrameF::getVersion(void) const {
00212     return mVersion;
00213 }
00214 
00215 inline int 
00216 FrameF::getPatch(void) const {
00217     return mData[6];
00218 }
00219 
00220 inline bool
00221 FrameF::isOK(void) const {
00222     return mIn.good();
00223 }
00224 
00225 inline short
00226 FrameF::getID(void) const {
00227     return mSHdr.ID;
00228 }
00229 
00230 inline short 
00231 FrameF::getInstance(void) const {
00232     return mSHdr.Instance;
00233 }
00234 
00235 inline int
00236 FrameF::getLength(void) const {
00237     return mSHdr.length;
00238 }
00239 
00240 inline int
00241 FrameF::getStrucHdrLen(void) const {
00242     return mHdrSz;
00243 }
00244 
00245 inline void
00246 FrameF::resetHeader(void) {
00247     mHeaderOK = false;
00248 }
00249 #endif

Generated on Sun Mar 8 19:20:47 2009 for dmt by  doxygen 1.5.4