00001 #ifndef SIO_LCSIO_H
00002 #define SIO_LCSIO_H 1
00003
00004 #include "LCIOTypes.h"
00005
00006 #include "SIO_record.h"
00007 #include "SIO_definitions.h"
00008
00009 #include <string>
00010
00011
00012 #define LCSIO_RUNRECORDNAME "LCRunHeader"
00013 #define LCSIO_RUNBLOCKNAME "RunHeader"
00014 #define LCSIO_EVENTRECORDNAME "LCEvent"
00015 #define LCSIO_EVENTBLOCKNAME "Event"
00016 #define LCSIO_HEADERRECORDNAME "LCEventHeader"
00017 #define LCSIO_HEADERBLOCKNAME "EventHeader"
00018
00019 #define LCSIO_ACCESSRECORDNAME "LCIORandomAccess"
00020 #define LCSIO_ACCESSBLOCKNAME "LCIORandomAccess"
00021 #define LCSIO_RANDOMACCESS_SIZE 136
00022 #define LCSIO_INDEXRECORDNAME "LCIOIndex"
00023 #define LCSIO_INDEXBLOCKNAME "LCIOIndex"
00024
00025
00026 class SIO_stream ;
00027
00028 namespace SIO {
00029
00030 class LCSIO ;
00031
00037 class SIORecords {
00038
00039 friend class LCSIO ;
00040 public:
00041
00042 enum ID{
00043 Event=0,
00044 Header,
00045 Run,
00046 Access,
00047 Index,
00048 NumberOfRecords
00049 } ;
00050
00056 class Unpack{
00057 public:
00058 static const unsigned Event = 0x0001 << SIORecords::Event ;
00059 static const unsigned Header = 0x0001 << SIORecords::Header ;
00060 static const unsigned Run = 0x0001 << SIORecords::Run ;
00061 static const unsigned Access = 0x0001 << SIORecords::Access ;
00062 static const unsigned Index = 0x0001 << SIORecords::Index ;
00063
00064 static const unsigned All = 0xFFFFFFFF ;
00065
00066 Unpack( unsigned recordFlag ) ;
00067 ~Unpack() ;
00068
00069 protected:
00070 bool _flags[ NumberOfRecords ] ;
00071 };
00072
00073
00074
00075 SIO_record* operator[](size_t idx) ;
00076
00077 void setCompress( bool flag=true ) ;
00078
00079 protected:
00080 void add(SIO_record*& rec, const char* name) ;
00081
00082 SIO_record* _records[ NumberOfRecords ] ;
00083
00084 SIORecords() ;
00085 } ;
00086
00087
00088 #define LCSIO_READ( rec, pnt ) status = LCSIO::read( (rec), (pnt) ); if( !(status & 1) ) return status;
00089 #define LCSIO_READ_LEN( rec, pnt , len ) status = LCSIO::read( (rec), (pnt) , (len) ); if( !(status & 1) ) return status;
00090
00091 #define LCSIO_WRITE( rec, pnt ) status = LCSIO::write( (rec), (pnt) ); if( !(status & 1) ) return status;
00092
00100 class LCSIO{
00101
00102 public :
00103
00104 static SIORecords& records() ;
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 static const char* FILE_EXTENSION ;
00115
00118 static const bool COMPRESSION = true ;
00119
00120
00123 static void checkVersion(int versionID ) ;
00124
00130 static unsigned int read( SIO_stream* stream ,char** c , int* len=0) ;
00131
00132
00133
00134
00135
00136
00137
00140 static unsigned int write( SIO_stream* stream , int i) ;
00141
00144 static unsigned int write( SIO_stream* stream , unsigned int i) ;
00145
00148 #if defined(_LP64) || defined(__APPLE_CC__)
00149
00150 static unsigned int write( SIO_stream* stream , size_t i) ;
00151 #endif
00152
00155 static unsigned int write( SIO_stream* stream , EVENT::long64 i) ;
00156
00159 static unsigned int write( SIO_stream* stream , float f) ;
00160
00164 static unsigned int write(SIO_stream* stream , const std::string& s) ;
00165
00166
00171 static std::string getValidSIOName(const std::string& aName ) ;
00172
00173
00174
00178 static void seekStream( SIO_stream* stream , EVENT::long64 pos) ;
00179
00180
00181 private:
00182
00183 static char* dummy ;
00184 static int dummy_size ;
00185 static int uid ;
00186 static const int dummy_initial_size = 1024 ;
00187
00188 } ;
00189
00190 }
00191 #endif // ifndef SIO_LCSIO_H