]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTConfiguration.h
set owner for tlist
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTConfiguration.h
index 02c9527cca9c449314ada2c32aa474b17e739572..6623dd37598767fcdf843b0a8eceebe39e293c10 100644 (file)
-// @(#) $Id$
+//-*- Mode: C++ -*-
+// $Id$
 
 #ifndef ALIHLTCONFIGURATION_H
 #define ALIHLTCONFIGURATION_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                               *
 
-/* AliHLTConfiguration
-   base class for HLT configurations
- */
+/// @file   AliHLTConfiguration.h
+/// @author Matthias Richter
+/// @date   
+/// @brief  HLT configuration description for a single component.
+/// @note   The class is used in Offline (AliRoot) context
 
-#include <errno.h>
+#include <vector>
 #include <TObject.h>
 #include <TList.h>
 #include "AliHLTDataTypes.h"
 #include "AliHLTLogging.h"
+#include "AliHLTDataBuffer.h"
 
+class AliHLTConfigurationHandler;
 
-/*****************************************************************************************************
+/**
+ * @class AliHLTConfiguration
+ * @brief Description of HLT processing chains.
+ *
+ * This class describes a configuration for an HLT component by means of
+ * the following parameters:
+ * - configuration id:      a unique id string/name
+ * - component id:          id returned by AliHLTComponent::GetComponentID()
+ * - parent configuartions: ids of configurations it requires input from
+ * - component arguments:   passed to the component when it is initialized
+ *
+ * The definition of a configuration requires simply the creation of an object
+ * of type @ref AliHLTConfiguration. 
+ * <pre>
+ * AliHLTConfiguration myprocessor("MyProcessor", "Dummy", "publisher", "-output_percentage 80")
+ * </pre>
  *
- * AliHLTConfiguration
+ * The Configuration is automatically registered in the list of available
+ * configurations maintained by the @ref AliHLTConfigurationHandler.
+ * The list is used to resolve the dependencies on other configurations.
+ * Hierarchies can be built up by specifying the configuration id of parent
+ * configurations as input in the .
+ * A configuration entry is persistent and must be explicitly removed from
+ * the AliHLTConfigurationHandler if desired.
  *
- * this class describes a certain configuration af an HLT processing step by the following parameters:
- *  - a unique id string/name
- *  - the id of the component
- *  - the ids of the configurations it requires input from
- *  - the arguments, which are passed to the component when it is initialized
+ * The registration mechanism requires the HLT system to be available. The
+ * global instance of AliHLTSystem is created and retrieved by
+ * <pre>
+ *   // setup the HLT system
+ *   AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
+ * </pre>
  *
- * The setup of a configuration requires simply the creation of a global object of class AliHLTConfiguration.
- * The Configuration is automatically registered in the list of available configurations. The list is used
- * by the handler to resolve the dependencies upon other configurations. Hierarchies can be built up in
- * an easy way.
+ * A configuration is transformed into a list of AliHLTTask objects by the
+ * function AliHLTSystem::BuildTaskList().
  *
- * A configuration is interpreted by the Configuration Handler and transformed into a Task List.
+ * This class is only used in the HLT offline environment, see @ref alihlt_system
+ * for more details.
+ *
+ * @ingroup alihlt_system
  */
 class AliHLTConfiguration : public TObject, public AliHLTLogging {
  public:
+  /**
+   * standard constructor. The configuration is automatically registered in the
+   * global configuration manager
+   */
   AliHLTConfiguration();
-  AliHLTConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
+  /**
+   * constructor. The configuration is automatically registered in the
+   * global configuration manager
+   * @param id         unique id of the configuration
+   * @param component  component id
+   * @param sources    blank separated list of source configuration ids
+   * @param arguments  argument string passed to the component at initialization
+   * @param bufsize    size of the output buffer in byte, the string can contain a
+   *                   number prepended by a unit, e.g. 1M, allowed units 'k' and 'M'
+   */
+  AliHLTConfiguration(const char* id, const char* component,
+                     const char* sources, const char* arguments,
+                     const char* bufsize=NULL);
+  /** copy constructor */
+  AliHLTConfiguration(const AliHLTConfiguration& src);
+  /** assignment op */
+  AliHLTConfiguration& operator=(const AliHLTConfiguration& src);
+  /** destructor */
   virtual ~AliHLTConfiguration();
 
-  /****************************************************************************************************
-   * properties
+  /*****************************************************************************
+   * properties of the configuration
    */
 
-  // configuration id, a unique name
-  // overridden TObject function in order to return the configuration name instead of the class name
-  // enables use of TList standard functions
+  /**
+   * Get configuration id, a unique name
+   * This is an overridden TObject function in order to return the configuration
+   * name instead of the class name. Enables use of TList standard functions.
+   * @return configuration id
+   */
   const char *GetName() const;
 
-  // id of the component
-  const char* GetComponentID();
-
-  // print status info
-  void PrintStatus();
-
-  // get a certain source
-  AliHLTConfiguration* GetSource(const char* id);
-
-  // try to find a dependency recursively in the list of sources
-  // parameter:
-  //   id - the source to search for
-  //   pTgtList - (optional) target list to receive the dependency tree
-  // result:
-  //   0 if not found
-  //   n found in the n-th level
-  //   dependency list in the target list  
-  int FollowDependency(const char* id, TList* pTgtList=NULL);
-
-  // get the number of resolved sources
-  int GetNofSources() {return fListSources.size();}
-
-  // 1 if all sources are resolved
-  // try to resolve if bAuto==1 
-  int SourcesResolved(int bAuto=0);
-
-  // start iteration and get the first source
-  AliHLTConfiguration* GetFirstSource();
-
-  // continue iteration and get the next source
-  AliHLTConfiguration* GetNextSource();
-
-  // invalidate a dependency and mark the configuration to be re-evaluted 
-  int InvalidateSource(AliHLTConfiguration* pConf);
-
-  // mark the configuration to be re-evaluted 
-  int InvalidateSources() {fNofSources=-1; return 0;}
-
-  // return the arguments array
-  int GetArguments(int* pArgc, const char*** pArgv);
-
- protected:
-  
-  //int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
-
- private:
-  /* extract the source configurations from the sources string
+  /**
+   * Get id of the component.
+   * The id is a unique string.
+   * @return id of the component
    */
-  int ExtractSources();
+  const char* GetComponentID() const {return fComponent;}
 
-  /* extract arguments from the argument string
+  /**
+   * Return the source string.
    */
-  int ExtractArguments();
+  const char* GetSourceSettings() const {return fStringSources;}
 
-  /* helper function to build a vector from an argument string
+  /**
+   * Return the argument string.
    */
-  int InterpreteString(const char* arg, vector<char*>& argList);
-
-  const char* fID;                  // id of this configuration
-  const char* fComponent;           // component id of this configuration
-
-  const char* fStringSources;                             // the 'sources' string as passed to the constructor
-  int fNofSources;
-  vector<AliHLTConfiguration*> fListSources;              // list of sources
-  vector<AliHLTConfiguration*>::iterator fListSrcElement; // iterator for the above list
-
-  const char* fArguments;           // the arguments string as passed to the constructor
-  int fArgc;                        // number of arguments
-  char** fArgv;                     // argument array
-
-  ClassDef(AliHLTConfiguration, 0);
-};
+  const char* GetArgumentSettings() const {return fArguments;}
 
-struct AliHLTComponent_BlockData;
-class AliHLTComponent;
-class AliHLTComponentHandler;
-
-/*****************************************************************************************************
- *
- * AliHLTTask
- *
- * 
- */
-class AliHLTTask : public TObject, public AliHLTLogging {
- public:
-  AliHLTTask();
-  AliHLTTask(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
-  virtual ~AliHLTTask();
+  /**
+   * Print status info.
+   * Short summary on id, component, sources and unresolved sources.
+   */
+  void PrintStatus() const;
 
-  /* initialize the task
+  /**
+   * overloaded from TObject
+   * options:
+   *   status  - print status including the resolved sources
    */
-  int Init(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
+  virtual void Print(const char* option="") const;
 
-  // overridden TObject function in order to return the configuration name instead of the class name
-  // enables use of TList standard functions
-  const char *GetName() const;
+  /**
+   * Get a certain source.
+   * @param  id of the source configuration
+   * @result pointer to the corresponding configuration descriptor
+   */
+  AliHLTConfiguration* GetSource(const char* id);
 
-  /* return pointer to configuration
+  /**
+   * Try to find a dependency recursively in the list of sources.
+   * @param id       the source to search for
+   * @param pTgtList (optional) target list to receive the dependency tree
+   * @return
+   *   0 if not found
+   *   n found in the n-th level
+   *   dependency list in the target list  
    */
-  AliHLTConfiguration* GetConf();
+  int FollowDependency(const char* id, TList* pTgtList=NULL);
 
-  /* return pointer to configuration
+  /**
+   * Get the number of resolved sources.
+   * @return number of resolved sources
    */
-  AliHLTComponent* GetComponent();
+  int GetNofSources() {return fListSources.size();}
 
-  /* find a dependency with name/id 
+  /**
+   * Check resolving status.
+   * @return 1 if all sources resolved, 0 if not yet extracted or not resolved
    */
-  AliHLTTask* FindDependency(const char* id);
+  int SourcesResolved() const;
 
-  /* insert block data to the list
-   * the data has to come from a task the current one depend on
-   * result:
-   *    -EEXIST : the block data from this task has already been inserted
-   *    -ENOENT : no dependencies to the task the data is coming from
+  /**
+   * extract the source configurations from the sources string
+   * builds up the internal list of source configurations
+   * @result 1 if sources resolved, 0 if not
    */
-  int InsertBlockData(AliHLTComponent_BlockData* pBlock, AliHLTTask* pSource);
+  int ExtractSources(AliHLTConfigurationHandler* pHandler);
 
-  /* add a dependency for the task
+  /**
+   * Start iteration and get the first source.
+   * @result pointer to the first configuration descriptor
    */
-  int SetDependency(AliHLTTask* pDep);
+  AliHLTConfiguration* GetFirstSource() const;
 
-  /* return number of unresolved dependencies
+  /**
+   * Continue iteration and get the next source.
+   * @result pointer to the next configuration descriptor in the list
    */
-  int CheckDependencies();
+  AliHLTConfiguration* GetNextSource() const;
 
-  /* 1 if the current task depends upon pTask
-   * 0 if no dependency
+  /**
+   * Invalidate a dependency and mark the configuration to be re-evaluted. 
+   * @param pConf pointer to configuration descriptor
    */
-  int Depends(AliHLTTask* pTask);
+  int InvalidateSource(AliHLTConfiguration* pConf);
 
-  /* find a target
+  /**
+   * Mark the configuration to be re-evaluted.
    */
-  AliHLTTask* FindTarget(const char* id);
+  int InvalidateSources() {fNofSources=-1; return 0;}
 
-  /* insert task into target list
+  /**
+   * Get the arguments array.
+   * @param pArgv   pointer to receive argument array pointer
+   * @return argc if succeeded, neg. error code if failed
    */
-  int SetTarget(AliHLTTask* pDep);
+  int GetArguments(const char*** pArgv) const;
 
-  // build a monolithic array of block data
-  // result: array size, pointer to array in the target pTgt
-  //
-  int BuildBlockDataArray(AliHLTComponent_BlockData*& pTgt);
+  /**
+   * Get output buffer size.
+   * @return size in byte or -1 if not specified
+   */
+  int GetOutputBufferSize() const {return fBufferSize;}
 
-  /* process the task if all dependencies are resolved
-   * reset the source block data list
+  /**
+   * Two configurations are considered equal if all properties match
    */
-  //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
-  int ClearSourceBlocks();
-
-  // print the status of the task with component, dependencies and targets
-  void PrintStatus();
-
-  // search task dependency list recursively to find a dependency 
-  // parameter:
-  //   id - the task to search for
-  //   pTgtList - (optional) target list to receive the dependency tree
-  // result:
-  //   0 if not found
-  //   n found in the n-th level
-  //   dependency list in the target list  
-  int FollowDependency(const char* id, TList* pTgtList=NULL);
+  bool operator==(const AliHLTConfiguration& c) const {
+    return (fID==c.fID) && (fComponent==c.fComponent) && (fStringSources==c.fStringSources) && (fArguments==c.fArguments);
+  }
+  bool operator!=(const AliHLTConfiguration& c) const {
+    return !(*this==c);
+  }
+
+  /**
+   * Helper function to build a vector from an argument string.
+   * The function allocates memory for each token. The caller is responsible
+   * for cleaning the strings recursively.
+   * @param arg       pointer to argument string
+   * @param argList   target to receive the argument list
+   */
+  static int InterpreteString(const char* arg, vector<char*>& argList);
 
-  // print the tree for a certain dependency either from the task or configuration list
-  // each task posseses two "link lists": The configurations are the the origin of the 
-  // task list. In case of an error during the built of the task list, the dependencies 
-  // for the task list might be incomplete. In this case the configurations can give 
-  // infomation on the error reason  
-  // parameter:
-  //   id - the dependency to search for
-  //   bFromConfiguration (default=0) - if 0 the task dependency list is used, if one the configuration list is used
-  void PrintDependencyTree(const char* id, int bFromConfiguration=0);
+ protected:
+  
 
  private:
-  AliHLTConfiguration* fpConfiguration;
-  AliHLTComponent* fpComponent;
-  vector<AliHLTComponent_BlockData*> fSources;
-  TList fListTargets;
-  TList fListDependencies;
-
-  AliHLTComponent_BlockData* fpBlockDataArray;
-
-  ClassDef(AliHLTTask, 0);
-};
-
-class AliHLTConfigurationHandler : public AliHLTLogging {
- public:
-  AliHLTConfigurationHandler();
-  AliHLTConfigurationHandler(AliHLTConfiguration* pConf);
-  virtual ~AliHLTConfigurationHandler();
-
-  /****************************************************************************************************
-   * registration
+  /* extract arguments from the argument string
    */
+  int ExtractArguments();
 
-  // register a configuration to the global list of configurations
-  static int RegisterConfiguration(AliHLTConfiguration* pConf);
-
-  // create a configuration and register it
-  static int CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
-
-  // remove a configuration from the global list
-  static int RemoveConfiguration(AliHLTConfiguration* pConf);
-  static int RemoveConfiguration(const char* id);
-
-  // find a configuration from the global list
-  static AliHLTConfiguration* FindConfiguration(const char* id);
-
-  // print the registered configurations to the logging function
-  static void PrintConfigurations();
-
+  /**
+   * Convert buffer size string to number
+   */
+  int ConvertSizeString(const char* strSize) const;
+
+  /** id of this configuration */
+  TString fID;                                                     // see above
+  /** component id of this configuration */
+  TString fComponent;                                              // see above
+
+  /** the <i>sources</i> string as passed to the constructor */
+  TString fStringSources;                                          // see above
+  /** number of resolved sources, -1 indicates re-evaluation */
+  int fNofSources;                                                 //! transient
+  /** list of sources */
+  vector<AliHLTConfiguration*> fListSources;                       //! transient
+  /** index of the current element in the list of sources */
+  int fListSrcElementIdx;                                          //! transient
+
+  /**
+   * The argument string as passed to the constructor.
+   * Specifies the arguments for the Analysys component. The string will
+   * be parsed and the separated arguments stored in the @ref fArgv array
+   * and @ref fArgc member.
+   */
+  TString fArguments;                                              // see above
+  /** number of arguments */
+  int fArgc;                                                       //! transient
+  /** argument array */
+  char** fArgv;                                                    //! transient
 
- private:
-  static TList fListConfigurations; // the list of registered configurations
-  static TList fListDynamicConfigurations; // the list of dynamic configurations (for proper cleanup)
+  /** size of the output buffer */
+  int fBufferSize;                                                 // see above
 
-  ClassDef(AliHLTConfigurationHandler, 0);
+  ClassDef(AliHLTConfiguration, 0);
 };
 
 #endif