]>
Commit | Line | Data |
---|---|---|
a655eae3 | 1 | //-*- Mode: C++ -*- |
f23a6e1a | 2 | // @(#) $Id$ |
3 | ||
4 | #ifndef ALIHLTCOMPONENT_H | |
5 | #define ALIHLTCOMPONENT_H | |
6 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
7 | * See cxx source for full Copyright notice */ | |
8 | ||
bfccbf68 | 9 | /** @file AliHLTComponent.h |
10 | @author Matthias Richter, Timm Steinbeck | |
11 | @date | |
b22e91eb | 12 | @brief Base class declaration for HLT components. |
13 | @note The class is both used in Online (PubSub) and Offline (AliRoot) | |
14 | context | |
15 | */ | |
16 | /** | |
17 | * @defgroup alihlt_component Component handling of the HLT module | |
18 | * This section describes the the component handling for the HLT module. | |
19 | */ | |
8ede8717 | 20 | |
21 | #include <vector> | |
9ce4bf4a | 22 | #include <string> |
5ec8e281 | 23 | #include "AliHLTLogging.h" |
f23a6e1a | 24 | #include "AliHLTDataTypes.h" |
71d7c760 | 25 | #include "AliHLTDefinitions.h" |
f23a6e1a | 26 | |
2d7ff710 | 27 | /* Matthias Dec 2006 |
28 | * The names have been changed for Aliroot's coding conventions sake | |
29 | * The old names are defined for backward compatibility with the | |
30 | * stand alone SampleLib package | |
31 | */ | |
32 | typedef AliHLTComponentLogSeverity AliHLTComponent_LogSeverity; | |
33 | typedef AliHLTComponentEventData AliHLTComponent_EventData; | |
34 | typedef AliHLTComponentShmData AliHLTComponent_ShmData; | |
35 | typedef AliHLTComponentDataType AliHLTComponent_DataType; | |
36 | typedef AliHLTComponentBlockData AliHLTComponent_BlockData; | |
37 | typedef AliHLTComponentTriggerData AliHLTComponent_TriggerData; | |
38 | typedef AliHLTComponentEventDoneData AliHLTComponent_EventDoneData; | |
39 | ||
f23a6e1a | 40 | class AliHLTComponentHandler; |
a655eae3 | 41 | class TObjArray; |
f23a6e1a | 42 | |
bfccbf68 | 43 | /** |
44 | * @class AliHLTComponent | |
45 | * Base class of HLT data processing components. | |
46 | * The class provides a common interface for HLT data processing components. | |
47 | * The interface can be accessed from the online HLT framework or the AliRoot | |
48 | * offline analysis framework. | |
a655eae3 | 49 | * @section alihltcomponent-properties Component identification and properties |
50 | * Each component must provide a unique ID, input and output data type indications, | |
51 | * and a spawn function. | |
52 | * @subsection alihltcomponent-req-methods Required property methods | |
53 | * - @ref GetComponentID | |
54 | * - @ref GetInputDataTypes (see @ref alihltcomponent-type for default | |
55 | * implementations.) | |
56 | * - @ref GetOutputDataType (see @ref alihltcomponent-type for default | |
57 | * implementations.) | |
58 | * - @ref GetOutputDataSize (see @ref alihltcomponent-type for default | |
59 | * implementations.) | |
60 | * - @ref Spawn | |
bfccbf68 | 61 | * |
a655eae3 | 62 | * @subsection alihltcomponent-opt-mehods Optional handlers |
63 | * - @ref DoInit | |
64 | * - @ref DoDeinit | |
65 | * | |
66 | * @subsection alihltcomponent-processing-mehods Data processing | |
67 | * | |
68 | * | |
69 | * @subsection alihltcomponent-type Component type | |
70 | * Components can be of type | |
71 | * - @ref kSource: components which only produce data | |
72 | * - @ref kProcessor: components which consume and produce data | |
73 | * - @ref kSink: components which only consume data | |
74 | * | |
75 | * where data production and consumption refer to the analysis data stream. In | |
76 | * order to indicate the type, a child component can overload the | |
77 | * @ref GetComponentType function. | |
78 | * @subsubsection alihltcomponent-type-std Standard implementations | |
79 | * Components in general do not need to implement this function, standard | |
80 | * implementations of the 3 types are available: | |
81 | * - AliHLTDataSource for components of type @ref kSource <br> | |
82 | * All types of data sources can inherit from AliHLTDataSource and must | |
83 | * implement the @ref AliHLTDataSource::GetEvent method. The class | |
84 | * also implements a standard method for @ref GetInputDataTypes. | |
85 | * | |
86 | * - AliHLTProcessor for components of type @ref kProcessor <br> | |
87 | * All types of data processors can inherit from AliHLTDataSource and must | |
88 | * implement the @ref AliHLTProcessor::DoEvent method. | |
89 | * | |
90 | * - AliHLTDataSink for components of type @ref kSink <br> | |
91 | * All types of data processors can inherit from AliHLTDataSource and must | |
92 | * implement the @ref AliHLTDataSink::DumpEvent method. The class | |
93 | * also implements a standard method for @ref GetOutputDataType and @ref | |
94 | * GetOutputDataSize. | |
95 | * | |
96 | * @subsection alihltcomponent-environment Running environment | |
bfccbf68 | 97 | * |
98 | * In order to adapt to different environments (on-line/off-line), the component | |
99 | * gets an environment structure with function pointers. The base class provides | |
100 | * member functions for those environment dependend functions. The member | |
101 | * functions are used by the component implementation and are re-mapped to the | |
102 | * corresponding functions. | |
a655eae3 | 103 | * @section alihltcomponent-interfaces Component interfaces |
104 | * Each of the 3 standard component base classes AliHLTProcessor, AliHLTDataSource | |
105 | * and AliHLTDataSink provides it's own processing method (see | |
106 | * @ref alihltcomponent-type-std), which splits into a high and a low-level | |
107 | * method. For the @ref alihltcomponent-low-level-interface, all parameters are | |
108 | * shipped as function arguments, the component is supposed to dump data to the | |
109 | * output buffer and handle all block descriptors. | |
110 | * The @ref alihltcomponent-high-level-interface is the standard processing | |
111 | * method and will be used whenever the low-level method is not overloaded. | |
112 | * | |
113 | * @subsection alihltcomponent-high-level-interface High-level interface | |
114 | * The high-level component interface provides functionality to exchange ROOT | |
115 | * structures between components. In contrast to the | |
116 | * @ref alihltcomponent-low-level-interface, a couple of functions can be used | |
117 | * to access data blocks of the input stream | |
118 | * and send data blocks or ROOT TObject's to the output stream. The functionality | |
119 | * is hidden from the user and is implemented by using ROOT's TMessage class. | |
120 | * | |
121 | * @subsubsection alihltcomponent-high-level-int-methods Interface methods | |
122 | * The interface provides a couple of methods in order to get objects from the | |
123 | * input, data blocks (non TObject) from the input, and to push back objects and | |
124 | * data blocks to the output. For convenience there are several functions of | |
125 | * identical name (and similar behavior) with different parameters defined. | |
126 | * Please refer to the function documentation. | |
127 | * - @ref GetNumberOfInputBlocks <br> | |
128 | * return the number of data blocks in the input stream | |
129 | * - @ref GetFirstInputObject <br> | |
130 | * get the first object of a specific data type | |
131 | * - @ref GetNextInputObject <br> | |
132 | * get the next object of same data type as last GetFirstInputObject/Block call | |
133 | * - @ref GetFirstInputBlock <br> | |
134 | * get the first block of a specific data type | |
135 | * - @ref GetNextInputBlock <br> | |
136 | * get the next block of same data type as last GetFirstInputBlock/Block call | |
137 | * - @ref PushBack <br> | |
138 | * insert an object or data buffer into the output | |
139 | * - @ref CreateEventDoneData <br> | |
140 | * add event information to the output | |
141 | * | |
142 | * In addition, the processing methods are simplified a bit by cutting out most of | |
143 | * the parameters. The component implementation | |
144 | * @see AliHLTProcessor AliHLTDataSource AliHLTDataSink | |
145 | * | |
146 | * @subsubsection alihltcomponent-high-level-int-guidelines High-level interface guidelines | |
147 | * - Structures must inherit from the ROOT object base class TObject in order be | |
148 | * transported by the transportation framework. | |
149 | * - all pointer members must be transient (marked <tt>//!</tt> behind the member | |
150 | * definition), i.e. will not be stored/transported, or properly marked | |
151 | * (<tt>//-></tt>) in order to call the streamer of the object the member is pointing | |
152 | * to. The latter is not recomended. Structures to be transported between components | |
153 | * should be streamlined. | |
154 | * - no use of stl vectors/strings, use appropriate ROOT classes instead | |
155 | * | |
156 | * @subsection alihltcomponent-low-level-interface Low-level interface | |
157 | * The low-level component interface consists of the specific data processing | |
158 | * methods for @ref AliHLTProcessor, @ref AliHLTDataSource, and @ref AliHLTDataSink. | |
159 | * - @ref AliHLTProcessor::DoEvent | |
160 | * - @ref AliHLTDataSource::GetEvent | |
161 | * - @ref AliHLTDataSink::DumpEvent | |
162 | * | |
163 | * | |
164 | * @section alihltcomponent-handling Component handling | |
165 | * The handling of HLT analysis components is carried out by the AliHLTComponentHandler. | |
166 | * Component are registered automatically at load-time of the component shared library | |
167 | * under the following suppositions: | |
168 | * - the component library has to be loaded from the AliHLTComponentHandler using the | |
169 | * @ref AliHLTComponentHandler::LoadLibrary method. | |
170 | * - the component implementation defines one global object (which is generated | |
171 | * when the library is loaded) | |
172 | * | |
173 | * @subsection alihltcomponent-design-rules General design considerations | |
174 | * The analysis code should be implemented in one or more destict class(es). A | |
175 | * \em component should be implemented which interface the destict analysis code to the | |
176 | * component interface. This component generates the analysis object dynamically. <br> | |
177 | * | |
178 | * Assume you have an implemetation <tt> AliHLTDetMyAnalysis </tt>, another class <tt> | |
179 | * AliHLTDetMyAnalysisComponent </tt> contains: | |
180 | * <pre> | |
181 | * private: | |
182 | * AliHLTDetMyAnalysis* fMyAnalysis; //! | |
183 | * </pre> | |
184 | * The object should then be instantiated in the DoInit handler of | |
185 | * <tt>AliHLTDetMyAnalysisComponent </tt>, and cleaned in the DoDeinit handler. | |
186 | * | |
187 | * Further rules: | |
188 | * - avoid big static arrays in the component, allocate the memory at runtime | |
189 | * | |
b22e91eb | 190 | * @ingroup alihlt_component |
a655eae3 | 191 | * @section alihltcomponent-members Class members |
bfccbf68 | 192 | */ |
5ec8e281 | 193 | class AliHLTComponent : public AliHLTLogging { |
f23a6e1a | 194 | public: |
bfccbf68 | 195 | /** standard constructor */ |
f23a6e1a | 196 | AliHLTComponent(); |
70ed7d01 | 197 | /** not a valid copy constructor, defined according to effective C++ style */ |
198 | AliHLTComponent(const AliHLTComponent&); | |
199 | /** not a valid assignment op, but defined according to effective C++ style */ | |
200 | AliHLTComponent& operator=(const AliHLTComponent&); | |
bfccbf68 | 201 | /** standard destructor */ |
f23a6e1a | 202 | virtual ~AliHLTComponent(); |
203 | ||
bfccbf68 | 204 | /** component type definitions */ |
f23a6e1a | 205 | enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 }; |
bfccbf68 | 206 | |
207 | /** | |
208 | * Init function to prepare data processing. | |
209 | * Initialization of common data structures for a sequence of events. | |
210 | * The call is redirected to the internal method @ref DoInit which can be | |
211 | * overridden by the child class.<br> | |
212 | * During Init also the environment structure is passed to the component. | |
213 | * @param environ environment pointer with environment dependend function | |
214 | * calls | |
70ed7d01 | 215 | * @param environParam additionel parameter for function calls, the pointer |
bfccbf68 | 216 | * is passed as it is |
217 | * @param argc size of the argument array | |
218 | * @param argv agument array for component initialization | |
219 | */ | |
70ed7d01 | 220 | virtual int Init( AliHLTComponentEnvironment* environ, void* environParam, int argc, const char** argv ); |
bfccbf68 | 221 | |
222 | /** | |
223 | * Clean-up function to terminate data processing. | |
224 | * Clean-up of common data structures after data processing. | |
225 | * The call is redirected to the internal method @ref DoDeinit which can be | |
226 | * overridden by the child class. | |
227 | */ | |
f23a6e1a | 228 | virtual int Deinit(); |
bfccbf68 | 229 | |
230 | /** | |
231 | * Processing of one event. | |
3cde846d | 232 | * The method is the entrance of the event processing. The parameters are |
233 | * cached for uses with the high-level interface and the DoProcessing | |
234 | * implementation is called. | |
235 | * | |
236 | * @param evtData | |
237 | * @param blocks | |
238 | * @param trigData | |
239 | * @param outputPtr | |
240 | * @param size | |
241 | * @param outputBlockCnt out: size of the output block array, set by the component | |
242 | * @param outputBlocks out: the output block array is allocated internally | |
243 | * @param edd | |
244 | * @return neg. error code if failed | |
245 | */ | |
246 | int ProcessEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
247 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, | |
248 | AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt, | |
249 | AliHLTComponentBlockData*& outputBlocks, | |
250 | AliHLTComponentEventDoneData*& edd ); | |
251 | ||
252 | /** | |
253 | * Internal processing of one event. | |
bfccbf68 | 254 | * The method is pure virtual and implemented by the child classes |
255 | * - @ref AliHLTProcessor | |
256 | * - @ref AliHLTDataSource | |
257 | * - @ref AliHLTDataSink | |
258 | * | |
259 | * @param evtData | |
260 | * @param blocks | |
261 | * @param trigData | |
262 | * @param outputPtr | |
263 | * @param size | |
2d7ff710 | 264 | * @param outputBlocks out: the output block array is allocated internally |
bfccbf68 | 265 | * @param edd |
266 | * @return neg. error code if failed | |
267 | */ | |
3cde846d | 268 | virtual int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, |
8ede8717 | 269 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, |
a655eae3 | 270 | AliHLTUInt32_t& size, |
271 | vector<AliHLTComponentBlockData>& outputBlocks, | |
8ede8717 | 272 | AliHLTComponentEventDoneData*& edd ) = 0; |
f23a6e1a | 273 | |
274 | // Information member functions for registration. | |
bfccbf68 | 275 | |
276 | /** | |
277 | * Get the type of the component. | |
278 | * The function is pure virtual and must be implemented by the child class. | |
279 | * @return component type id | |
280 | */ | |
f23a6e1a | 281 | virtual TComponentType GetComponentType() = 0; // Source, sink, or processor |
bfccbf68 | 282 | |
283 | /** | |
284 | * Get the id of the component. | |
285 | * Each component is identified by a unique id. | |
286 | * The function is pure virtual and must be implemented by the child class. | |
287 | * @return component id (string) | |
288 | */ | |
f23a6e1a | 289 | virtual const char* GetComponentID() = 0; |
bfccbf68 | 290 | |
291 | /** | |
292 | * Get the input data types of the component. | |
293 | * The function is pure virtual and must be implemented by the child class. | |
294 | * @return list of data types in the vector reference | |
295 | */ | |
8ede8717 | 296 | virtual void GetInputDataTypes( vector<AliHLTComponentDataType>& ) = 0; |
bfccbf68 | 297 | |
298 | /** | |
299 | * Get the output data type of the component. | |
300 | * The function is pure virtual and must be implemented by the child class. | |
301 | * @return output data type | |
302 | */ | |
8ede8717 | 303 | virtual AliHLTComponentDataType GetOutputDataType() = 0; |
bfccbf68 | 304 | |
305 | /** | |
306 | * Get a ratio by how much the data volume is shrinked or enhanced. | |
307 | * The function is pure virtual and must be implemented by the child class. | |
308 | * @param constBase <i>return</i>: additive part, independent of the | |
309 | * input data volume | |
310 | * @param inputMultiplier <i>return</i>: multiplication ratio | |
311 | * @return values in the reference variables | |
312 | */ | |
71d7c760 | 313 | virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0; |
f23a6e1a | 314 | |
bfccbf68 | 315 | /** |
316 | * Spawn function. | |
317 | * Each component must implement a spawn function to create a new instance of | |
318 | * the class. Basically the function must return <i>new <b>my_class_name</b></i>. | |
319 | * @return new class instance | |
320 | */ | |
f23a6e1a | 321 | virtual AliHLTComponent* Spawn() = 0; |
0c0c9d99 | 322 | |
bfccbf68 | 323 | /** |
324 | * Find matching data types between this component and a consumer component. | |
325 | * Currently, a component can produce only one type of data. This restriction is most | |
326 | * likely to be abolished in the future. | |
327 | * @param pConsumer a component and consumer of the data produced by this component | |
328 | * @param tgtList reference to a vector list to receive the matching data types. | |
329 | * @return >= 0 success, neg. error code if failed | |
330 | */ | |
8ede8717 | 331 | int FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponentDataType>* tgtList); |
f23a6e1a | 332 | |
bfccbf68 | 333 | /** |
334 | * Set the global component handler. | |
335 | * The static method is needed for the automatic registration of components. | |
336 | */ | |
85869391 | 337 | static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0); |
bfccbf68 | 338 | |
339 | /** | |
340 | * Clear the global component handler. | |
341 | * The static method is needed for the automatic registration of components. | |
342 | */ | |
85869391 | 343 | static int UnsetGlobalComponentHandler(); |
bfccbf68 | 344 | |
9ce4bf4a | 345 | /** |
346 | * Helper function to convert the data type to a string. | |
347 | */ | |
348 | static string DataType2Text( const AliHLTComponentDataType& type ); | |
349 | ||
5f5b708b | 350 | /** |
351 | * Helper function to print content of data type. | |
352 | */ | |
353 | void PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format=NULL) const; | |
354 | ||
9ce4bf4a | 355 | /** |
356 | * helper function to initialize AliHLTComponentEventData structure | |
357 | */ | |
358 | static void FillEventData(AliHLTComponentEventData& evtData); | |
359 | ||
360 | /** | |
361 | * Print info on an AliHLTComponentDataType structure | |
362 | * This is just a helper function to examine an @ref AliHLTComponentDataType | |
363 | * structur. | |
364 | */ | |
365 | void PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt); | |
366 | ||
a655eae3 | 367 | |
f23a6e1a | 368 | protected: |
71d7c760 | 369 | |
bfccbf68 | 370 | /** |
8ede8717 | 371 | * Fill AliHLTComponentBlockData structure with default values. |
bfccbf68 | 372 | * @param blockData reference to data structure |
373 | */ | |
70ed7d01 | 374 | void FillBlockData( AliHLTComponentBlockData& blockData ) const; |
bfccbf68 | 375 | |
376 | /** | |
8ede8717 | 377 | * Fill AliHLTComponentShmData structure with default values. |
bfccbf68 | 378 | * @param shmData reference to data structure |
379 | */ | |
70ed7d01 | 380 | void FillShmData( AliHLTComponentShmData& shmData ) const; |
bfccbf68 | 381 | |
382 | /** | |
8ede8717 | 383 | * Fill AliHLTComponentDataType structure with default values. |
bfccbf68 | 384 | * @param dataType reference to data structure |
385 | */ | |
70ed7d01 | 386 | void FillDataType( AliHLTComponentDataType& dataType ) const; |
f23a6e1a | 387 | |
2d7ff710 | 388 | /** |
389 | * Copy data type structure | |
390 | * Copies the value an AliHLTComponentDataType structure to another one | |
391 | * @param[out] tgtdt target structure | |
392 | * @param[in] srcdt source structure | |
393 | */ | |
394 | void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt); | |
395 | ||
396 | /** | |
397 | * Set the ID and Origin of an AliHLTComponentDataType structure. | |
398 | * The function sets the fStructureSize member and copies the strings | |
399 | * to the ID and Origin. Only characters from the valid part of the string | |
400 | * are copied, the rest is fille with 0's. | |
401 | * Please note that the fID and fOrigin members are not strings, just arrays of | |
402 | * chars of size @ref kAliHLTComponentDataTypefIDsize and | |
21745ddc | 403 | * @ref kAliHLTComponentDataTypefOriginSize respectively and not necessarily with |
2d7ff710 | 404 | * a terminating zero. |
9ce4bf4a | 405 | * @param tgtdt target data type structure |
2d7ff710 | 406 | * @param id ID string |
407 | * @param origin Origin string | |
408 | */ | |
409 | void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin); | |
410 | ||
bfccbf68 | 411 | /** |
412 | * Default method for the internal initialization. | |
413 | * The method is called by @ref Init | |
414 | */ | |
53feaef5 | 415 | virtual int DoInit( int argc, const char** argv ); |
f23a6e1a | 416 | |
bfccbf68 | 417 | /** |
418 | * Default method for the internal clean-up. | |
419 | * The method is called by @ref Deinit | |
420 | */ | |
53feaef5 | 421 | virtual int DoDeinit(); |
f23a6e1a | 422 | |
bfccbf68 | 423 | /** |
424 | * General memory allocation method. | |
425 | * All memory which is going to be used 'outside' of the interface must | |
426 | * be provided by the framework (online or offline). | |
427 | * The method is redirected to a function provided by the current | |
428 | * framework. Function pointers are transferred via the @ref | |
429 | * AliHLTComponentEnvironment structure. | |
430 | */ | |
85869391 | 431 | void* AllocMemory( unsigned long size ); |
f23a6e1a | 432 | |
bfccbf68 | 433 | /** |
434 | * Helper function to create a monolithic BlockData description block out | |
435 | * of a list BlockData descriptors. | |
436 | * For convenience, inside the interface vector lists are used, to make the | |
437 | * interface pure C style, monilithic blocks must be exchanged. | |
438 | * The method is redirected to a function provided by the current | |
439 | * framework. Function pointers are transferred via the @ref | |
440 | * AliHLTComponentEnvironment structure. | |
441 | */ | |
8ede8717 | 442 | int MakeOutputDataBlockList( const vector<AliHLTComponentBlockData>& blocks, AliHLTUInt32_t* blockCount, |
443 | AliHLTComponentBlockData** outputBlocks ); | |
f23a6e1a | 444 | |
bfccbf68 | 445 | /** |
446 | * Fill the EventDoneData structure. | |
447 | * The method is redirected to a function provided by the current | |
448 | * framework. Function pointers are transferred via the @ref | |
449 | * AliHLTComponentEnvironment structure. | |
450 | */ | |
8ede8717 | 451 | int GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd ); |
f23a6e1a | 452 | |
bfccbf68 | 453 | /** |
454 | * Helper function to convert the data type to a string. | |
455 | */ | |
70ed7d01 | 456 | void DataType2Text(const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]) const; |
fa2e9b7c | 457 | |
3cde846d | 458 | /** |
459 | * Get event number. | |
460 | * @return value of the internal event counter | |
461 | */ | |
70ed7d01 | 462 | int GetEventCount() const; |
3cde846d | 463 | |
a655eae3 | 464 | /** |
465 | * Get the number of input blocks. | |
466 | * @return number of input blocks | |
467 | */ | |
468 | int GetNumberOfInputBlocks(); | |
469 | ||
470 | /** | |
471 | * Get the first object of a specific data type from the input data. | |
472 | * The hight-level methods provide functionality to transfer ROOT data | |
473 | * structures which inherit from TObject. | |
474 | * The method looks for the first ROOT object of type dt in the input stream. | |
475 | * If also the class name is provided, the object is checked for the right | |
476 | * class type. The input data block needs a certain structure, namely the | |
477 | * buffer size as first word. If the cross check fails, the retrieval is | |
478 | * silently abondoned, unless the \em bForce parameter is set. | |
479 | * @param dt data type of the object | |
480 | * @param classname class name of the object | |
481 | * @param bForce force the retrieval of an object, error messages | |
482 | * are suppressed if \em bForce is not set | |
483 | * @return pointer to @ref TObject, NULL if no objects of specified type | |
484 | * available | |
485 | */ | |
486 | const TObject* GetFirstInputObject(const AliHLTComponentDataType& dt=kAliHLTAnyDataType, | |
487 | const char* classname=NULL, | |
488 | int bForce=0); | |
489 | ||
490 | /** | |
491 | * Get the first object of a specific data type from the input data. | |
492 | * The hight-level methods provide functionality to transfer ROOT data | |
493 | * structures which inherit from TObject. | |
494 | * The method looks for the first ROOT object of type specified by the ID and | |
495 | * Origin strings in the input stream. | |
496 | * If also the class name is provided, the object is checked for the right | |
497 | * class type. The input data block needs a certain structure, namely the | |
498 | * buffer size as first word. If the cross check fails, the retrieval is | |
499 | * silently abondoned, unless the \em bForce parameter is set. | |
500 | * @param dtID data type ID of the object | |
501 | * @param dtOrigin data type origin of the object | |
502 | * @param classname class name of the object | |
503 | * @param bForce force the retrieval of an object, error messages | |
504 | * are suppressed if \em bForce is not set | |
505 | * @return pointer to @ref TObject, NULL if no objects of specified type | |
506 | * available | |
507 | */ | |
508 | const TObject* GetFirstInputObject(const char* dtID, | |
509 | const char* dtOrigin, | |
510 | const char* classname=NULL, | |
511 | int bForce=0); | |
512 | ||
513 | /** | |
514 | * Get the next object of a specific data type from the input data. | |
515 | * The hight-level methods provide functionality to transfer ROOT data | |
516 | * structures which inherit from TObject. | |
517 | * The method looks for the next ROOT object of type and class specified | |
518 | * to the previous @ref GetFirstInputObject call. | |
519 | * @param bForce force the retrieval of an object, error messages | |
520 | * are suppressed if \em bForce is not set | |
521 | * @return pointer to @ref TObject, NULL if no more objects available | |
522 | */ | |
523 | const TObject* GetNextInputObject(int bForce=0); | |
524 | ||
525 | /** | |
526 | * Get data type of an input block. | |
527 | * Get data type of the object previously fetched via | |
528 | * GetFirstInputObject/NextInputObject or the last one if no object | |
529 | * specified. | |
530 | * @param pObject pointer to TObject | |
531 | * @return data specification, kAliHLTVoidDataSpec if failed | |
532 | */ | |
533 | AliHLTComponentDataType GetDataType(const TObject* pObject=NULL); | |
534 | ||
535 | /** | |
536 | * Get data specification of an input block. | |
537 | * Get data specification of the object previously fetched via | |
538 | * GetFirstInputObject/NextInputObject or the last one if no object | |
539 | * specified. | |
540 | * @param pObject pointer to TObject | |
541 | * @return data specification, kAliHLTVoidDataSpec if failed | |
542 | */ | |
543 | AliHLTUInt32_t GetSpecification(const TObject* pObject=NULL); | |
544 | ||
545 | /** | |
546 | * Get the first block of a specific data type from the input data. | |
547 | * The method looks for the first block of type dt in the input stream. It is intended | |
548 | * to be used within the high-level interface. | |
549 | * @param dt data type of the block | |
550 | * @return pointer to @ref AliHLTComponentBlockData | |
551 | */ | |
552 | const AliHLTComponentBlockData* GetFirstInputBlock(const AliHLTComponentDataType& dt=kAliHLTAnyDataType); | |
553 | ||
554 | /** | |
555 | * Get the first block of a specific data type from the input data. | |
556 | * The method looks for the first block of type specified by the ID and | |
557 | * Origin strings in the input stream. It is intended | |
558 | * to be used within the high-level interface. | |
559 | * @param dtID data type ID of the block | |
560 | * @param dtOrigin data type origin of the block | |
561 | * @return pointer to @ref AliHLTComponentBlockData | |
562 | */ | |
563 | const AliHLTComponentBlockData* GetFirstInputBlock(const char* dtID, | |
564 | const char* dtOrigin); | |
565 | ||
566 | /** | |
567 | * Get input block by index | |
568 | * @return pointer to AliHLTComponentBlockData, NULL if index out of range | |
569 | */ | |
570 | const AliHLTComponentBlockData* GetInputBlock(int index); | |
571 | ||
572 | /** | |
573 | * Get the next block of a specific data type from the input data. | |
574 | * The method looks for the next block of type and class specified | |
575 | * to the previous @ref GetFirstInputBlock call. | |
576 | * To be used within the high-level interface. | |
577 | */ | |
578 | const AliHLTComponentBlockData* GetNextInputBlock(); | |
579 | ||
580 | /** | |
581 | * Get data specification of an input block. | |
582 | * Get data specification of the input bblock previously fetched via | |
583 | * GetFirstInputObject/NextInputObject or the last one if no block | |
584 | * specified. | |
585 | * @param pBlock pointer to input block | |
586 | * @return data specification, kAliHLTVoidDataSpec if failed | |
587 | */ | |
588 | AliHLTUInt32_t GetSpecification(const AliHLTComponentBlockData* pBlock=NULL); | |
589 | ||
590 | /** | |
591 | * Insert an object into the output. | |
592 | * @param pObject pointer to root object | |
593 | * @param dt data type of the object | |
594 | * @param spec data specification | |
595 | * @return neg. error code if failed | |
596 | */ | |
597 | int PushBack(TObject* pObject, const AliHLTComponentDataType& dt, | |
598 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec); | |
599 | ||
600 | /** | |
601 | * Insert an object into the output. | |
602 | * @param pObject pointer to root object | |
603 | * @param dtID data type ID of the object | |
604 | * @param dtOrigin data type origin of the object | |
605 | * @param spec data specification | |
606 | * @return neg. error code if failed | |
607 | */ | |
608 | int PushBack(TObject* pObject, const char* dtID, const char* dtOrigin, | |
609 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec); | |
610 | ||
611 | /** | |
612 | * Insert an object into the output. | |
613 | * @param pBuffer pointer to buffer | |
614 | * @param iSize size of the buffer | |
615 | * @param dt data type of the object | |
616 | * @param spec data specification | |
617 | * @return neg. error code if failed | |
618 | */ | |
619 | int PushBack(void* pBuffer, int iSize, const AliHLTComponentDataType& dt, | |
620 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec); | |
621 | ||
622 | /** | |
623 | * Insert an object into the output. | |
624 | * @param pBuffer pointer to buffer | |
625 | * @param iSize size of the buffer | |
626 | * @param dtID data type ID of the object | |
627 | * @param dtOrigin data type origin of the object | |
628 | * @param spec data specification | |
629 | * @return neg. error code if failed | |
630 | */ | |
631 | int PushBack(void* pBuffer, int iSize, const char* dtID, const char* dtOrigin, | |
632 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec); | |
633 | ||
634 | /** | |
635 | * Insert event-done data information into the output. | |
636 | * @param edd event-done data information | |
637 | */ | |
638 | int CreateEventDoneData(AliHLTComponentEventDoneData edd); | |
639 | ||
f23a6e1a | 640 | private: |
3cde846d | 641 | /** |
642 | * Increment the internal event counter. | |
643 | * To be used by the friend classes AliHLTProcessor, AliHLTDataSource | |
644 | * and AliHLTDataSink. | |
645 | * @return new value of the internal event counter | |
a655eae3 | 646 | * @internal |
3cde846d | 647 | */ |
648 | int IncrementEventCounter(); | |
649 | ||
a655eae3 | 650 | /** |
651 | * Find the first input block of specified data type beginning at index. | |
652 | * @param dt data type | |
653 | * @param startIdx index to start the search | |
654 | * @return index of the block, -ENOENT if no block found | |
655 | * | |
656 | * @internal | |
657 | */ | |
658 | int FindInputBlock(const AliHLTComponentDataType& dt, int startIdx=-1); | |
659 | ||
660 | /** | |
661 | * Get index in the array of input bocks. | |
662 | * Calculate index and check integrety of a block data structure pointer. | |
663 | * @param pBlock pointer to block data | |
664 | * @return index of the block, -ENOENT if no block found | |
665 | * | |
666 | * @internal | |
667 | */ | |
668 | int FindInputBlock(const AliHLTComponentBlockData* pBlock); | |
669 | ||
670 | /** | |
671 | * Create an object from a specified input block. | |
672 | * @param idx index of the input block | |
673 | * @param bForce force the retrieval of an object, error messages | |
674 | * are suppressed if \em bForce is not set | |
675 | * @return pointer to TObject, caller must delete the object after use | |
676 | * | |
677 | * @internal | |
678 | */ | |
679 | TObject* CreateInputObject(int idx, int bForce=0); | |
680 | ||
681 | /** | |
682 | * Get input object | |
683 | * Get object from the input block list | |
684 | * @param idx index in the input block list | |
685 | * @param classname name of the class, object is checked for correct class | |
686 | * name if set | |
687 | * @param bForce force the retrieval of an object, error messages | |
688 | * are suppressed if \em bForce is not set | |
689 | * @return pointer to TObject | |
690 | * | |
691 | * @internal | |
692 | */ | |
693 | TObject* GetInputObject(int idx, const char* classname=NULL, int bForce=0); | |
694 | ||
695 | /** | |
696 | * Insert a buffer into the output block stream. | |
697 | * This is the only method to insert blocks into the output stream, called | |
698 | * from all types of the Pushback method. The actual data might have been | |
699 | * written to the output buffer already. In that case NULL can be provided | |
700 | * as buffer, only the block descriptor will be build. | |
701 | * @param pBuffer pointer to buffer | |
702 | * @param iSize size of the buffer in byte | |
703 | * @param dt data type | |
704 | * @param spec data specification | |
705 | */ | |
706 | int InsertOutputBlock(void* pBuffer, int iSize, | |
707 | const AliHLTComponentDataType& dt, | |
708 | AliHLTUInt32_t spec); | |
709 | ||
710 | ||
bfccbf68 | 711 | /** The global component handler instance */ |
a655eae3 | 712 | static AliHLTComponentHandler* fgpComponentHandler; //! transient |
70ed7d01 | 713 | |
bfccbf68 | 714 | /** The environment where the component is running in */ |
a655eae3 | 715 | AliHLTComponentEnvironment fEnvironment; // see above |
f23a6e1a | 716 | |
a655eae3 | 717 | /** Set by ProcessEvent before the processing starts */ |
718 | AliHLTEventID_t fCurrentEvent; // see above | |
f23a6e1a | 719 | |
3cde846d | 720 | /** internal event no */ |
a655eae3 | 721 | int fEventCount; // see above |
722 | ||
723 | /** the number of failed events */ | |
724 | int fFailedEvents; // see above | |
725 | ||
726 | /** event data struct of the current event under processing */ | |
727 | AliHLTComponentEventData fCurrentEventData; // see above | |
728 | ||
729 | /** array of input data blocks of the current event */ | |
730 | const AliHLTComponentBlockData* fpInputBlocks; //! transient | |
731 | ||
732 | /** index of the current input block */ | |
733 | int fCurrentInputBlock; // see above | |
734 | ||
735 | /** data type of the last block search */ | |
736 | AliHLTComponentDataType fSearchDataType; // see above | |
737 | ||
738 | /** name of the class for the object to search for */ | |
739 | string fClassName; // see above | |
740 | ||
741 | /** array of generated input objects */ | |
742 | TObjArray* fpInputObjects; //! transient | |
743 | ||
744 | /** the output buffer */ | |
745 | AliHLTUInt8_t* fpOutputBuffer; //! transient | |
746 | ||
747 | /** size of the output buffer */ | |
748 | AliHLTUInt32_t fOutputBufferSize; // see above | |
749 | ||
750 | /** size of data written to output buffer */ | |
751 | AliHLTUInt32_t fOutputBufferFilled; // see above | |
752 | ||
753 | /** list of ouput block data descriptors */ | |
754 | vector<AliHLTComponentBlockData> fOutputBlocks; // see above | |
3cde846d | 755 | |
756 | ClassDef(AliHLTComponent, 1) | |
f23a6e1a | 757 | }; |
758 | #endif |