]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTDataBuffer.h
code documentation; minor enhancement of BlockFilter
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDataBuffer.h
index 0e3702b308320b0c14ae3bd4c7673b0ff9dafb74..e7823c4c1d6243f57892586b5a8535d41dd772d5 100644 (file)
 #include "AliHLTComponent.h"
 
 class AliHLTConsumerDescriptor;
+class AliHLTTask;
 
 /** list of AliHLTConsumerDescriptor pointers */
 typedef vector<AliHLTConsumerDescriptor*> AliHLTConsumerDescriptorPList;
 
+typedef AliHLTUInt8_t* AliHLTUInt8Pointer_t;
+
 /**
  * @class AliHLTDataBuffer
  * @brief  Handling of data buffers for the HLT.
@@ -94,8 +97,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging
    * would have been prepared if there was enough space in the array<br>
    * The method is used by the consumer component.
    * @param pConsumer       the component which subscribes to the buffer
-   * @param arrayBlockDesc  pointer to block descriptor to be filled
-   * @param iArraySize      size of the block descriptor array
+   * @param blockDescList   block descriptor vector to be filled
    * @return: number of matching data blocks, neg. error code if failed<br>
    *          -EACCESS      the consumer state can't be changed (activated)
    *          -EBADF        unresolved data segments <br>
@@ -104,8 +106,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging
    *          -EINVAL       invalid parameter <br>
    */
   int Subscribe(const AliHLTComponent* pConsumer,
-               AliHLTComponentBlockData* arrayBlockDesc,
-               int iArraySize);
+               AliHLTComponentBlockDataList& blockDescList);
 
   /**
    * Release an instance of the data buffer.
@@ -115,12 +116,24 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging
    * The method is used by the consumer component.
    * @param pBlockDesc      descriptor of the data segment
    * @param pConsumer       the component which subscribes to the buffer
+   * @param pOwnerTask      task owning this buffer
    * @return: >0 if success, negative error code if failed <br>
    *          -EACCESS      the consumer state can not be changed (de-activated)
    *          -ENOENT       consumer has not subscribed to the buffer <br>
    *          -EINVAL       invalid parameter <br>
    */
-  int Release(AliHLTComponentBlockData* pBlockDesc, const AliHLTComponent* pConsumer);
+  int Release(AliHLTComponentBlockData* pBlockDesc, const AliHLTComponent* pConsumer,
+             const AliHLTTask* pOwnerTask);
+
+  /**
+   * Register an input data block for forwarding.
+   * Consumer of this data buffer subscribe to forwarded data blocks in te same way.
+   * Forwarded data blocks are released when the last consumer has released the
+   * blocks.
+   * @param pSrcTask        original source task of the data block
+   * @param pBlockDesc      descriptor of the data segment
+   */
+  int Forward(AliHLTTask* pSrcTask, AliHLTComponentBlockData* pBlockDesc);
 
   /**
    * Get a target buffer of minimum size iMinSize.
@@ -211,31 +224,64 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging
    * @brief  Descriptor of a data segment within the buffer.
    */
   class AliHLTDataSegment {
-  friend class AliHLTDataBuffer;
-  friend class AliHLTConsumerDescriptor;
+    friend class AliHLTDataBuffer;
+    friend class AliHLTConsumerDescriptor;
   public:
     AliHLTDataSegment()
       :
-      fDataType(),
+      fDataType(kAliHLTVoidDataType),
+      fPtr(NULL),
       fSegmentOffset(0),
       fSegmentSize(0),
       fSpecification(0)
     {
-      memset(&fDataType, 0, sizeof(AliHLTComponentDataType));
     }
-    AliHLTDataSegment(AliHLTUInt32_t offset, AliHLTUInt32_t size) 
+
+    AliHLTDataSegment(AliHLTUInt8_t* ptr, AliHLTUInt32_t offset, AliHLTUInt32_t size) 
+      :
+      fDataType(kAliHLTVoidDataType),
+      fPtr(ptr),
+      fSegmentOffset(offset),
+      fSegmentSize(size),
+      fSpecification(0)
+    {
+    }
+
+    AliHLTDataSegment(void* ptr, AliHLTUInt32_t offset, AliHLTUInt32_t size) 
       :
-      fDataType(),
+      fDataType(kAliHLTVoidDataType),
+      fPtr((AliHLTUInt8_t*)ptr),
       fSegmentOffset(offset),
       fSegmentSize(size),
       fSpecification(0)
     {
-      memset(&fDataType, 0, sizeof(AliHLTComponentDataType));
     }
 
+    AliHLTDataSegment(void* ptr, AliHLTUInt32_t offset, AliHLTUInt32_t size, AliHLTComponentDataType dt, AliHLTUInt32_t spec)
+      :
+      fDataType(dt),
+      fPtr((AliHLTUInt8_t*)ptr),
+      fSegmentOffset(offset),
+      fSegmentSize(size),
+      fSpecification(spec)
+    {
+    }
+
+    AliHLTUInt8_t* GetPtr() const {return (AliHLTUInt8_t*)*this;}
+
+    AliHLTUInt32_t GetSize() const {return fSegmentSize;}
+    
+    int operator==(const AliHLTDataSegment& seg) const
+    {
+      return (fPtr+fSegmentOffset==seg.fPtr+seg.fSegmentOffset) && (fSegmentSize==seg.fSegmentSize);
+    }
+    operator AliHLTUInt8_t*() const {return fPtr+fSegmentOffset;}
+
   private:
     /** the data type of this segment */
     AliHLTComponentDataType fDataType;                             // see above
+    /** pointer to the buffer */
+    AliHLTUInt8Pointer_t fPtr;                                     //!transient
     /** offset in byte within the data buffer */
     AliHLTUInt32_t fSegmentOffset;                                 // see above
     /** size of the actual content */
@@ -373,6 +419,12 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging
   // flags indicating the state of the buffer
   AliHLTUInt32_t fFlags;                                           // see above
 
+  /** list of tasks with forwarded data blocks */
+  vector<AliHLTTask*> fForwardedSegmentSources;                    //! transient
+
+  /** list of forwarded block descriptors */
+  vector<AliHLTDataSegment> fForwardedSegments;                    //! transient
+
   //////////////////////////////////////////////////////////////////////////////
   // global buffer handling, internal use only