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 */
10 /** @file AliHLTMemoryFile.h
11 @author Matthias Richter
13 @brief Serialization of complete ROOT files.
15 // see below for class documentation
17 // refer to README to build package
19 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
22 #include "AliHLTLogging.h"
25 * @class AliHLTMemoryFile
26 * Serialization of ROOT files for transport in the Alice HLT analysis
29 * The file behaves like a normal ROOT file except that it is written to
30 * a memory buffer instead of disk.
32 class AliHLTMemoryFile : public TFile, public AliHLTLogging {
34 /** standard constructor */
38 AliHLTMemoryFile(void* pBuffer, int iSize);
40 /** standard destructor */
41 virtual ~AliHLTMemoryFile();
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
52 int WriteHeaderBuffer(const char* pHeader, int iSize);
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
64 //int WriteTrailerBuffer(const char* pTrailer, int size);
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.
71 void Close(const Option_t*);
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
79 int CloseMemoryFile(int bFlush=1);
82 * Check if file has been closed.
85 int IsClosed() const {return fbClosed;}
88 * Get the last error code.
91 int GetErrno() const {return fErrno;}
96 int GetHeaderSize() const {return fHeaderSize;}
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);
109 /** copy constructor prohibited */
110 AliHLTMemoryFile(const AliHLTMemoryFile&);
111 /** assignment operator prohibited */
112 AliHLTMemoryFile& operator=(const AliHLTMemoryFile&);
115 char* fpBuffer; //! transient
117 /** size of buffer */
118 int fBufferSize; // see above
121 int fPosition; // see above
123 /** filled posrtion of the buffer */
124 int fSize; // see above
126 /** result of last operation */
127 int fErrno; // see above
130 int fbClosed; // see above
132 /** size of header */
133 int fHeaderSize; // see above
135 /** size of trailer */
136 int fTrailerSize; // see above
138 ClassDef(AliHLTMemoryFile, 1)
140 #endif // ALIHLTMEMORYFILE_H