X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HLT%2FBASE%2FAliHLTDataBuffer.h;h=8fce7598c6122e2f35a077674af07eda1da19cda;hb=62bb3cd4f3cd3538739ebe2456896b0b4132a446;hp=5bba4074dbd8e5ed5ef410fe7ac18d1f3fa10729;hpb=90ebac254452087aac5949b630ca6e42949503d4;p=u%2Fmrichter%2FAliRoot.git diff --git a/HLT/BASE/AliHLTDataBuffer.h b/HLT/BASE/AliHLTDataBuffer.h index 5bba4074dbd..8fce7598c61 100644 --- a/HLT/BASE/AliHLTDataBuffer.h +++ b/HLT/BASE/AliHLTDataBuffer.h @@ -12,17 +12,23 @@ @note The class is used in Offline (AliRoot) context */ -#include +// see below for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + #include +#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 AliHLTConsumerDescriptorPList; + /** * @class AliHLTDataBuffer * @brief Handling of data buffers for the HLT. @@ -50,10 +56,6 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging /* 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(); @@ -81,7 +83,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * -EINVAL invalid parameter
*/ int FindMatchingDataBlocks(const AliHLTComponent* pConsumer, - vector* tgtList=NULL); + AliHLTComponentDataTypeList* tgtList=NULL); /** * Subscribe to a segment of the data buffer. @@ -162,13 +164,21 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging 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(); @@ -190,10 +200,13 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging int Reset(); /** - * @struct AliHLTDataSegment + * @class AliHLTDataSegment * @brief Descriptor of a data segment within the buffer. */ - struct AliHLTDataSegment { + class AliHLTDataSegment { + friend class AliHLTDataBuffer; + friend class AliHLTConsumerDescriptor; + public: AliHLTDataSegment() : fDataType(), @@ -212,6 +225,8 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging { memset(&fDataType, 0, sizeof(AliHLTComponentDataType)); } + + private: /** the data type of this segment */ AliHLTComponentDataType fDataType; // see above /** offset in byte within the data buffer */ @@ -223,19 +238,92 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging }; /** - * @struct AliHLTRawBuffer + * @class AliHLTRawBuffer * @brief Descriptor of the raw data buffer which can host several segments. */ - struct AliHLTRawBuffer { + class AliHLTRawBuffer { + public: + /** standard constructor */ + AliHLTRawBuffer() : fSize(0), fTotalSize(0), fPtr(NULL) {} + /** 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); */ @@ -266,11 +354,11 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging vector fSegments; // see above // the list of all consumers which are going to subscribe to the buffer - vector fConsumers; // see above + AliHLTConsumerDescriptorPList fConsumers; // see above // the list of all consumers which are currently subscribed to the buffer - vector fActiveConsumers; // see above + AliHLTConsumerDescriptorPList fActiveConsumers; // see above // the list of all consumers which are already released for the current event - vector fReleasedConsumers; // see above + AliHLTConsumerDescriptorPList fReleasedConsumers; // see above // the buffer instance AliHLTRawBuffer* fpBuffer; //! transient @@ -342,7 +430,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * @param list list where to search for the consumer */ AliHLTConsumerDescriptor* FindConsumer(const AliHLTComponent* pConsumer, - vector &list) const; + AliHLTConsumerDescriptorPList &list) const; /** * Change the state of a consumer. @@ -353,8 +441,8 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * @param tgtList list where to move the consumer */ int ChangeConsumerState(AliHLTConsumerDescriptor* pDesc, - vector &srcList, - vector &tgtList); + AliHLTConsumerDescriptorPList &srcList, + AliHLTConsumerDescriptorPList &tgtList); /** * Cleanup a consumer list.