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 WriteHeader(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 WriteTrailer(const char* pTrailer, int size);
67 * Close file and flush output.
68 * @param bFlush write remaining data
69 * @return neg. error code if failed
70 * - -ENOSPC buffer size too small
72 int Close(int bFlush=1);
75 * Check if file has been closed.
78 int IsClosed() {return fbClosed;}
81 * Get the last error code.
84 int GetErrno() {return fErrno;}
89 int GetHeaderSize() {return fHeaderSize;}
92 // Interface to basic system I/O routines
93 Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
94 Int_t SysClose(Int_t fd);
95 Int_t SysRead(Int_t fd, void *buf, Int_t len);
96 Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
97 Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
98 Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
99 Int_t SysSync(Int_t fd);
102 /** not a valid copy constructor, defined according to effective C++ style */
103 AliHLTMemoryFile(const AliHLTMemoryFile&);
104 /** not a valid assignment op, but defined according to effective C++ style */
105 AliHLTMemoryFile& operator=(const AliHLTMemoryFile&);
108 char* fpBuffer; //! transient
110 /** size of buffer */
111 int fBufferSize; // see above
114 int fPosition; // see above
116 /** filled posrtion of the buffer */
117 int fSize; // see above
119 /** result of last operation */
120 int fErrno; // see above
123 int fbClosed; // see above
125 /** size of header */
126 int fHeaderSize; // see above
128 /** size of trailer */
129 int fTrailerSize; // see above
131 ClassDef(AliHLTMemoryFile, 1)
133 #endif // ALIHLTMEMORYFILE_H