]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTDataBuffer.h
fix for 64bit architectures after last commit
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDataBuffer.h
index b503acb2fd041f87ffc9dadb821b5bb4b7cd59de..672e6e643298db0f19ee2073128f17689cada18d 100644 (file)
     @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 "AliHLTLogging.h"
 #include "AliHLTDataTypes.h"
-//#include "AliHLTDefinitions.h"
 #include "TObject.h"
-//#include "TList.h"
 
 class AliHLTComponent;
 class AliHLTConsumerDescriptor;
@@ -49,10 +53,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();
 
@@ -161,13 +161,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();
@@ -193,6 +201,8 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging
    * @brief  Descriptor of a data segment within the buffer.
    */
   class AliHLTDataSegment {
+  friend class AliHLTDataBuffer;
+  friend class AliHLTConsumerDescriptor;
   public:
     AliHLTDataSegment()
       :
@@ -212,6 +222,7 @@ 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 */
@@ -230,21 +241,85 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging
   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);
   */