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"
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 /****************************************************************************************************
46 // configuration id, a unique name
47 // overridden TObject function in order to return the configuration name instead of the class name
48 // enables use of TList standard functions
49 const char *GetName() const;
51 // id of the component
52 const char* GetComponentID();
57 // get a certain source
58 AliHLTConfiguration* GetSource(const char* id);
60 // try to find a dependency recursively in the list of sources
62 // id - the source to search for
63 // pTgtList - (optional) target list to receive the dependency tree
66 // n found in the n-th level
67 // dependency list in the target list
68 int FollowDependency(const char* id, TList* pTgtList=NULL);
70 // get the number of resolved sources
71 int GetNofSources() {return fListSources.size();}
73 // 1 if all sources are resolved
74 // try to resolve if bAuto==1
75 int SourcesResolved(int bAuto=0);
77 // start iteration and get the first source
78 AliHLTConfiguration* GetFirstSource();
80 // continue iteration and get the next source
81 AliHLTConfiguration* GetNextSource();
83 // invalidate a dependency and mark the configuration to be re-evaluted
84 int InvalidateSource(AliHLTConfiguration* pConf);
86 // mark the configuration to be re-evaluted
87 int InvalidateSources() {fNofSources=-1; return 0;}
89 // return the arguments array
90 int GetArguments(int* pArgc, const char*** pArgv);
94 //int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
97 /* extract the source configurations from the sources string
101 /* extract arguments from the argument string
103 int ExtractArguments();
105 /* helper function to build a vector from an argument string
107 int InterpreteString(const char* arg, vector<char*>& argList);
109 const char* fID; // id of this configuration
110 const char* fComponent; // component id of this configuration
112 const char* fStringSources; // the 'sources' string as passed to the constructor
114 vector<AliHLTConfiguration*> fListSources; // list of sources
115 vector<AliHLTConfiguration*>::iterator fListSrcElement; // iterator for the above list
117 const char* fArguments; // the arguments string as passed to the constructor
118 int fArgc; // number of arguments
119 char** fArgv; // argument array
121 ClassDef(AliHLTConfiguration, 0);
124 struct AliHLTComponent_BlockData;
125 class AliHLTComponent;
126 class AliHLTComponentHandler;
128 /*****************************************************************************************************
134 class AliHLTTask : public TObject, public AliHLTLogging {
137 AliHLTTask(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
138 virtual ~AliHLTTask();
140 /* initialize the task
142 int Init(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
144 // overridden TObject function in order to return the configuration name instead of the class name
145 // enables use of TList standard functions
146 const char *GetName() const;
148 /* return pointer to configuration
150 AliHLTConfiguration* GetConf();
152 /* return pointer to configuration
154 AliHLTComponent* GetComponent();
156 /* find a dependency with name/id
158 AliHLTTask* FindDependency(const char* id);
160 /* insert block data to the list
161 * the data has to come from a task the current one depend on
163 * -EEXIST : the block data from this task has already been inserted
164 * -ENOENT : no dependencies to the task the data is coming from
166 int InsertBlockData(AliHLTComponent_BlockData* pBlock, AliHLTTask* pSource);
168 /* add a dependency for the task
170 int SetDependency(AliHLTTask* pDep);
172 /* return number of unresolved dependencies
174 int CheckDependencies();
176 /* 1 if the current task depends upon pTask
179 int Depends(AliHLTTask* pTask);
183 AliHLTTask* FindTarget(const char* id);
185 /* insert task into target list
187 int SetTarget(AliHLTTask* pDep);
189 // build a monolithic array of block data
190 // result: array size, pointer to array in the target pTgt
192 int BuildBlockDataArray(AliHLTComponent_BlockData*& pTgt);
194 /* process the task if all dependencies are resolved
195 * reset the source block data list
197 //int ProcessTask(...);
199 // clear the list of source data blocks
200 // the list of source data blocks has to be cleared at the beginning of
202 int ClearSourceBlocks();
204 // print the status of the task with component, dependencies and targets
207 // search task dependency list recursively to find a dependency
209 // id - the task to search for
210 // pTgtList - (optional) target list to receive the dependency tree
213 // n found in the n-th level
214 // dependency list in the target list
215 int FollowDependency(const char* id, TList* pTgtList=NULL);
217 // print the tree for a certain dependency either from the task or configuration list
218 // each task posseses two "link lists": The configurations are the the origin of the
219 // task list. In case of an error during the built of the task list, the dependencies
220 // for the task list might be incomplete. In this case the configurations can give
221 // infomation on the error reason
223 // id - the dependency to search for
224 // bFromConfiguration (default=0) - if 0 the task dependency list is used, if one the configuration list is used
225 void PrintDependencyTree(const char* id, int bFromConfiguration=0);
228 AliHLTConfiguration* fpConfiguration;
229 AliHLTComponent* fpComponent;
230 vector<AliHLTComponent_BlockData*> fSources;
232 TList fListDependencies;
234 AliHLTComponent_BlockData* fpBlockDataArray;
236 ClassDef(AliHLTTask, 0);
239 class AliHLTConfigurationHandler : public AliHLTLogging {
241 AliHLTConfigurationHandler();
242 AliHLTConfigurationHandler(AliHLTConfiguration* pConf);
243 virtual ~AliHLTConfigurationHandler();
245 /****************************************************************************************************
249 // register a configuration to the global list of configurations
250 static int RegisterConfiguration(AliHLTConfiguration* pConf);
252 // create a configuration and register it
253 static int CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
255 // remove a configuration from the global list
256 static int RemoveConfiguration(AliHLTConfiguration* pConf);
257 static int RemoveConfiguration(const char* id);
259 // find a configuration from the global list
260 static AliHLTConfiguration* FindConfiguration(const char* id);
262 // print the registered configurations to the logging function
263 static void PrintConfigurations();
267 static TList fListConfigurations; // the list of registered configurations
268 static TList fListDynamicConfigurations; // the list of dynamic configurations (for proper cleanup)
270 ClassDef(AliHLTConfigurationHandler, 0);