]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTConfiguration.h
initialization of CDB in wrapper interface;added treatment of reconfiguration event
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTConfiguration.h
1 //-*- Mode: C++ -*-
2 // @(#) $Id$
3
4 #ifndef ALIHLTCONFIGURATION_H
5 #define ALIHLTCONFIGURATION_H
6 /* This file is property of and copyright by the ALICE HLT Project        * 
7  * ALICE Experiment at CERN, All rights reserved.                         *
8  * See cxx source for full Copyright notice                               */
9
10 /** @file   AliHLTConfiguration.h
11     @author Matthias Richter
12     @date   
13     @brief  Base class and handling of HLT configurations.
14     @note   The class is used in Offline (AliRoot) context
15 */
16
17 // see below for class documentation
18 // or
19 // refer to README to build package
20 // or
21 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt   
22
23 #include <vector>
24 #include <TObject.h>
25 #include <TList.h>
26 #include "AliHLTDataTypes.h"
27 #include "AliHLTLogging.h"
28 #include "AliHLTDataBuffer.h"
29
30 class AliHLTConfigurationHandler;
31
32 /**
33  * @class AliHLTConfiguration
34  * @brief Description of HLT processing chains.
35  *
36  * This class describes a certain configuration af an HLT processing step
37  * by the following parameters:
38  * - a unique id string/name
39  * - the id of the component
40  * - the ids of the configurations it requires input from
41  * - the arguments, which are passed to the component when it is initialized
42  *
43  * The setup of a configuration requires simply the creation of a global object
44  * of @ref AliHLTConfiguration. The Configuration is automatically registered
45  * in the list of available configurations maintained by the @ref
46  * AliHLTConfigurationHandler. The list is used by to resolve the dependencies
47  * on other configurations. Hierarchies can be built up in an easy way.
48  *
49  * A configuration is interpreted by the @ref AliHLTConfigurationHandler and
50  * transformed into a Task List.
51  *
52  * @note This class is only used for the @ref alihlt_system.
53  *
54  * @ingroup alihlt_system
55  */
56 class AliHLTConfiguration : public TObject, public AliHLTLogging {
57  public:
58   /**
59    * standard constructor. The configuration is automatically registered in the
60    * global configuration manager
61    */
62   AliHLTConfiguration();
63   /**
64    * constructor. The configuration is automatically registered in the
65    * global configuration manager
66    * @param id         unique id of the configuration
67    * @param component  component id
68    * @param sources    blank separated list of source configuration ids
69    * @param arguments  argument string passed to the component at initialization
70    */
71   AliHLTConfiguration(const char* id, const char* component,
72                       const char* sources, const char* arguments);
73   /** copy constructor */
74   AliHLTConfiguration(const AliHLTConfiguration& src);
75   /** assignment op */
76   AliHLTConfiguration& operator=(const AliHLTConfiguration& src);
77   /** destructor */
78   virtual ~AliHLTConfiguration();
79
80   /*****************************************************************************
81    * global initialization
82    */
83
84   /**
85    * Global initialization of the configuration handler.
86    */
87   static int GlobalInit(AliHLTConfigurationHandler* pHandler);
88
89   /**
90    * Global de-init and cleanup of the global configuration handler
91    */
92   static int GlobalDeinit(AliHLTConfigurationHandler* pHandler);
93
94   /*****************************************************************************
95    * properties of the configuration
96    */
97
98   /**
99    * Get configuration id, a unique name
100    * This is an overridden TObject function in order to return the configuration
101    * name instead of the class name. Enables use of TList standard functions.
102    * @return configuration id
103    */
104   const char *GetName() const;
105
106   /**
107    * Get id of the component.
108    * The id is a unique string.
109    * @return id of the component
110    */
111   const char* GetComponentID() const {return fComponent;}
112
113   /**
114    * Print status info.
115    * Short summary on id, component, sources and unresolved sources.
116    */
117   void PrintStatus();
118
119   /**
120    * Get a certain source.
121    * @param  id of the source configuration
122    * @result pointer to the corresponding configuration descriptor
123    */
124   AliHLTConfiguration* GetSource(const char* id);
125
126   /**
127    * Try to find a dependency recursively in the list of sources.
128    * @param id       the source to search for
129    * @param pTgtList (optional) target list to receive the dependency tree
130    * @return
131    *   0 if not found
132    *   n found in the n-th level
133    *   dependency list in the target list  
134    */
135   int FollowDependency(const char* id, TList* pTgtList=NULL);
136
137   /**
138    * Get the number of resolved sources.
139    * @return number of resolved sources
140    */
141   int GetNofSources() {return fListSources.size();}
142
143   /**
144    * Check resolving status.
145    * @param bAuto resolve if ==1 
146    * @return 1 if all sources resolved
147    */
148   int SourcesResolved(int bAuto=0);
149
150   /**
151    * Start iteration and get the first source.
152    * @result pointer to the first configuration descriptor
153    */
154   AliHLTConfiguration* GetFirstSource();
155
156   /**
157    * Continue iteration and get the next source.
158    * @result pointer to the next configuration descriptor in the list
159    */
160   AliHLTConfiguration* GetNextSource();
161
162   /**
163    * Invalidate a dependency and mark the configuration to be re-evaluted. 
164    * @param pConf pointer to configuration descriptor
165    */
166   int InvalidateSource(AliHLTConfiguration* pConf);
167
168   /**
169    * Mark the configuration to be re-evaluted.
170    */
171   int InvalidateSources() {fNofSources=-1; return 0;}
172
173   /**
174    * Get the arguments array.
175    * @param pArgv   pointer to receive argument array pointer
176    * @return argc if succeeded, neg. error code if failed
177    */
178   int GetArguments(const char*** pArgv);
179
180  protected:
181   
182
183  private:
184   /* extract the source configurations from the sources string
185    */
186   int ExtractSources();
187
188   /* extract arguments from the argument string
189    */
190   int ExtractArguments();
191
192   /**
193    * Helper function to build a vector from an argument string
194    * @param arg       pointer to argument string
195    * @param argList   target to receive the argument list
196    */
197   int InterpreteString(const char* arg, vector<char*>& argList);
198
199   /** id of this configuration */
200   TString fID;                                                     // see above
201   /** component id of this configuration */
202   TString fComponent;                                              // see above
203
204   /** the <i>sources</i> string as passed to the constructor */
205   TString fStringSources;                                          // see above
206   /** number of resolved sources, -1 indicates re-evaluation */
207   int fNofSources;                                                 // see above
208   /** list of sources */
209   vector<AliHLTConfiguration*> fListSources;                       // see above
210   /** iterator for the above list */
211   vector<AliHLTConfiguration*>::iterator fListSrcElement;          // see above
212
213   /**
214    * The argument string as passed to the constructor.
215    * Specifies the arguments for the Analysys component. The string will
216    * be parsed and the separated arguments stored in the @ref fArgv array
217    * and @ref fArgc member.
218    */
219   TString fArguments;                                              // see above
220   /** number of arguments */
221   int fArgc;                                                       // see above
222   /** argument array */
223   char** fArgv;                                                    // see above
224
225   /** the instance of the global configuration handler */
226   static AliHLTConfigurationHandler* fgConfigurationHandler;       //! transient
227
228   ClassDef(AliHLTConfiguration, 0);
229 };
230
231 #endif