]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTModuleAgent.h
Minor cleanup of code.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTModuleAgent.h
index 5d4b8f17356c8461b16c005f5720467e8427ac0e..1d89054e0ff8832e9e6ef6551467d0b4b610f4e2 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <TObject.h>
 #include <TList.h>
+#include <TString.h>
 #include "AliHLTLogging.h"
 #include "AliHLTConfiguration.h"
 #include "AliHLTConfigurationHandler.h"
@@ -32,6 +33,7 @@ class AliRawReader;
 class AliRawStream;
 class AliHLTOUTHandler;
 class AliHLTOUT;
+class AliHLTModulePreprocessor;
 
 /**
  * @class AliHLTModuleAgent
@@ -96,12 +98,6 @@ class AliHLTOUT;
  *       Return AliHLTOUTHandler for a given data type and specification.
  *       This is mainly intended to treat detector proprietary data.
  *
- * - @ref GetRawStream                                                      <br>
- *       Return an AliRawStream object which is capable of treating the
- *       specified data type and specification. Rawstream must be provided
- *       for data blocks intended to be the input for AliRoot detector
- *       reconstruction by replacing the normal input stream.
- *
  * @section alihltmoduleagent_references References
  * @see @ref AliHLTReconstructor interface to the AliRoot reconstruction
  * @see @ref AliHLTAgentSample agent for the libAliHLTSample library
@@ -114,10 +110,18 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging {
    * standard constructor. The agent is automatically registered in the
    * global agent manager
    */
-  AliHLTModuleAgent();
+  AliHLTModuleAgent(const char* id);
   /** destructor */
   virtual ~AliHLTModuleAgent();
 
+  /**
+   * Get module id.
+   * The module id is a string specifying the detector, or module. The
+   * library must follow the naming scheme \em libAliHLTModule.so, e.g.
+   * \em libAliHLTTPC.so if the module is 'TPC'
+   */
+  const char* GetModuleId() const;
+
   /**
    * Print status info.
    * Short summary on registered agents. This function acts globally on the
@@ -210,12 +214,32 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging {
    */
   enum AliHLTOUTHandlerType {
     kUnknownOutput =0,
+
     /** output is in ESD format */
     kEsd,
-    /** agent can create a raw stream */
-    kRawstream,
-    /** agent provides a chain */
+
+    /** agent provides data for a RawReader
+     * From the data block one or more output blocks can be
+     * created idenditcal to the ddl format. The blocks are
+     * provided to subsequent analysis by a RawReader instance.
+     * The data block can be processed in order to provide the
+     * raw data, e.g. in case of lossless compression.
+     */
+    kRawReader,
+
+    /** agent can create a raw stream
+     * The agent directly generates a detector specific RawStream
+     * object. This is used for pre-analyzed data which will not
+     * be converted back to the raw format.
+     */
+    kRawStream,
+
+    /** agent provides a chain
+     * The data bock is fed into an analysis chain, the treatment
+     * depends on the components in the chain.
+     */
     kChain,
+
     /** agent provides detector specific handler */
     kProprietary,
     kLastOutputHandler
@@ -224,19 +248,44 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging {
   /**
    * Output handler description.
    * \em fModule: module name specific for the handler type
-   *              - kRawStream: class name of the Rawstream class
+   *              - kRawReader: DDL no printed in ascii format
+   *              - kRawStream: class name of the RawStream class
    *              - kChain:     blank separated list of chains
    *              - kProprietary: name of the handler class
    */
-  struct AliHLTOUTHandlerDesc {
+  class AliHLTOUTHandlerDesc {
+  public:
+    AliHLTOUTHandlerDesc() : fHType(kUnknownOutput), fDt(kAliHLTVoidDataType), fModule() {}
+
+    AliHLTOUTHandlerDesc(AliHLTOUTHandlerType handlerType, AliHLTComponentDataType dt, const char* module) 
+      : fHType(handlerType), fDt(dt), fModule(module) {}
+
+    AliHLTOUTHandlerDesc(const AliHLTOUTHandlerDesc& src) 
+      : fHType(src.fHType), fDt(src.fDt), fModule(src.fModule) {}
+
+    const AliHLTOUTHandlerDesc& operator=(const AliHLTOUTHandlerDesc& src) {
+      fHType=src.fHType; fDt=src.fDt; fModule=src.fModule; return *this;
+    }
+
+    ~AliHLTOUTHandlerDesc() {}
+
+    bool operator==(const AliHLTOUTHandlerType handlerType) const {
+      return fHType==handlerType;
+    }
+    operator AliHLTOUTHandlerType() {return fHType;}
+    operator AliHLTComponentDataType() {return fDt;}
+
+  private:
     /** type of the handler */
-    AliHLTOUTHandlerType    fHType;
+    AliHLTOUTHandlerType    fHType;                          //!transient
     /** data type treated by the handler */
-    AliHLTComponentDataType fDt;
+    AliHLTComponentDataType fDt;                             //!transient
     /** class or chain name */
-    const char*             fModule;
+    TString                 fModule;                         //!transient
   };
 
+  static const AliHLTOUTHandlerDesc fgkVoidHandlerDesc; //! initializer
+
   /**
    * Get handler description for a data block.
    * @param dt        [in] data type of the block
@@ -247,13 +296,32 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging {
   virtual int GetHandlerDescription(AliHLTComponentDataType dt,
                                    AliHLTUInt32_t spec,
                                    AliHLTOUTHandlerDesc& desc) const;
+
   /**
    * Get handler for a data block of the HLTOUT data.
+   * The agent can also provide an overloaded @ref DeleteOutputHandler
+   * function to implement customized clean up. It is also possible to
+   * return the same instance of a handler for different data blocks.<br>
+   *
+   * The framework first collects the handlers for all data blocks, and
+   * calls the @ref AliHLTOUTHandler::ProcessData method afterwords for
+   * each handler.
    * @param dt        [in] data type of the block
    * @param spec      [in] specification of the block
+   * @return pointer to handler
    */
   virtual AliHLTOUTHandler* GetOutputHandler(AliHLTComponentDataType dt,
-                                            AliHLTUInt32_t spec) const;
+                                            AliHLTUInt32_t spec);
+
+  /**
+   * Delete an HLTOUT handler.
+   * Even if the agent returned the handler several times, this is the
+   * final cleanup. The framwork makes sure that the handler is not
+   * used any further outside the agent. The default implementation just
+   * deltetes the object.
+   * @param pInstance      pointer to handler
+   */
+  virtual int DeleteOutputHandler(AliHLTOUTHandler* pInstance);
 
   /**
    * Get raw stream for a data block.
@@ -262,9 +330,19 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging {
    * @param pData     [in] data control object
    * @return Rawstream object, NULL if no Rawstream available for data type/spec
    */
-  virtual AliRawStream* GetRawStream(AliHLTComponentDataType dt,
-                                    AliHLTUInt32_t spec,
-                                    const AliHLTOUT* pData) const;
+  // this method is likely to be moved to a specific implementation
+  // of AliHLTOUTHandler
+//   virtual AliRawStream* GetRawStream(AliHLTComponentDataType dt,
+//                                  AliHLTUInt32_t spec,
+//                                  const AliHLTOUT* pData);
+
+  /**
+   * Get the preprocessor for this component library.
+   * Create an instance of the preprocessor for this component library.
+   * The caller will delete it after useage.
+   * @return pointer to AliHLTModulePreprocessor object.
+   */
+  virtual AliHLTModulePreprocessor* GetPreprocessor();
 
   /**
    * Old method kept for backward compatibility, redirected to @ref
@@ -277,6 +355,8 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging {
  protected:
 
  private:
+  /** standard constructor prohibited */
+  AliHLTModuleAgent();
   /** copy constructor prohibited */
   AliHLTModuleAgent(const AliHLTModuleAgent&);
   /** assignment operator prohibited */
@@ -295,21 +375,24 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging {
   static int Unregister(AliHLTModuleAgent* pAgent);
 
   /** the list of active agents */
-  static AliHLTModuleAgent* fAnchor;                               //! transient
+  static AliHLTModuleAgent* fgAnchor;                               //! transient
 
   /** next element in the list */
   AliHLTModuleAgent* fpNext;                                       //! transient
 
   /** the current object link (list position) */
-  static AliHLTModuleAgent* fCurrent;                              //! transient
+  static AliHLTModuleAgent* fgCurrent;                              //! transient
 
   /** number of agents */
-  static int fCount;                                               //! transient
+  static int fgCount;                                               //! transient
 
-  /* instance of the active component handler */
+  /** instance of the active component handler */
   AliHLTComponentHandler* fpComponentHandler;                      //! transient
 
-  ClassDef(AliHLTModuleAgent, 2);
+  /** id of the module */
+  TString fModuleId;                                               //! transient
+
+  ClassDef(AliHLTModuleAgent, 3);
 };
 
 #endif