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 */
9 base class for HLT configurations
15 #include "AliHLTDataTypes.h"
16 #include "AliHLTLogging.h"
18 class AliHLTConfigurationHandler;
19 /*****************************************************************************************************
23 * this class describes a certain configuration af an HLT processing step by the following parameters:
24 * - a unique id string/name
25 * - the id of the component
26 * - the ids of the configurations it requires input from
27 * - the arguments, which are passed to the component when it is initialized
29 * The setup of a configuration requires simply the creation of a global object of class AliHLTConfiguration.
30 * The Configuration is automatically registered in the list of available configurations. The list is used
31 * by the handler to resolve the dependencies upon other configurations. Hierarchies can be built up in
34 * A configuration is interpreted by the Configuration Handler and transformed into a Task List.
36 class AliHLTConfiguration : public TObject, public AliHLTLogging {
38 AliHLTConfiguration();
39 AliHLTConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
40 virtual ~AliHLTConfiguration();
42 /****************************************************************************************************
43 * global initialization
45 static int GlobalInit(AliHLTConfigurationHandler* pHandler);
47 static int GlobalDeinit();
49 /****************************************************************************************************
53 // configuration id, a unique name
54 // overridden TObject function in order to return the configuration name instead of the class name
55 // enables use of TList standard functions
56 const char *GetName() const;
58 // id of the component
59 const char* GetComponentID() {return fComponent;}
64 // get a certain source
65 AliHLTConfiguration* GetSource(const char* id);
67 // try to find a dependency recursively in the list of sources
69 // id - the source to search for
70 // pTgtList - (optional) target list to receive the dependency tree
73 // n found in the n-th level
74 // dependency list in the target list
75 int FollowDependency(const char* id, TList* pTgtList=NULL);
77 // get the number of resolved sources
78 int GetNofSources() {return fListSources.size();}
80 // 1 if all sources are resolved
81 // try to resolve if bAuto==1
82 int SourcesResolved(int bAuto=0);
84 // start iteration and get the first source
85 AliHLTConfiguration* GetFirstSource();
87 // continue iteration and get the next source
88 AliHLTConfiguration* GetNextSource();
90 // invalidate a dependency and mark the configuration to be re-evaluted
91 int InvalidateSource(AliHLTConfiguration* pConf);
93 // mark the configuration to be re-evaluted
94 int InvalidateSources() {fNofSources=-1; return 0;}
96 // return the arguments array
97 int GetArguments(int* pArgc, const char*** pArgv);
103 /* extract the source configurations from the sources string
105 int ExtractSources();
107 /* extract arguments from the argument string
109 int ExtractArguments();
111 /* helper function to build a vector from an argument string
113 int InterpreteString(const char* arg, vector<char*>& argList);
115 const char* fID; // id of this configuration
116 const char* fComponent; // component id of this configuration
118 const char* fStringSources; // the 'sources' string as passed to the constructor
120 vector<AliHLTConfiguration*> fListSources; // list of sources
121 vector<AliHLTConfiguration*>::iterator fListSrcElement; // iterator for the above list
123 const char* fArguments; // the arguments string as passed to the constructor
124 int fArgc; // number of arguments
125 char** fArgv; // argument array
127 static AliHLTConfigurationHandler* fConfigurationHandler;
129 ClassDef(AliHLTConfiguration, 0);
132 struct AliHLTComponent_BlockData;
133 class AliHLTComponent;
134 class AliHLTComponentHandler;
136 /*****************************************************************************************************
140 * a task collects all the information which is necessary to process a certain step in the HLT data
142 * 1. the instance of the component
143 * 2. the data buffer which receives the result of the component and provides the data to other
145 * 3. a list of all dependencies
146 * 4. a list of consumers
147 * 5. the task object holds the configuration object
149 class AliHLTTask : public TObject, public AliHLTLogging {
152 AliHLTTask(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
153 virtual ~AliHLTTask();
155 /* initialize the task
157 int Init(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
159 // overridden TObject function in order to return the configuration name instead of the class name
160 // enables use of TList standard functions
161 const char *GetName() const;
163 /* return pointer to configuration
164 * the tasks holds internally the configuration object, which is returned by the function
166 AliHLTConfiguration* GetConf();
168 /* return pointer to component, which the task internally holds
170 AliHLTComponent* GetComponent();
172 /* find a dependency with name/id
173 * searches in the list of dependencies for a task
174 * NOTE: the id specifies a CONFIGURATION not a COMPONENT
176 AliHLTTask* FindDependency(const char* id);
178 /* insert block data to the list
179 * the data has to come from a task the current one depend on
181 * -EEXIST : the block data from this task has already been inserted
182 * -ENOENT : no dependencies to the task the data is coming from
184 int InsertBlockData(AliHLTComponent_BlockData* pBlock, AliHLTTask* pSource);
186 /* add a dependency for the task
187 * the task which the current task depends on is added to the list
188 * result: 0 if suceeded, neg error code if failed
189 * -EEXIST : the dependencies already exists
192 int SetDependency(AliHLTTask* pDep);
194 /* return number of unresolved dependencies
195 * iterate through all the configurations the task depends on and check whether a corresponding
196 * task is available in the list
198 int CheckDependencies();
200 /* check whether the current task depends on the task pTask
202 * 1 the current task depends upon pTask
204 * neg error code if failure
206 int Depends(AliHLTTask* pTask);
210 AliHLTTask* FindTarget(const char* id);
212 /* insert task into target list
214 int SetTarget(AliHLTTask* pDep);
216 // build a monolithic array of block data
217 // result: array size, pointer to array in the target pTgt
219 int BuildBlockDataArray(AliHLTComponent_BlockData*& pTgt);
221 /* process the task if all dependencies are resolved
222 * reset the source block data list
224 //int ProcessTask(...);
226 // clear the list of source data blocks
227 // the list of source data blocks has to be cleared at the beginning of
229 int ClearSourceBlocks();
231 // print the status of the task with component, dependencies and targets
234 // search task dependency list recursively to find a dependency
236 // id - the task to search for
237 // pTgtList - (optional) target list to receive the dependency tree
240 // n found in the n-th level
241 // dependency list in the target list
242 int FollowDependency(const char* id, TList* pTgtList=NULL);
244 // print the tree for a certain dependency either from the task or configuration list
245 // each task posseses two "link lists": The configurations are the the origin of the
246 // task list. In case of an error during the built of the task list, the dependencies
247 // for the task list might be incomplete. In this case the configurations can give
248 // infomation on the error reason
250 // id - the dependency to search for
251 // bFromConfiguration (default=0) - if 0 the task dependency list is used, if one the configuration list is used
252 void PrintDependencyTree(const char* id, int bFromConfiguration=0);
255 AliHLTConfiguration* fpConfiguration;
256 AliHLTComponent* fpComponent;
257 vector<AliHLTComponent_BlockData*> fSources;
259 TList fListDependencies;
261 AliHLTComponent_BlockData* fpBlockDataArray;
263 ClassDef(AliHLTTask, 0);
266 class AliHLTConfigurationHandler : public AliHLTLogging {
268 AliHLTConfigurationHandler();
269 //AliHLTConfigurationHandler(AliHLTConfiguration* pConf);
270 virtual ~AliHLTConfigurationHandler();
272 /****************************************************************************************************
276 // register a configuration to the global list of configurations
277 int RegisterConfiguration(AliHLTConfiguration* pConf);
279 // create a configuration and register it
280 int CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
282 // remove a configuration from the global list
283 int RemoveConfiguration(AliHLTConfiguration* pConf);
284 int RemoveConfiguration(const char* id);
286 // find a configuration from the global list
287 AliHLTConfiguration* FindConfiguration(const char* id);
289 // print the registered configurations to the logging function
290 void PrintConfigurations();
294 static TList fListConfigurations; // the list of registered configurations
295 static TList fListDynamicConfigurations; // the list of dynamic configurations (for proper cleanup)
297 ClassDef(AliHLTConfigurationHandler, 0);