LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTMemoryFile.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 4 25.0 %
Date: 2016-06-14 17:26:59 Functions: 1 11 9.1 %

          Line data    Source code
       1             : //-*- Mode: C++ -*-
       2             : // @(#) $Id$
       3             : 
       4             : #ifndef ALIHLTMEMORYFILE_H
       5             : #define ALIHLTMEMORYFILE_H
       6             : /* This file is property of and copyright by the ALICE HLT Project        * 
       7             :  * ALICE Experiment at CERN, All rights reserved.                         *
       8             :  * See cxx source for full Copyright notice                               */
       9             : 
      10             : /** @file   AliHLTMemoryFile.h
      11             :     @author Matthias Richter
      12             :     @date   
      13             :     @brief  Serialization of complete ROOT files.
      14             : 
      15             : // see below for class documentation
      16             : // or
      17             : // refer to README to build package
      18             : // or
      19             : // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      20             :                                                                           */
      21             : #include "TFile.h"
      22             : #include "AliHLTLogging.h"
      23             : 
      24             : /**
      25             :  * @class AliHLTMemoryFile
      26             :  * Serialization of ROOT files for transport in the Alice HLT analysis
      27             :  * chain.
      28             :  *
      29             :  * The file behaves like a normal ROOT file except that it is written to
      30             :  * a memory buffer instead of disk.
      31             :  */
      32             : class AliHLTMemoryFile : public TFile, public AliHLTLogging {
      33             :  public:
      34             :   /** standard constructor */
      35             :   AliHLTMemoryFile();
      36             : 
      37             :   /** constructor */
      38             :   AliHLTMemoryFile(void* pBuffer, int iSize);
      39             : 
      40             :   /** standard destructor */
      41             :   virtual ~AliHLTMemoryFile();
      42             : 
      43             :   /**
      44             :    * Write a header at the beginning of the file.
      45             :    * The header is not part of the ROOT file. It should be written before any
      46             :    * other object in order to avoid data to be moved.
      47             :    * @param pHeader     buffer to write
      48             :    * @param iSize       size of the buffer
      49             :    * @return neg. error code if failed
      50             :    *         - -ENOSPC    buffer size too small
      51             :    */
      52             :   int WriteHeaderBuffer(const char* pHeader, int iSize);
      53             : 
      54             :   /**
      55             :    * Write a header at the beginning of the file.
      56             :    * The trailer is not part of the ROOT file. It can only be written if the
      57             :    * file already has been closed.
      58             :    * @param pTrailer    buffer to write
      59             :    * @param iSize       size of the buffer
      60             :    * @return neg. error code if failed
      61             :    *         - -ENOSPC    buffer size too small
      62             :    */
      63             :   // not yet stable
      64             :   //int WriteTrailerBuffer(const char* pTrailer, int size);
      65             : 
      66             :   /**
      67             :    * Close file and flush output.
      68             :    * Forwards to @ref CloseMemoryFile and is introduced to avoid
      69             :    * compilation warnings about hidden virtual functions in the base class.
      70             :    */
      71             :   void Close(const Option_t*);
      72             : 
      73             :   /**
      74             :    * Close file and flush output.
      75             :    * @param bFlush       write remaining data
      76             :    * @return neg. error code if failed
      77             :    *         - -ENOSPC    buffer size too small
      78             :    */
      79             :   int CloseMemoryFile(int bFlush=1);
      80             : 
      81             :   /**
      82             :    * Check if file has been closed.
      83             :    * @return 1 if closed
      84             :    */
      85           0 :   int IsClosed() const {return fbClosed;}
      86             : 
      87             :   /**
      88             :    * Get the last error code.
      89             :    * @return error code
      90             :    */
      91           0 :   int GetErrno() const {return fErrno;}
      92             : 
      93             :   /**
      94             :    * Get header size.
      95             :    */
      96           0 :   int GetHeaderSize() const {return fHeaderSize;}
      97             : 
      98             :  protected:
      99             :   // Interface to basic system I/O routines
     100             :   Int_t    SysOpen(const char *pathname, Int_t flags, UInt_t mode);
     101             :   Int_t    SysClose(Int_t fd);
     102             :   Int_t    SysRead(Int_t fd, void *buf, Int_t len);
     103             :   Int_t    SysWrite(Int_t fd, const void *buf, Int_t len);
     104             :   Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
     105             :   Int_t    SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
     106             :   Int_t    SysSync(Int_t fd);
     107             : 
     108             :  private:
     109             :   /** copy constructor prohibited */
     110             :   AliHLTMemoryFile(const AliHLTMemoryFile&);
     111             :   /** assignment operator prohibited */
     112             :   AliHLTMemoryFile& operator=(const AliHLTMemoryFile&);
     113             : 
     114             :   /** target buffer */
     115             :   char* fpBuffer;                                                 //! transient
     116             : 
     117             :   /** size of buffer */
     118             :   int fBufferSize;                                                // see above
     119             : 
     120             :   /** position */
     121             :   int fPosition;                                                  // see above
     122             : 
     123             :   /** filled posrtion of the buffer */
     124             :   int fSize;                                                      // see above
     125             : 
     126             :   /** result of last operation */
     127             :   int fErrno;                                                     // see above
     128             : 
     129             :   /** file closed */
     130             :   int fbClosed;                                                   // see above
     131             : 
     132             :   /** size of header */
     133             :   int fHeaderSize;                                                // see above
     134             : 
     135             :   /** size of trailer */
     136             :   int fTrailerSize;                                               // see above
     137             : 
     138         126 :   ClassDef(AliHLTMemoryFile, 1)
     139             : };
     140             : #endif // ALIHLTMEMORYFILE_H

Generated by: LCOV version 1.11