]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTTask.h
implementation of SOR and EOR events (not yet enabled), bugfix in DataBuffer: data...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTTask.h
index 5fe52da19c7398e31625e068477dd93a4e56a3e3..04e91f4aefd49f5c790cbde5e0c9b0d9a6042cd8 100644 (file)
@@ -1,61 +1,89 @@
+//-*- Mode: C++ -*-
 // $Id$
 
 #ifndef ALIHLTTASK_H
 #define ALIHLTTASK_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+/* This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
  * See cxx source for full Copyright notice                               */
 
-/** @file   AliHLTConfiguration.h
+/** @file   AliHLTTask.h
     @author Matthias Richter
     @date   
     @brief  base class for HLT tasks
 */
 
-#include <cerrno>
+// 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 <TList.h>
 #include "AliHLTDataTypes.h"
 #include "AliHLTLogging.h"
 #include "AliHLTDataBuffer.h"
 
-struct AliHLTComponent_BlockData;
+struct AliHLTComponentBlockData;
 class AliHLTComponent;
 class AliHLTComponentHandler;
+class AliHLTConfiguration;
+class AliHLTTask;
+
+typedef vector<AliHLTTask*> AliHLTTaskPList;
 
 /******************************************************************************/
 
- /**
-  * @class AliHLTTask
-  * A task collects all the information which is necessary to process a certain
-  * step in the HLT data processing chain:
-  * - the instance of the component
-  * - the data buffer which receives the result of the component and provides
-  *   the data to other tasks/components
-  * - a list of all dependencies
-  * - a list of consumers
-  * - the task object holds the configuration object 
-  */
+/**
+ * @class AliHLTTask
+ * A task collects all the information which is necessary to process a certain
+ * step in the HLT data processing chain.
+ * - the instance of the component
+ *   the task object creates and deletes the component object
+ * - the data buffer which receives the result of the component and provides
+ *   the data to other tasks/components
+ * - a list of all dependencies
+ * - a list of consumers
+ * - the task object holds an external pointer to the configuration object; 
+ *   \b Note: the configuration object must exist through the existence of the
+ *   task object!!!
+ *  
+ *
+ * @note This class is only used for the @ref alihlt_system.
+ *
+ * @ingroup alihlt_system
+ */
 class AliHLTTask : public TObject, public AliHLTLogging {
  public:
   /** standard constructor */
   AliHLTTask();
   /** constructor 
       @param pConf pointer to configuration descriptor
-      @param pCH   the HLT component handler
    */
-  AliHLTTask(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH);
+  AliHLTTask(AliHLTConfiguration* pConf);
   /** destructor */
   virtual ~AliHLTTask();
 
   /**
    * Initialize the task.
    * The task is initialized with a configuration descriptor. It needs a
-   * component handler instance to create the analysis component.
-   * @param pConf pointer to configuration descriptor
+   * component handler instance to create the analysis component. The
+   * component is created and initialized.
+   * @param pConf pointer to configuration descriptor, can be NULL if it
+   *              was already provided to the constructor
    * @param pCH   the HLT component handler
    */
   int Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH);
 
+  /**
+   * De-Initialize the task.
+   * Final cleanup after the run. The @ref AliHLTComponent::Deinit method of
+   * the component is called. The analysis component is deleted.
+   */
+  int Deinit();
+
   /**
    * Get the name of the object.
    * This is an overridden TObject function in order to return the configuration
@@ -87,18 +115,6 @@ class AliHLTTask : public TObject, public AliHLTLogging {
    */
   AliHLTTask* FindDependency(const char* id);
 
-  /*
-   * insert block data to the list
-   * the data has to come from a task the current one depends on
-   * result:
-   *    -EEXIST : the block data from this task has already been inserted
-   *    -ENOENT : no dependencies to the task the data is coming from
-   */
-  /*
-   * this function is most likely depricated
-  int InsertBlockData(AliHLTComponent_BlockData* pBlock, AliHLTTask* pSource);
-  */
-
   /**
    * Add a dependency for the task.
    * The task maintains a list of other tasks it depends on.
@@ -109,6 +125,14 @@ class AliHLTTask : public TObject, public AliHLTLogging {
    */
   int SetDependency(AliHLTTask* pDep);
 
+  /**
+   * Clear a dependency.
+   * The ROOT TList touches the object which is in the list, even though
+   * it shouldn't care about. Thats why all lists have to be cleared before
+   * objects are deleted.
+   */
+  int UnsetDependency(AliHLTTask* pDep);
+
   /**
    * Return number of unresolved dependencies.
    * Iterate through all the configurations the task depends on and check
@@ -142,27 +166,26 @@ class AliHLTTask : public TObject, public AliHLTLogging {
    */
   int SetTarget(AliHLTTask* pDep);
 
-  // build a monolithic array of block data
-  // @param pBlockData reference to the block data target
-  // @return: array size, pointer to array in the target pTgt
-  //
-  /* this function is most likely depricated
-  int BuildBlockDataArray(AliHLTComponent_BlockData*& pBlockData);
-  */
+  /**
+   * Clear a target.
+   * The ROOT TList touches the object which is in the list, even though
+   * it shouldn't care about. Thats why all lists have to be cleared before
+   * objects are deleted.
+   */
+  int UnsetTarget(AliHLTTask* pTarget);
 
   /**
    * Prepare the task for event processing.
    * The method initializes the Data Buffer and calls the
    * @ref AliHLTComponent::Init method of the component.<br>
-   * The @ref ProcessTask methode can be called an arbitrary number of times
+   * The @ref ProcessTask method can be called an arbitrary number of times
    * as soon as the task is in <i>running</i> mode. 
    */
   int StartRun();
 
   /**
    * Clean-up the task after event processing.
-   * The method cleans up internal structures and calls the
-   * @ref AliHLTComponent::Deinit method of the component.
+   * The method cleans up internal structures.
    */
   int EndRun();
 
@@ -174,14 +197,7 @@ class AliHLTTask : public TObject, public AliHLTLogging {
    * processing, the data blocks are released. <br>
    * The @ref StartRun method must be called before.
    */
-  int ProcessTask();
-
-  // clear the list of source data blocks
-  // the list of source data blocks has to be cleared at the beginning of 
-  // a new event
-  /* this function is most likely depricated
-  int ClearSourceBlocks();
-  */
+  int ProcessTask(Int_t eventNo);
 
   /**
    * Determine the number of matching data block between the component and the
@@ -191,7 +207,7 @@ class AliHLTTask : public TObject, public AliHLTLogging {
    * @param pConsumerTask   the task which subscribes to the data
    * @return number of matching data blocks
    */
-  int GetNofMatchingDataBlocks(const AliHLTTask* pConsumerTask);
+  int GetNofMatchingDataBlocks(const AliHLTTask* pConsumerTask) const;
 
   /**
    * Determine the number of matching data types between the component and a
@@ -200,7 +216,7 @@ class AliHLTTask : public TObject, public AliHLTLogging {
    * @param pConsumerTask   the task which subscribes to the data
    * @return number of matching data types
    */
-  int GetNofMatchingDataTypes(const AliHLTTask* pConsumerTask);
+  int GetNofMatchingDataTypes(const AliHLTTask* pConsumerTask) const;
 
   /**
    * Subscribe to the data of a source task.
@@ -210,12 +226,10 @@ class AliHLTTask : public TObject, public AliHLTLogging {
    * returns the number of blocks which would be prepared in case the target
    * array is big enough.
    * @param pConsumerTask   the task which subscribes to the data
-   * @param arrayBlockDesc  pointer to block descriptor to be filled
-   * @param iArraySize      size of the block descriptor array
+   * @param blockDescList   block descriptor list to be filled
    * @return number of matching data blocks, negative error code if failed
    */
-  int Subscribe(const AliHLTTask* pConsumerTask,
-               AliHLTComponent_BlockData* arrayBlockDesc, int iArraySize);
+  int Subscribe(const AliHLTTask* pConsumerTask, AliHLTComponentBlockDataList& blockDescList);
 
   /**
    * Release a block descriptor.
@@ -224,7 +238,7 @@ class AliHLTTask : public TObject, public AliHLTLogging {
    * @param pConsumerTask   the task which subscribed to the data
    * @return: >0 if success, negative error code if failed
    */
-  int Release(AliHLTComponent_BlockData* pBlockDesc,
+  int Release(AliHLTComponentBlockData* pBlockDesc,
              const AliHLTTask* pConsumerTask);
 
   /**
@@ -258,30 +272,33 @@ class AliHLTTask : public TObject, public AliHLTLogging {
    * Get number of source tasks.
    * @return number of source tasks
    */
-  int GetNofSources() {return fListDependencies.GetSize();}
+  int GetNofSources() const {return fListDependencies.GetSize();}
 
  private:
-  /** the configuration descriptor */
-  AliHLTConfiguration* fpConfiguration;
-  /** the component described by this task */
-  AliHLTComponent* fpComponent;
+  /** prohibited copy constructor */
+  AliHLTTask(const AliHLTTask&);
+  /** prohibited assignment operator */
+  AliHLTTask& operator=(const AliHLTTask&);
+
+  /** the configuration descriptor (external pointer) */
+  AliHLTConfiguration* fpConfiguration;                           //! transient
+  /** the component described by this task (created and deleted internally) */
+  AliHLTComponent* fpComponent;                                   //! transient
   /** the data buffer for the component processing */
-  AliHLTDataBuffer* fpDataBuffer;
+  AliHLTDataBuffer* fpDataBuffer;                                 //! transient
   /** the list of targets (tasks which depend upon the current one) */
-  TList fListTargets;
+  TList fListTargets;                                             // see above
   /** the list of sources (tasks upon which the current one depends) */ 
-  TList fListDependencies;
+  TList fListDependencies;                                        // see above
 
   /**
    * block data array to be passed as argument to the 
    * @ref AliHLTComponent::ProcessEvent method. 
    * Filled through subscription to source tasks (@ref Subscribe).
    */
-  AliHLTComponent_BlockData* fpBlockDataArray;
-  /** size of the block data array */
-  int fBlockDataArraySize;
+  vector<AliHLTComponentBlockData> fBlockDataArray;               //! transient
 
-  ClassDef(AliHLTTask, 0);
+  ClassDef(AliHLTTask, 2);
 };
 
 #endif