TDbiBinaryFile Class Reference

Concept Binary file for reading/writing TDbi related objects. More...

#include <TDbiBinaryFile.hxx>

Collaboration diagram for TDbiBinaryFile:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TDbiBinaryFile (const char *fileName="", Bool_t input=kTRUE)
 ~TDbiBinaryFile ()
 Purpose: Default Destructor.
string GetFileName () const
Bool_t IsOK () const
Bool_t IsReading () const
Bool_t IsWriting () const
void Close ()
 Purpose: Close file.
TDbiBinaryFileoperator>> (Bool_t &num)
 Builtin data type I/O.
TDbiBinaryFileoperator<< (const Bool_t &num)
TDbiBinaryFileoperator>> (Int_t &num)
TDbiBinaryFileoperator<< (const Int_t &num)
TDbiBinaryFileoperator>> (UInt_t &num)
TDbiBinaryFileoperator<< (const UInt_t &num)
TDbiBinaryFileoperator>> (Double_t &num)
TDbiBinaryFileoperator<< (const Double_t &num)
TDbiBinaryFileoperator>> (TVldTimeStamp &ts)
TDbiBinaryFileoperator<< (const TVldTimeStamp &ts)
TDbiBinaryFileoperator>> (string &str)
TDbiBinaryFileoperator<< (const string &str)
TDbiBinaryFileoperator>> (TVldRange &vr)
 Compound object I/O.
TDbiBinaryFileoperator<< (const TVldRange &vr)
TDbiBinaryFileoperator>> (vector< TDbiTableRow * > &arr)
 Vector I/O.
TDbiBinaryFileoperator<< (vector< TDbiTableRow * > &arr)
char * ReleaseArrayBuffer ()

Static Public Member Functions

static Bool_t CanReadL2Cache ()
 Global control of all created TDbiBinaryFile objects.
static Bool_t CanWriteL2Cache ()
static void SetWorkDir (const string &dir)
static void SetReadAccess (Bool_t access=kTRUE)
static void SetWriteAccess (Bool_t access=kTRUE)

Private Member Functions

Bool_t CanRead ()
 The functions that do the low-level I/O.
Bool_t CanWrite ()
void CheckFileStatus ()
Bool_t Read (char *bytes, UInt_t numBytes)
Bool_t Write (const char *bytes, UInt_t numBytes)

Private Attributes

fstream * fFile
 Associated file, may be null.
Bool_t fReading
Bool_t fHasErrors
char * fArrayBuffer
string fFileName

Static Private Attributes

static string fgWorkDir
static Bool_t fgReadAccess = kTRUE
static Bool_t fgWriteAccess = kTRUE

Detailed Description

Concept Binary file for reading/writing TDbi related objects.

Purpose To save/restore cache to speed up startup when running in the same context. Contact: A.Finch@lancaster.ac.uk

Definition at line 42 of file TDbiBinaryFile.hxx.


Constructor & Destructor Documentation

TDbiBinaryFile::TDbiBinaryFile ( const char *  fileName = "",
Bool_t  input = kTRUE 
)
     Purpose:  Default Constructor.
   
     Arguments:
       fileName     in    File name (default: "" => file is a dummy)
       input        in    true if reading (default = kTRUE)
   
     Specification:-
     =============
   
     If file name or fgWorkDir is dummy, or the appropriate access is not set
   

JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ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JJJjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj / then name is set to dummy otherwise fgWorkDir is prepended to the name.

Definition at line 55 of file TDbiBinaryFile.cxx.

References fFile, fFileName, fgReadAccess, fgWorkDir, fgWriteAccess, fHasErrors, and SK_DBI_Debug.

00055                                                                   :
00056 fFile(0),
00057 fReading(input),
00058 fHasErrors(kFALSE),
00059 fArrayBuffer(0)
00060 {
00061 //
00062 //
00063 //  Purpose:  Default Constructor.
00064 //
00065 //  Arguments:
00066 //    fileName     in    File name (default: "" => file is a dummy)
00067 //    input        in    true if reading (default = kTRUE)
00068 
00069 //  Specification:-
00070 //  =============
00071 //
00072 //  If file name or fgWorkDir is dummy, or the appropriate access is not set
00073 //  then name is set to dummy otherwise fgWorkDir is prepended to the name.
00074 
00075   // Complete the file name.
00076   fFileName = fileName;
00077   if ( fFileName != "" ) {
00078     Bool_t access = input ? fgReadAccess : fgWriteAccess;
00079     if ( fgWorkDir == "" || ! access ) fFileName = "";
00080     else                               fFileName = fgWorkDir +  fFileName;
00081   }
00082 
00083   // Open the file.
00084   ios_base::openmode mode = ios_base::in|ios_base::binary;
00085   if ( ! input ) mode = ios_base::out|ios_base::binary;
00086 
00087   if ( fFileName == "" ) fHasErrors = kTRUE;
00088   else {
00089     fFile = new fstream(fFileName.c_str(),mode);
00090     if ( ! fFile->is_open() || ! fFile->good() ) {
00091       SK_DBI_Debug( "Cannot open " << fFileName
00092                              << "; all I/O will fail." << "  ");
00093       fHasErrors = kTRUE;
00094     }
00095   }
00096 
00097 }
//.....................................................................

TDbiBinaryFile::~TDbiBinaryFile (  ) 

Purpose: Default Destructor.

Definition at line 100 of file TDbiBinaryFile.cxx.

References Close(), fArrayBuffer, and fFile.

00101 {
00102 //
00103 //
00104 
00105 
00106   delete[] fArrayBuffer;
00107   fArrayBuffer = 0;
00108   this->Close();
00109   delete fFile;
00110   fFile = 0;
00111 
00112 }

Here is the call graph for this function:


Member Function Documentation

Bool_t TDbiBinaryFile::CanRead (  )  [private]

The functions that do the low-level I/O.

Definition at line 403 of file TDbiBinaryFile.cxx.

References fReading, IsOK(), and SK_DBI_Severe.

Referenced by operator>>(), and Read().

00403                                {
00404 
00405   if ( ! fReading ) {
00406        SK_DBI_Severe( "Attempting to read from a write-only file" << "  ");
00407     return kFALSE;
00408   }
00409   return this->IsOK();
00410 
00411 }

Here is the call graph for this function:

Here is the caller graph for this function:

static Bool_t TDbiBinaryFile::CanReadL2Cache (  )  [inline, static]

Global control of all created TDbiBinaryFile objects.

Definition at line 114 of file TDbiBinaryFile.hxx.

References fgReadAccess, and fgWorkDir.

00114 { return fgWorkDir.size() && fgReadAccess; }

Bool_t TDbiBinaryFile::CanWrite (  )  [private]

Definition at line 414 of file TDbiBinaryFile.cxx.

References fReading, IsOK(), and SK_DBI_Severe.

Referenced by operator<<(), and Write().

00414                                 {
00415 
00416   if ( fReading ) {
00417        SK_DBI_Severe( "Attempting to write to a read-only file" << "  ");
00418     return kFALSE;
00419   }
00420   return this->IsOK();
00421 
00422 }

Here is the call graph for this function:

Here is the caller graph for this function:

static Bool_t TDbiBinaryFile::CanWriteL2Cache (  )  [inline, static]

Definition at line 115 of file TDbiBinaryFile.hxx.

References fgWorkDir, and fgWriteAccess.

Referenced by TDbiTableProxy::SaveToL2Cache().

00115 { return fgWorkDir.size() && fgWriteAccess; }

Here is the caller graph for this function:

void TDbiBinaryFile::CheckFileStatus (  )  [private]

Definition at line 426 of file TDbiBinaryFile.cxx.

References Close(), fFile, fFileName, fHasErrors, fReading, and SK_DBI_Severe.

Referenced by Read(), and Write().

00426                                      {
00427 
00428 //  If file was good but has just gone bad, report and close it.
00429 //  Delete it if writing.
00430 
00431   if (    fFile
00432        && ! fHasErrors
00433        && ( ! fFile->is_open() || ! fFile->good() ) ) {
00434        SK_DBI_Severe( "File not open or has gone bad,"
00435                            << " all further I/O will fail." << "  ");
00436     fHasErrors = kTRUE;
00437     this->Close();
00438 
00439     //Delete file if writing.
00440     if ( ! fReading ) {
00441          SK_DBI_Severe( "Erasing " << fFileName << "  ");
00442       gSystem->Unlink(fFileName.c_str());
00443     }
00444 
00445   }
00446 
00447 }

Here is the call graph for this function:

Here is the caller graph for this function:

void TDbiBinaryFile::Close (  ) 

Purpose: Close file.

Definition at line 115 of file TDbiBinaryFile.cxx.

References fFile.

Referenced by CheckFileStatus(), and ~TDbiBinaryFile().

00116 {
00117 //
00118 //
00119 
00120 
00121   if ( fFile ) fFile->close();
00122 }

Here is the caller graph for this function:

string TDbiBinaryFile::GetFileName (  )  const [inline]

Definition at line 66 of file TDbiBinaryFile.hxx.

References fFileName.

00066 { return fFileName; }

Bool_t TDbiBinaryFile::IsOK (  )  const [inline]

Definition at line 67 of file TDbiBinaryFile.hxx.

References fHasErrors.

Referenced by CanRead(), CanWrite(), IsReading(), and IsWriting().

00067 { return ! fHasErrors;}

Here is the caller graph for this function:

Bool_t TDbiBinaryFile::IsReading (  )  const [inline]

Definition at line 68 of file TDbiBinaryFile.hxx.

References fReading, and IsOK().

Referenced by TDbiValidityRec::Streamer(), TDbiResultSetNonAgg::Streamer(), and TDbiResultSet::Streamer().

00068 { return this->IsOK() && fReading; }

Here is the call graph for this function:

Here is the caller graph for this function:

Bool_t TDbiBinaryFile::IsWriting (  )  const [inline]

Definition at line 69 of file TDbiBinaryFile.hxx.

References fReading, and IsOK().

Referenced by TDbiValidityRec::Streamer(), TDbiResultSetNonAgg::Streamer(), and TDbiResultSet::Streamer().

00069 { return this->IsOK() && ! fReading; }

Here is the call graph for this function:

Here is the caller graph for this function:

TDbiBinaryFile & TDbiBinaryFile::operator<< ( vector< TDbiTableRow * > &  arr  ) 
    Vector I/O.
    ***********
   
   
     Purpose: Read a vector of objects inheriting from TDbiTableRow.
   
      NB:     On entry, array must be empty.
   
   
              The objects are written into a buffer that is a contiguous
              area of memory that is allocated to receive it. After a
              successful read the user must call ReleaseArrayBuffer to take
              control over this buffer as it will be automatically release
              when the next array input occurs otherwise.
    */
//  For the format of record see the operator <<.
///

TDbiBinaryFile& TDbiBinaryFile::operator >> (vector<TDbiTableRow*>& arr) {

if ( ! this->CanRead() ) return *this;

if ( arr.size() ) { SK_DBI_Severe( "Attempting to read into non-empty array" << " "); return *this; }

Check for start of array marker.

UInt_t marker = 0; (*this) >> marker; if ( marker != StartMarker ) { SK_DBI_Severe( "Cannot find start of array marker" << " "); this->Close(); this->CheckFileStatus(); return *this; }

Get array size and deal with non-empty arrays.

Int_t arrSize = 0; (*this) >> arrSize;

if ( arrSize ) { Int_t objSize = 0; string objName; (*this) >> objName >> objSize;

Ensure that sizes look sensible and use ROOT to instatiate an example object so that we can get the address of the virtual table.

TClass objClass(objName.c_str()); Int_t objSizefromRoot = objClass.Size(); void* obj = objClass.New(); void* vt = GetVTptr(obj); This only works if the address of the sub-class object is the same as the underlying base class, which should be true in this simple case. TDbiTableRow* tr = reinterpret_cast<TDbiTableRow*>(obj); delete tr;

SK_DBI_Verbose( "Restoring array of " << arrSize << " " << objName << " objects" << " VTaddr " << std::ios::hex << vt << std::ios::dec << " object size " << objSize << "(from file) " << objSizefromRoot << "(from ROOT)" << " ");

if ( arrSize < 0 || objSize != objSizefromRoot ) { SK_DBI_Severe( "Illegal array size ("<< arrSize << ") or object size(" << objSize << "," << objSizefromRoot << ")" << " "); this->Close(); this->CheckFileStatus(); return *this; }

Allocate buffer and load in array. delete[] fArrayBuffer; Int_t buffSize = arrSize*objSize; fArrayBuffer = new char[buffSize]; this->Read(fArrayBuffer,buffSize);

Fix up VT pointers and populate the vector.

char* elem = fArrayBuffer; arr.reserve(arrSize); for (int row = 0; row < arrSize; ++row ) { SetVTptr(elem,vt); arr.push_back(reinterpret_cast<TDbiTableRow*>(elem)); elem += objSize; }

}

Check for end of array marker.

(*this) >> marker; if ( marker != EndMarker ) { SK_DBI_Severe( "Cannot find end of array marker" << " "); this->Close(); this->CheckFileStatus(); }

return *this;

}

/**.....................................................................

   
     Purpose: Write a vector of objects inheriting from TDbiTableRow.
   
     Format of record:-
   
     Int_t   StartMarker  Start of record marker = 0xaabbccdd
     Int_t   arrSize      Size of vector
   
     If size of vector > 0 this is folowed by:-
   
     string  objName      Name of object
     Int_t   objSize      Size of object
     char*                The data arrSize*objSize bytes long
   
     The record concludes:-
   
     Int_t     EndMarker  End of record marker = 0xddbbccaa
   

Definition at line 368 of file TDbiBinaryFile.cxx.

References EndMarker, and StartMarker.

00368                                                                        {
00369 
00370 
00371   if ( ! this->CanWrite() ) return *this;
00372 
00373   UInt_t marker = StartMarker;
00374   (*this) << marker;
00375   Int_t arrSize = arr.size();
00376   (*this) << arrSize;
00377 
00378   if ( arrSize ) {
00379     TDbiTableRow* obj = arr[0];
00380     Int_t objSize  = obj->IsA()->Size();
00381     string objName = obj->ClassName();
00382     (*this) << objName << objSize;
00383     for (int row = 0; row < arrSize; ++row ) {
00384       obj = arr[row];
00385       const char* p = reinterpret_cast<const char*>(arr[row]);
00386       this->Write(p,objSize);
00387     }
00388 
00389   }
00390 
00391   marker = EndMarker;
00392   (*this) << marker;
00393 
00394   return *this;
00395 
00396 }

TDbiBinaryFile & TDbiBinaryFile::operator<< ( const TVldRange vr  ) 

Definition at line 225 of file TDbiBinaryFile.cxx.

References CanWrite(), TVldRange::GetDataSource(), TVldRange::GetDetectorMask(), TVldRange::GetSimMask(), TVldRange::GetTimeEnd(), and TVldRange::GetTimeStart().

00225                                                                 {
00226 
00227   if ( this->CanWrite() ) {
00228     string str(vr.GetDataSource().Data());
00229     (*this) << vr.GetDetectorMask()
00230             << vr.GetSimMask()
00231             << vr.GetTimeStart()
00232             << vr.GetTimeEnd()
00233             << str;
00234   }
00235   return *this;
00236 }

Here is the call graph for this function:

TDbiBinaryFile & TDbiBinaryFile::operator<< ( const string &  str  ) 

Definition at line 195 of file TDbiBinaryFile.cxx.

References Write().

00195                                                               {
00196 
00197   UInt_t numBytes = str.size()+1;
00198   this->Write(str.c_str(),numBytes);
00199   return *this;
00200 }

Here is the call graph for this function:

TDbiBinaryFile& TDbiBinaryFile::operator<< ( const TVldTimeStamp ts  ) 
TDbiBinaryFile& TDbiBinaryFile::operator<< ( const Double_t &  num  ) 
TDbiBinaryFile& TDbiBinaryFile::operator<< ( const UInt_t &  num  ) 
TDbiBinaryFile& TDbiBinaryFile::operator<< ( const Int_t &  num  ) 
TDbiBinaryFile& TDbiBinaryFile::operator<< ( const Bool_t &  num  ) 
TDbiBinaryFile& TDbiBinaryFile::operator>> ( vector< TDbiTableRow * > &  arr  ) 

Vector I/O.

TDbiBinaryFile & TDbiBinaryFile::operator>> ( TVldRange vr  ) 

Compound object I/O.

Definition at line 204 of file TDbiBinaryFile.cxx.

References CanRead().

00204                                                           {
00205 
00206   if ( this->CanRead() ) {
00207     Int_t        detectorMask;
00208     Int_t        simMask;
00209     TVldTimeStamp timeStart;
00210     TVldTimeStamp timeEnd;
00211     string str;
00212     (*this) >> detectorMask
00213             >> simMask
00214             >> timeStart
00215             >> timeEnd
00216             >> str;
00217     TString dataSource(str.c_str());
00218     TVldRange tmp(detectorMask,simMask,timeStart,timeEnd,dataSource);
00219     vr = tmp;
00220   }
00221   return *this;
00222 }

Here is the call graph for this function:

TDbiBinaryFile & TDbiBinaryFile::operator>> ( string &  str  ) 

String I/O. Warning: Implimentation assumes that string does not contain a null character.

Definition at line 185 of file TDbiBinaryFile.cxx.

00185                                                         {
00186 
00187   if ( this->CanRead() ) {
00188     getline(*fFile,str,'\0');
00189     this->CheckFileStatus();
00190   }
00191   return *this;
00192 }

TDbiBinaryFile& TDbiBinaryFile::operator>> ( TVldTimeStamp ts  ) 

Simple Virtual object I/O. (i.e. object with vptr but only built-in data types)

TDbiBinaryFile& TDbiBinaryFile::operator>> ( Double_t &  num  ) 
TDbiBinaryFile& TDbiBinaryFile::operator>> ( UInt_t &  num  ) 
TDbiBinaryFile& TDbiBinaryFile::operator>> ( Int_t &  num  ) 
TDbiBinaryFile& TDbiBinaryFile::operator>> ( Bool_t &  num  ) 

Builtin data type I/O.

Bool_t TDbiBinaryFile::Read ( char *  bytes,
UInt_t  numBytes 
) [private]

Definition at line 451 of file TDbiBinaryFile.cxx.

References CanRead(), CheckFileStatus(), fFile, and fHasErrors.

00451                                                         {
00452 //
00453 //
00454 //  Purpose: Low-level I/O with error checking.
00455 //
00456 
00457   if ( ! this->CanRead() ) return kFALSE;
00458 
00459   fFile->read(bytes,numBytes);
00460   this->CheckFileStatus();
00461   return ! fHasErrors;
00462 }

Here is the call graph for this function:

char* TDbiBinaryFile::ReleaseArrayBuffer (  )  [inline]

Definition at line 108 of file TDbiBinaryFile.hxx.

References fArrayBuffer.

Referenced by TDbiResultSetNonAgg::Streamer().

00108                              { char* buff = fArrayBuffer;
00109                                fArrayBuffer = 0;
00110                                return buff; }

Here is the caller graph for this function:

static void TDbiBinaryFile::SetReadAccess ( Bool_t  access = kTRUE  )  [inline, static]

Definition at line 118 of file TDbiBinaryFile.hxx.

References fgReadAccess.

00118 { fgReadAccess = access; }

static void TDbiBinaryFile::SetWorkDir ( const string &  dir  )  [inline, static]

Definition at line 116 of file TDbiBinaryFile.hxx.

References fgWorkDir.

Referenced by TDbiDatabaseManager::Config().

00116                                               { fgWorkDir = dir;
00117                   if ( fgWorkDir[fgWorkDir.size()-1] != '/' ) fgWorkDir += '/'; }

Here is the caller graph for this function:

static void TDbiBinaryFile::SetWriteAccess ( Bool_t  access = kTRUE  )  [inline, static]

Definition at line 119 of file TDbiBinaryFile.hxx.

References fgWriteAccess.

00119 { fgWriteAccess = access; }

Bool_t TDbiBinaryFile::Write ( const char *  bytes,
UInt_t  numBytes 
) [private]

Definition at line 466 of file TDbiBinaryFile.cxx.

References CanWrite(), CheckFileStatus(), fFile, and fHasErrors.

Referenced by operator<<().

00466                                                                {
00467 //
00468 //
00469 //  Purpose: Low-level I/O with error checking.
00470 //
00471 
00472   if ( ! this->CanWrite() ) return kFALSE;
00473 
00474   fFile->write(bytes,numBytes);
00475   this->CheckFileStatus();
00476   return ! fHasErrors;
00477 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 141 of file TDbiBinaryFile.hxx.

Referenced by ReleaseArrayBuffer(), and ~TDbiBinaryFile().

fstream* TDbiBinaryFile::fFile [private]

Associated file, may be null.

Definition at line 136 of file TDbiBinaryFile.hxx.

Referenced by CheckFileStatus(), Close(), Read(), TDbiBinaryFile(), Write(), and ~TDbiBinaryFile().

string TDbiBinaryFile::fFileName [private]

Definition at line 142 of file TDbiBinaryFile.hxx.

Referenced by CheckFileStatus(), GetFileName(), and TDbiBinaryFile().

Bool_t TDbiBinaryFile::fgReadAccess = kTRUE [static, private]

Definition at line 145 of file TDbiBinaryFile.hxx.

Referenced by CanReadL2Cache(), SetReadAccess(), and TDbiBinaryFile().

string TDbiBinaryFile::fgWorkDir [static, private]

Definition at line 144 of file TDbiBinaryFile.hxx.

Referenced by CanReadL2Cache(), CanWriteL2Cache(), SetWorkDir(), and TDbiBinaryFile().

Bool_t TDbiBinaryFile::fgWriteAccess = kTRUE [static, private]

Definition at line 146 of file TDbiBinaryFile.hxx.

Referenced by CanWriteL2Cache(), SetWriteAccess(), and TDbiBinaryFile().

Bool_t TDbiBinaryFile::fHasErrors [private]

Definition at line 140 of file TDbiBinaryFile.hxx.

Referenced by CheckFileStatus(), IsOK(), Read(), TDbiBinaryFile(), and Write().

Bool_t TDbiBinaryFile::fReading [private]

Definition at line 139 of file TDbiBinaryFile.hxx.

Referenced by CanRead(), CanWrite(), CheckFileStatus(), IsReading(), and IsWriting().


The documentation for this class was generated from the following files:

Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1