]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponentHandler.h
reverting r45444 to disentangle modules and make porting possible
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponentHandler.h
index 1f8bc99a7ea95265acc055ba4fb3b3bb9d34b998..149aa82fd8bcce6e74912c4c29c8cb9773bfaf45 100644 (file)
@@ -1,18 +1,18 @@
 //-*- Mode: C++ -*-
-// @(#) $Id$
+// $Id$
 
 #ifndef ALIHLTCOMPONENTHANDLER_H
 #define ALIHLTCOMPONENTHANDLER_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice                               */
+//* 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   AliHLTComponentHandler.h
-    @author Matthias Richter, Timm Steinbeck
-    @date   
-    @brief  Global handling of HLT processing components
-    @note   The handler is part of the interface and both used in the
-            Online (PubSub) and Offline (AliRoot) context.
-                                                                          */
+/// @file   AliHLTComponentHandler.h
+/// @author Matthias Richter, Timm Steinbeck
+/// @date   
+/// @brief  Global handling of HLT processing components
+/// @note   The handler is part of the interface and both used in the
+///         Online (PubSub) and Offline (AliRoot) context.
 
 // see below for class documentation
 // or
 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt   
 
 #include <vector>
+#include <utility>
 //#include "TObject.h"
 #include "AliHLTDataTypes.h"
 #include "AliHLTLogging.h"
 
 class AliHLTComponent;
 class AliHLTModuleAgent;
-struct AliHLTComponentEnvironment;
+struct AliHLTAnalysisEnvironment;
 struct AliHLTComponentDataType;
 
 /**
@@ -41,10 +42,22 @@ class AliHLTComponentHandler : public AliHLTLogging {
   /** standard constructor */
   AliHLTComponentHandler();
   /** constructor */
-  AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv);
+  AliHLTComponentHandler(AliHLTAnalysisEnvironment* pEnv);
   /** destructor */
   virtual ~AliHLTComponentHandler();
 
+  /**
+   * Create an instance from the global sigleton.
+   * Instance has to be destroyed by the Destroy function
+   */
+  static AliHLTComponentHandler* CreateHandler();
+
+  /**
+   * Destroy an instance of the global singleton retrieved by
+   * AliHLTComponentHandler::CreateHandler()
+   */
+  int Destroy();
+
   /**
    * Library mode.
    * - kDynamic: library can be unloaded (unload forced at termination of the
@@ -58,16 +71,21 @@ class AliHLTComponentHandler : public AliHLTLogging {
    * The environment mainly consists of function pointers for the integration
    * of the HLT framework into a system like the PubSub online system or
    * AliRoot offline system.
-   * @param pEnv    pointer to @ref AliHLTComponentEnvironment structure
+   * @param pEnv    pointer to @ref AliHLTAnalysisEnvironment structure
    * @return none
    */
-  void SetEnvironment(AliHLTComponentEnvironment* pEnv);
+  void SetEnvironment(AliHLTAnalysisEnvironment* pEnv);
+
+  /**
+   * Get the current environment.
+   */
+  const AliHLTAnalysisEnvironment* GetEnvironment() const {return &fEnvironment;}
 
   /**
    * Set library mode.
    * The mode effects all loaded libraries until another mode is set.
    * @param mode             persistent library or not
-   * @param previous mode
+   * @return previous mode
    */
   TLibraryMode SetLibraryMode(TLibraryMode mode);
 
@@ -85,13 +103,18 @@ class AliHLTComponentHandler : public AliHLTLogging {
    */
   int LoadLibrary( const char* libraryPath, int bActivateAgents=1);
 
+  /**
+   * Load external library dependencies defined in a static array.
+   */
+  int LoadDependencies( const char* libraryPath);
+
   /**
    * Find a symbol in a dynamically loaded library.
    * @param library      library
    * @param symbol       the symbol to find
    * @return void pointer to function
    */
-  void* FindSymbol(const char* library, const char* symbol);
+  AliHLTfctVoid FindSymbol(const char* library, const char* symbol);
 
   /**
    * Unload a component shared library.
@@ -182,7 +205,14 @@ class AliHLTComponentHandler : public AliHLTLogging {
    * @return component pointer in component, neg. error code if failed
    */
   int CreateComponent( const char* componentID, void* pEnvParam, 
-                      int argc, const char** argv, AliHLTComponent*& component );
+                      int argc, const char** argv, AliHLTComponent*& component);
+
+  /**
+   * Create component without initializing it.
+   * @param componentID  ID of the component to create
+   * @param component    reference to receive the create component instance
+   */
+  int CreateComponent(const char* componentID, AliHLTComponent*& component );
 
   /**
    * Create a component of the given name (ID).
@@ -198,6 +228,18 @@ class AliHLTComponentHandler : public AliHLTLogging {
     return CreateComponent( componentID, pEnvParam, 0, NULL, component );
     }
 
+  /**
+   * Set the run description.
+   * The run description is set globally for all components. Each component
+   * is initialized from the global run description after creation and before
+   * call of AliHLTComponent::Init().
+   *
+   * @param desc    run descriptor, currently only the run no member is used
+   * @param runType originally, run type was supposed to be a number and part
+   *                of the run descriptor. But it was defined as string later
+   */
+  int SetRunDescription(const AliHLTRunDesc* desc, const char* runType);
+
   /**
    * Check if a registered component has output data, e.g. is of type
    * kSource or kProcessor (see @ref AliHLTComponent::TComponentType).
@@ -259,16 +301,21 @@ class AliHLTComponentHandler : public AliHLTLogging {
    * each agent with this component handler. During activation, the
    * dynamic component registration is carried out by the agents version
    * of @ref AliHLTModuleAgent::RegisterComponents
-   * @param blackList     array of agents which should be excluded
-   * @param size          array size
+   *
+   * Agents are identified by an id which is a string containing the
+   * module name. Libraries follow the naming scheme libAliHLT<MOD>.so
+   * If the library name is provided and the specific agent found in the
+   * list, only that one is activated. All pending agents otherwize.
+   * @param library       library to activate the agent for
+   * @param blackList     blank separated list of module ids
    */
-  int ActivateAgents(const AliHLTModuleAgent** blackList=NULL, int size=0);
+  int ActivateAgents(const char* library=NULL, const char* blackList=NULL);
 
   /**
    * Compound descriptor for component libraries
    */
   struct AliHLTLibHandle {
-    AliHLTLibHandle() : fHandle(NULL), fName(NULL) {}
+    AliHLTLibHandle() : fHandle(NULL), fName(NULL), fMode(kDynamic) {}
     /** dlopen handle */
     void* fHandle;                                                 //! transient
     /** name of the library, casted to TString* before use */
@@ -300,13 +347,25 @@ class AliHLTComponentHandler : public AliHLTLogging {
   /** list of libraries */
   vector<AliHLTLibHandle> fLibraryList;                            // see above 
   /** running environment for the component */
-  AliHLTComponentEnvironment fEnvironment;                         // see above 
+  AliHLTAnalysisEnvironment fEnvironment;                         // see above 
   /** list of owned components, deleted at termination of the handler */
   vector<AliHLTComponent*> fOwnedComponents;                       // see above 
   /** library mode effects all loaded libraries until a new mode is set */
   TLibraryMode fLibraryMode;                                       // see above 
 
-  ClassDef(AliHLTComponentHandler, 0);
+  /** run descriptor */
+  AliHLTRunDesc fRunDesc;                                          //!transient 
+  /** run type string */
+  char* fRunType;                                                  //!transient 
+
+  /** the global singleton */
+  static AliHLTComponentHandler* fgpInstance;                      //!transient
+  /** number of used instances of the global singleton */
+  static int fgNofInstances;                                       //!transient
+  /// library dependencies
+  static const std::pair<const char*, const char*> fgkLibDep[];    //!transient
+
+  ClassDef(AliHLTComponentHandler, 2);
 
 };
 #endif