minor modification (proper C++ type cast)
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTFileWriter.h
CommitLineData
e74abd18 1// @(#) $Id$
2
3#ifndef ALIHLTFILEWRITER_H
4#define ALIHLTFILEWRITER_H
79c114b5 5/* This file is property of and copyright by the ALICE HLT Project *
6 * ALICE Experiment at CERN, All rights reserved. *
e74abd18 7 * See cxx source for full Copyright notice */
8
9/** @file AliHLTFileWriter.h
10 @author Matthias Richter
11 @date
12 @brief An HLT file dump (data sink) component.
13*/
14
15#include "AliHLTDataSink.h"
5df0cbb9 16#include <TString.h>
17//#include <TList.h>
e74abd18 18
19/**
20 * @class AliHLTFileWriter
21 * An HLT data sink component which writes data to file(s).
22 *
23 * Component ID: \b FileWriter <br>
24 * Library: \b libHLTBase (in order to use the component from the external
25 * interface, it might be necessary to specify a dummy library with the
26 * \em -componentlibrary argument).
27 *
28 * Mandatory arguments: <br>
29 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
30 *
31 * Optional arguments: <br>
32 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
33 * \li -datafile <i> filename </i> <br>
34 * file name base
35 * \li -directory <i> directory </i> <br>
36 * target directory
37 * \li -enumerate <br>
38 * don't use the event number but an event counter beginning from 0
39 * \li -concatenate-blocks <br>
40 * concatenate all blocks of one event into one file, this skips
41 * the block no, and the block data type in the file name
42 * \li -concatenate-events <br>
43 * concatenate all events into one file, this skips the event no,
44 * the block no, and the block data type in the file name. Currently,
45 * this implies the -concatenate-blocks option.
46 *
47 * The file name is built from the basename, the event number, the block
48 * number and the data type in the format:
49 * <pre>
50 * basename_eventno_blockno_dt
51 * </pre>
52 * If the basename was not given, \em 'event' ist used instead. A file
53 * extension after the last dot is separated from the basename and appended
54 * to the final name.
55 *
56 * The class can be used as a base class for file writers. Additional
57 * argument scan can be implemented in @ref ScanArgument which is called
58 * for each unknown argument.
59 * @ingroup alihlt_component
60 */
61class AliHLTFileWriter : public AliHLTDataSink {
62 public:
63 /** standard constructor */
64 AliHLTFileWriter();
65 /** not a valid copy constructor, defined according to effective C++ style */
66 AliHLTFileWriter(const AliHLTFileWriter&);
67 /** not a valid assignment op, but defined according to effective C++ style */
68 AliHLTFileWriter& operator=(const AliHLTFileWriter&);
69 /** destructor */
70 virtual ~AliHLTFileWriter();
71
72 virtual const char* GetComponentID();
73 virtual void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
74 virtual AliHLTComponent* Spawn();
75
76 protected:
77 /**
78 * Init method.
79 */
80 int DoInit( int argc, const char** argv );
81
82 /**
83 * Deinit method.
84 */
85 int DoDeinit();
86
87 /**
88 * Init the writer.
89 * The DoInit function is not available for child classes. InitWriter is the
90 * corresponding function for classes derived from AliHLTFileWriter.
91 */
92 virtual int InitWriter();
93
94 /**
79c114b5 95 * Close the writer.
e74abd18 96 * The DoDeinit function is not available for child classes. CloseWriter is the
97 * corresponding function for classes derived from AliHLTFileWriter.
98 */
99 virtual int CloseWriter();
100
101 /**
102 * Data processing method for the component.
103 * The function can be overloaded by other file writer components.
104 * @param evtData event data structure
105 * @param blocks input data block descriptors
106 * @param trigData trigger data structure
107 */
108 virtual int DumpEvent( const AliHLTComponentEventData& evtData,
109 const AliHLTComponentBlockData* blocks,
110 AliHLTComponentTriggerData& trigData );
111
112 /**
113 * Scan one argument and adjacent parameters.
114 * Can be overloaded by child classes in order to add additional arguments
115 * beyond the standard arguments of the file publisher. The method is called
116 * whenever a non-standard argument is recognized. Make sure to return
117 * <tt> -EPROTO </tt> if the argument is not recognized be the child.
118 * @param argc size of the argument array
119 * @param argv agument array for component initialization
120 * @return number of processed members of the argv <br>
121 * -EINVAL unknown argument <br>
122 * -EPROTO parameter for argument missing <br>
123 */
124 virtual int ScanArgument(int argc, const char** argv);
125
126 /**
127 * Build file name from eventID data type and the specified directory and basename.
128 * @param eventID [in] the ID of the event
129 * @param blockID [in] the ID of the current block
130 * no block string appended if -1
131 * @param dataType [in] the data type of the data block
132 * no type string appanded if @ref kAliHLTVoidDataType
133 * @param filename [out] string to receive the file name
134 */
135 int BuildFileName(const AliHLTEventID_t eventID, const int blockID, const AliHLTComponentDataType& dataType, TString& filename);
136
137 /**
138 * Set a mode flag.
139 * @return current mode flags
140 */
141 int SetMode(Short_t mode);
142
143 /**
144 * Clear a mode flag.
145 * @return current mode flags
146 */
147 int ClearMode(Short_t mode);
148
149 /**
150 * Check a mode flag.
151 * @return 1 if flag is set, 0 if not
152 */
5df0cbb9 153 int CheckMode(Short_t mode) const;
e74abd18 154
155 /**
156 * Working modes of the writer
157 * @internal
158 */
159 enum TWriterMode {
160 /**
161 * flag to indicate whether to write each incoming block to separate files
162 * or all blocks of one event to one file. set = concatenate (one file).
163 */
164 kConcatenateBlocks = 0x1,
165
166 /**
167 * flag to indicate whether to concatenate incoming blocks of the same type
168 * for all events to one file. If also @ref kConcatenateBlocks is set,
169 * or all blocks of all events are written to the same file.
170 */
171 kConcatenateEvents = 0x2,
172
173 /** event enumeration flag */
174 kEnumerate = 0x4
175 };
176
177 private:
178 /** the basename of the output file */
179 TString fBaseName; // see above
180 /** the extension of the output file */
181 TString fExtension; // see above
182 /** target directory */
183 TString fDirectory; // see above
184 /** enumeration format string */
185 TString fCurrentFileName; // see above
186
187 /** mode specifier, see @ref TWriterMode */
188 Short_t fMode; // see above
189
190 ClassDef(AliHLTFileWriter, 1)
191};
192#endif