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