@note The class is used in Offline (AliRoot) context
*/
+// see below for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
#include <vector>
+#include "TObject.h"
#include "AliHLTLogging.h"
#include "AliHLTDataTypes.h"
-//#include "AliHLTDefinitions.h"
-#include "TObject.h"
-//#include "TList.h"
+#include "AliHLTComponent.h"
-class AliHLTComponent;
class AliHLTConsumerDescriptor;
+/** list of AliHLTConsumerDescriptor pointers */
+typedef vector<AliHLTConsumerDescriptor*> AliHLTConsumerDescriptorPList;
+
/**
* @class AliHLTDataBuffer
* @brief Handling of data buffers for the HLT.
/* standard constructor
*/
AliHLTDataBuffer();
- /** not a valid copy constructor, defined according to effective C++ style */
- AliHLTDataBuffer(const AliHLTDataBuffer&);
- /** not a valid assignment op, but defined according to effective C++ style */
- AliHLTDataBuffer& operator=(const AliHLTDataBuffer&);
/** destructor */
virtual ~AliHLTDataBuffer();
* -EINVAL invalid parameter <br>
*/
int FindMatchingDataBlocks(const AliHLTComponent* pConsumer,
- vector<AliHLTComponentDataType>* tgtList=NULL);
+ AliHLTComponentDataTypeList* tgtList=NULL);
/**
* Subscribe to a segment of the data buffer.
int GetNofSegments();
/**
- * Get the number of consumers
+ * Get the total number of consumers.
+ * This gives the number of consumers regardless of their state.
* @return number of consumers
*/
int GetNofConsumers();
/**
- * Get the number of active consumers
+ * Get the number of consumers which still need to be processed during
+ * the current event.
+ * @return number of consumers
+ */
+ int GetNofPendingConsumers();
+
+ /**
+ * Get the number of consumers currently under processing.
* @return number of active consumers
*/
int GetNofActiveConsumers();
int Reset();
/**
- * @struct AliHLTDataSegment
+ * @class AliHLTDataSegment
* @brief Descriptor of a data segment within the buffer.
*/
class AliHLTDataSegment {
+ friend class AliHLTDataBuffer;
+ friend class AliHLTConsumerDescriptor;
public:
AliHLTDataSegment()
:
{
memset(&fDataType, 0, sizeof(AliHLTComponentDataType));
}
+
+ private:
/** the data type of this segment */
AliHLTComponentDataType fDataType; // see above
/** offset in byte within the data buffer */
};
/**
- * @struct AliHLTRawBuffer
+ * @class AliHLTRawBuffer
* @brief Descriptor of the raw data buffer which can host several segments.
*/
class AliHLTRawBuffer {
public:
/** standard constructor */
AliHLTRawBuffer() : fSize(0), fTotalSize(0), fPtr(NULL) {}
- /** not a valid copy constructor, defined according to effective C++ style */
- AliHLTRawBuffer(const AliHLTRawBuffer&) : fSize(0), fTotalSize(0), fPtr(NULL) {}
- /** not a valid assignment op, but defined according to effective C++ style */
- AliHLTRawBuffer& operator=(const AliHLTRawBuffer&) {return *this;}
- /** standard destructor */
- virtual ~AliHLTRawBuffer() {}
+ /** constructor */
+ AliHLTRawBuffer(AliHLTUInt32_t size);
+ /** destructor */
+ virtual ~AliHLTRawBuffer();
+
+ /**
+ * Use a fraction of the buffer.
+ * @param size size in bytes to be used
+ * @return pointer to buffer
+ */
+ AliHLTUInt8_t* UseBuffer(AliHLTUInt32_t size);
+
+ /**
+ * Check whether buffer fits for a request.
+ * @param size size of the request in bytes
+ * @return 1 if buffer is big enough, 0 if not
+ */
+ int CheckSize(AliHLTUInt32_t size) const;
+
+ /**
+ * Get used size of the buffer
+ */
+ AliHLTUInt32_t GetUsedSize() const {return fSize;}
+
+ /**
+ * Get total size of the buffer
+ */
+ AliHLTUInt32_t GetTotalSize() const {return fTotalSize;}
+
+ /**
+ * Get pointer of data buffer
+ */
+ AliHLTUInt8_t* GetPointer() const {return fPtr;}
+
+ /**
+ * Write check pattern
+ */
+ int WritePattern(const char* pattern, int size);
+
+ /**
+ * Check pattern
+ */
+ int CheckPattern(const char* pattern, int size) const;
+
+ /**
+ * Reset buffer.
+ * Data buffer remains allocated, used size set to 0
+ */
+ int Reset();
+
+ int operator==(void*) const;
+ int operator==(AliHLTUInt8_t* ptr) const {return fPtr==ptr;}
+ int operator<=(void*) const;
+ int operator>(void*) const;
+ int operator-(void*) const;
+
+ operator void*() const {return fPtr;}
+ operator AliHLTUInt8_t*() const {return fPtr;}
+
+ private:
+ /** copy constructor prohibited */
+ AliHLTRawBuffer(const AliHLTRawBuffer&);
+ /** assignment operator prohibited */
+ AliHLTRawBuffer& operator=(const AliHLTRawBuffer&);
+
/** size of the currently occupied partition of the buffer */
AliHLTUInt32_t fSize; // see above
/** total size of the buffer, including safety margin */
AliHLTUInt32_t fTotalSize; // see above
/** the buffer */
- void* fPtr; //! transient
+ AliHLTUInt8_t* fPtr; //! transient
};
private:
+ /** copy constructor prohibited */
+ AliHLTDataBuffer(const AliHLTDataBuffer&);
+ /** assignment operator prohibited */
+ AliHLTDataBuffer& operator=(const AliHLTDataBuffer&);
+
/* lets see if this is needed
AliHLTDataSegment* FindDataSegment(AliHLTComponentDataType datatype);
*/
vector<AliHLTDataSegment> fSegments; // see above
// the list of all consumers which are going to subscribe to the buffer
- vector<AliHLTConsumerDescriptor*> fConsumers; // see above
+ AliHLTConsumerDescriptorPList fConsumers; // see above
// the list of all consumers which are currently subscribed to the buffer
- vector<AliHLTConsumerDescriptor*> fActiveConsumers; // see above
+ AliHLTConsumerDescriptorPList fActiveConsumers; // see above
// the list of all consumers which are already released for the current event
- vector<AliHLTConsumerDescriptor*> fReleasedConsumers; // see above
+ AliHLTConsumerDescriptorPList fReleasedConsumers; // see above
// the buffer instance
AliHLTRawBuffer* fpBuffer; //! transient
* @param list list where to search for the consumer
*/
AliHLTConsumerDescriptor* FindConsumer(const AliHLTComponent* pConsumer,
- vector<AliHLTConsumerDescriptor*> &list) const;
+ AliHLTConsumerDescriptorPList &list) const;
/**
* Change the state of a consumer.
* @param tgtList list where to move the consumer
*/
int ChangeConsumerState(AliHLTConsumerDescriptor* pDesc,
- vector<AliHLTConsumerDescriptor*> &srcList,
- vector<AliHLTConsumerDescriptor*> &tgtList);
+ AliHLTConsumerDescriptorPList &srcList,
+ AliHLTConsumerDescriptorPList &tgtList);
/**
* Cleanup a consumer list.