]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTConfiguration.h
updated 2D drawing macros
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTConfiguration.h
index 71027049028c02acc5bf320c0086ab94295f58c2..bfaa5b5a66b10c4525796be5aee7340c854fc42b 100644 (file)
@@ -1,18 +1,19 @@
-// @(#) $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 Experiment at CERN, All rights reserved.                         *
+//* See cxx source for full Copyright notice                               *
 
-/** @file   AliHLTConfiguration.h
-    @author Matthias Richter
-    @date   
-    @brief  Base class and handling of HLT configurations.
-    @note   The class is used in Offline (AliRoot) context
-*/
+/// @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 <cerrno>
+#include <vector>
 #include <TObject.h>
 #include <TList.h>
 #include "AliHLTDataTypes.h"
@@ -25,23 +26,39 @@ class AliHLTConfigurationHandler;
  * @class AliHLTConfiguration
  * @brief Description of HLT processing chains.
  *
- * 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
+ * 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 setup of a configuration requires simply the creation of a global object
- * of @ref AliHLTConfiguration. The Configuration is automatically registered
- * in the list of available configurations maintained by the @ref
- * AliHLTConfigurationHandler. The list is used by to resolve the dependencies
- * on other configurations. Hierarchies can be built up in an easy way.
+ * 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>
  *
- * A configuration is interpreted by the @ref AliHLTConfigurationHandler and
- * transformed into a Task List.
+ * 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.
  *
- * @note This class is only used for the @ref alihlt_system.
+ * 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>
+ *
+ * A configuration is transformed into a list of AliHLTTask objects by the
+ * function AliHLTSystem::BuildTaskList().
+ *
+ * This class is only used in the HLT offline environment, see @ref alihlt_system
+ * for more details.
  *
  * @ingroup alihlt_system
  */
@@ -59,31 +76,19 @@ class AliHLTConfiguration : public TObject, public AliHLTLogging {
    * @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);
-  /** not a valid copy constructor, defined according to effective C++ style */
-  AliHLTConfiguration(const AliHLTConfiguration&);
-  /** not a valid assignment op, but defined according to effective C++ style */
-  AliHLTConfiguration& operator=(const AliHLTConfiguration&);
-  /** destructor */
+                     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();
 
-  /*****************************************************************************
-   * global initialization
-   */
-
-  /**
-   * Global initialization of the configuration handler.
-   */
-  static int GlobalInit(AliHLTConfigurationHandler* pHandler);
-
-  /**
-   * Global de-init and cleanup of the global configuration handler
-   */
-  static int GlobalDeinit();
-
   /*****************************************************************************
    * properties of the configuration
    */
@@ -101,13 +106,30 @@ class AliHLTConfiguration : public TObject, public AliHLTLogging {
    * The id is a unique string.
    * @return id of the component
    */
-  const char* GetComponentID() {return fComponent;}
+  const char* GetComponentID() const {return fComponent;}
+
+  /**
+   * Return the source string.
+   */
+  const char* GetSourceSettings() const {return fStringSources;}
+
+  /**
+   * Return the argument string.
+   */
+  const char* GetArgumentSettings() const {return fArguments;}
 
   /**
    * Print status info.
    * Short summary on id, component, sources and unresolved sources.
    */
-  void PrintStatus();
+  void PrintStatus() const;
+
+  /**
+   * overloaded from TObject
+   * options:
+   *   status  - print status including the resolved sources
+   */
+  virtual void Print(const char* option="") const;
 
   /**
    * Get a certain source.
@@ -135,22 +157,28 @@ class AliHLTConfiguration : public TObject, public AliHLTLogging {
 
   /**
    * Check resolving status.
-   * @param bAuto resolve if ==1 
-   * @return 1 if all sources resolved
+   * @return 1 if all sources resolved, 0 if not yet extracted or not resolved
    */
-  int SourcesResolved(int bAuto=0);
+  int SourcesResolved() const;
+
+  /**
+   * 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 ExtractSources(AliHLTConfigurationHandler* pHandler);
 
   /**
    * Start iteration and get the first source.
    * @result pointer to the first configuration descriptor
    */
-  AliHLTConfiguration* GetFirstSource();
+  AliHLTConfiguration* GetFirstSource() const;
 
   /**
    * Continue iteration and get the next source.
    * @result pointer to the next configuration descriptor in the list
    */
-  AliHLTConfiguration* GetNextSource();
+  AliHLTConfiguration* GetNextSource() const;
 
   /**
    * Invalidate a dependency and mark the configuration to be re-evaluted. 
@@ -168,37 +196,59 @@ class AliHLTConfiguration : public TObject, public AliHLTLogging {
    * @param pArgv   pointer to receive argument array pointer
    * @return argc if succeeded, neg. error code if failed
    */
-  int GetArguments(const char*** pArgv);
+  int GetArguments(const char*** pArgv) const;
+
+  /**
+   * Get output buffer size.
+   * @return size in byte or -1 if not specified
+   */
+  int GetOutputBufferSize() const {return fBufferSize;}
+
+  /**
+   * Two configurations are considered equal if all properties match
+   */
+  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);
 
  protected:
   
 
  private:
-  /* extract the source configurations from the sources string
-   */
-  int ExtractSources();
-
   /* extract arguments from the argument string
    */
   int ExtractArguments();
 
-  /* helper function to build a vector from an argument string
+  /**
+   * Convert buffer size string to number
    */
-  int InterpreteString(const char* arg, vector<char*>& argList);
+  int ConvertSizeString(const char* strSize) const;
 
   /** id of this configuration */
-  const char* fID;
+  TString fID;                                                     // see above
   /** component id of this configuration */
-  const char* fComponent;
+  TString fComponent;                                              // see above
 
   /** the <i>sources</i> string as passed to the constructor */
-  const char* fStringSources;
+  TString fStringSources;                                          // see above
   /** number of resolved sources, -1 indicates re-evaluation */
-  int fNofSources;
+  int fNofSources;                                                 //! transient
   /** list of sources */
-  vector<AliHLTConfiguration*> fListSources;
-  /** iterator for the above list */
-  vector<AliHLTConfiguration*>::iterator fListSrcElement;
+  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.
@@ -206,13 +256,14 @@ class AliHLTConfiguration : public TObject, public AliHLTLogging {
    * be parsed and the separated arguments stored in the @ref fArgv array
    * and @ref fArgc member.
    */
-  const char* fArguments;
+  TString fArguments;                                              // see above
   /** number of arguments */
-  int fArgc;
+  int fArgc;                                                       //! transient
   /** argument array */
-  char** fArgv;
+  char** fArgv;                                                    //! transient
 
-  static AliHLTConfigurationHandler* fConfigurationHandler;
+  /** size of the output buffer */
+  int fBufferSize;                                                 // see above
 
   ClassDef(AliHLTConfiguration, 0);
 };