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 */
11 @author Matthias Richter
13 @brief The control class for HLTOUT data.
15 // see below for class documentation
17 // refer to README to build package
19 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
23 #include "AliHLTLogging.h"
27 * The control class for HLTOUT data.
28 * The output of the HLT, either from the HLTOUT nodes or simulated output,
29 * is transferred and stored in the HOMER format. The AliHLTOUT class
30 * implements scanning of the HOMER data for all HLTOUT DDL links and
31 * abstracts access to the complete HLTOUT data.
34 class AliHLTOUT : public AliHLTLogging {
36 /** standard constructor */
38 /** standard destructor */
42 * Get number of data blocks in the HLTOUT data
44 int GetNofDataBlocks();
47 * Select the first data block of a certain data type and specification.
48 * The selection criteria can be of kAliHLTAnyDataType and/or
49 * kAliHLTVoidDataSpec in order to be ignored and just match any data block.
50 * @param dt [in] data type to match <br>
51 * @param spec [in] data specification to match <br>
52 * @return identifier >=0 if success, neg. error code if failed <br>
53 * -ENOENT if no block found <br>
54 * -EPERM if access denied (object locked)
56 int SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec);
59 * Select the next data block of data type and specification of the previous
60 * call to @ref SelectFirstDataBlock.
61 * @return identifier >=0 if success, neg. error code if failed <br>
62 * -ENOENT if no block found <br>
63 * -EPERM if access denied (object locked)
65 int SelectNextDataBlock();
68 * Get properties of the selected data block.
69 * @param dt [out] data type of the selected block
70 * @param spec [out] data specification of the selected block
72 int GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec);
75 * Get buffer of the selected data block.
76 * @param pBuffer [out] buffer of the selected data block
77 * @param size [out] size of the selected data block
79 int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size);
82 * Release buffer after use.
83 * @param pBuffer [in] buffer of the selected data block
85 int ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer);
88 * Locking guard for the AliHLTOUT object.
89 * If the object is locked, the selection of data blocks can not be changed.
91 class AliHLTOUTLockGuard {
94 AliHLTOUTLockGuard(AliHLTOUT* pInstance) : fpInstance(pInstance)
95 {if (fpInstance) fpInstance->fbLocked=1;}
98 {if (fpInstance) fpInstance->fbLocked=0;}
101 /** standard constructor prohibited */
102 AliHLTOUTLockGuard();
103 /** copy constructor prohibited */
104 AliHLTOUTLockGuard(const AliHLTOUTLockGuard&);
105 /** assignment operator prohibited */
106 AliHLTOUTLockGuard& operator=(const AliHLTOUTLockGuard&);
108 /** the AliHLTOUT instance the guard is locking */
109 AliHLTOUT* fpInstance; //!transient
115 class AliHLTOUTBlockDescriptor {
117 AliHLTOUTBlockDescriptor(AliHLTComponentDataType dt, AliHLTUInt32_t spec, AliHLTUInt32_t index)
118 : fDataType(dt), fSpecification(spec), fIndex(index) {};
119 ~AliHLTOUTBlockDescriptor() {}
121 operator AliHLTComponentDataType() const {return fDataType;}
122 operator AliHLTUInt32_t() const {return fSpecification;}
123 int operator==(AliHLTComponentDataType dt) const {return dt==fDataType;}
124 int operator==(AliHLTUInt32_t spec) const {return spec==fSpecification;}
126 AliHLTUInt32_t GetIndex() const {return fIndex;}
128 /** data type of the block */
129 AliHLTComponentDataType fDataType; //!transient
130 /** data specification of the block */
131 AliHLTUInt32_t fSpecification; //!transient
132 /** index in the data stream */
133 AliHLTUInt32_t fIndex; //!transient
138 * Add a block descriptor.
139 * This is done by the child classes generating the index. The AliHLTOUT
140 * object must be locked for index generation.
141 * @param desc the block descriptor
142 * @return 0 if success, -EPERM if access denied
144 int AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc);
147 /** copy constructor prohibited */
148 AliHLTOUT(const AliHLTOUT&);
149 /** assignment operator prohibited */
150 AliHLTOUT& operator=(const AliHLTOUT&);
153 * Generate the index of the HLTOUT data.
154 * Must be implemented by the child classes.
156 virtual int GenerateIndex()=0;
159 * Get the data buffer
160 * @param index [in] index of the block
161 * @param pBuffer [out] buffer of the selected data block
162 * @param size [out] size of the selected data block
164 virtual int GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer,
165 AliHLTUInt32_t& size)=0;
167 /** data type for the current block search, set from @ref SelectFirstDataBlock */
168 AliHLTComponentDataType fSearchDataType; //!transient
170 /** data specification for the current block search */
171 AliHLTUInt32_t fSearchSpecification; //!transient
173 /** instance locked or not */
174 int fbLocked; //!transient
176 /** list of block descriptors */
177 vector<AliHLTOUTBlockDescriptor> fBlockDescList; //!transient
179 /** current position in the list */
180 vector<AliHLTOUTBlockDescriptor>::iterator fCurrent; //!transient
182 /** data buffer under processing */
183 const AliHLTUInt8_t* fpBuffer; //!transient
185 ClassDef(AliHLTOUT, 0)