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();
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 /*****************************************************************************************************
142 class AliHLTTask : public TObject, public AliHLTLogging {
145 AliHLTTask(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
146 virtual ~AliHLTTask();
148 /* initialize the task
150 int Init(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
152 // overridden TObject function in order to return the configuration name instead of the class name
153 // enables use of TList standard functions
154 const char *GetName() const;
156 /* return pointer to configuration
158 AliHLTConfiguration* GetConf();
160 /* return pointer to configuration
162 AliHLTComponent* GetComponent();
164 /* find a dependency with name/id
166 AliHLTTask* FindDependency(const char* id);
168 /* insert block data to the list
169 * the data has to come from a task the current one depend on
171 * -EEXIST : the block data from this task has already been inserted
172 * -ENOENT : no dependencies to the task the data is coming from
174 int InsertBlockData(AliHLTComponent_BlockData* pBlock, AliHLTTask* pSource);
176 /* add a dependency for the task
178 int SetDependency(AliHLTTask* pDep);
180 /* return number of unresolved dependencies
182 int CheckDependencies();
184 /* 1 if the current task depends upon pTask
187 int Depends(AliHLTTask* pTask);
191 AliHLTTask* FindTarget(const char* id);
193 /* insert task into target list
195 int SetTarget(AliHLTTask* pDep);
197 // build a monolithic array of block data
198 // result: array size, pointer to array in the target pTgt
200 int BuildBlockDataArray(AliHLTComponent_BlockData*& pTgt);
202 /* process the task if all dependencies are resolved
203 * reset the source block data list
205 //int ProcessTask(...);
207 // clear the list of source data blocks
208 // the list of source data blocks has to be cleared at the beginning of
210 int ClearSourceBlocks();
212 // print the status of the task with component, dependencies and targets
215 // search task dependency list recursively to find a dependency
217 // id - the task to search for
218 // pTgtList - (optional) target list to receive the dependency tree
221 // n found in the n-th level
222 // dependency list in the target list
223 int FollowDependency(const char* id, TList* pTgtList=NULL);
225 // print the tree for a certain dependency either from the task or configuration list
226 // each task posseses two "link lists": The configurations are the the origin of the
227 // task list. In case of an error during the built of the task list, the dependencies
228 // for the task list might be incomplete. In this case the configurations can give
229 // infomation on the error reason
231 // id - the dependency to search for
232 // bFromConfiguration (default=0) - if 0 the task dependency list is used, if one the configuration list is used
233 void PrintDependencyTree(const char* id, int bFromConfiguration=0);
236 AliHLTConfiguration* fpConfiguration;
237 AliHLTComponent* fpComponent;
238 vector<AliHLTComponent_BlockData*> fSources;
240 TList fListDependencies;
242 AliHLTComponent_BlockData* fpBlockDataArray;
244 ClassDef(AliHLTTask, 0);
247 class AliHLTConfigurationHandler : public AliHLTLogging {
249 AliHLTConfigurationHandler();
250 AliHLTConfigurationHandler(AliHLTConfiguration* pConf);
251 virtual ~AliHLTConfigurationHandler();
253 /****************************************************************************************************
257 // register a configuration to the global list of configurations
258 int RegisterConfiguration(AliHLTConfiguration* pConf);
260 // create a configuration and register it
261 int CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
263 // remove a configuration from the global list
264 int RemoveConfiguration(AliHLTConfiguration* pConf);
265 int RemoveConfiguration(const char* id);
267 // find a configuration from the global list
268 AliHLTConfiguration* FindConfiguration(const char* id);
270 // print the registered configurations to the logging function
271 void PrintConfigurations();
275 static TList fListConfigurations; // the list of registered configurations
276 static TList fListDynamicConfigurations; // the list of dynamic configurations (for proper cleanup)
278 ClassDef(AliHLTConfigurationHandler, 0);