]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTConfiguration.h
adaption to new logging class, added functionality to AliHLTSystem to build a task...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTConfiguration.h
CommitLineData
3495cce2 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/* AliHLTConfiguration
9 base class for HLT configurations
10 */
11
12#include <errno.h>
13#include <TObject.h>
14#include <TList.h>
15#include "AliHLTDataTypes.h"
16#include "AliHLTLogging.h"
17
18
19/*****************************************************************************************************
20 *
21 * AliHLTConfiguration
22 *
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
28 *
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
32 * an easy way.
33 *
34 * A configuration is interpreted by the Configuration Handler and transformed into a Task List.
35 */
36class AliHLTConfiguration : public TObject, public AliHLTLogging {
37 public:
38 AliHLTConfiguration();
39 AliHLTConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
40 virtual ~AliHLTConfiguration();
41
42 /****************************************************************************************************
43 * properties
44 */
45
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;
50
51 // id of the component
52 const char* GetComponentID();
53
54 // print status info
55 void PrintStatus();
56
57 // get a certain source
58 AliHLTConfiguration* GetSource(const char* id);
59
60 // try to find a dependency recursively in the list of sources
61 // parameter:
62 // id - the source to search for
63 // pTgtList - (optional) target list to receive the dependency tree
64 // result:
65 // 0 if not found
66 // n found in the n-th level
67 // dependency list in the target list
68 int FollowDependency(const char* id, TList* pTgtList=NULL);
69
70 // get the number of resolved sources
71 int GetNofSources() {return fListSources.size();}
72
73 // 1 if all sources are resolved
74 // try to resolve if bAuto==1
75 int SourcesResolved(int bAuto=0);
76
77 // start iteration and get the first source
78 AliHLTConfiguration* GetFirstSource();
79
80 // continue iteration and get the next source
81 AliHLTConfiguration* GetNextSource();
82
83 // invalidate a dependency and mark the configuration to be re-evaluted
84 int InvalidateSource(AliHLTConfiguration* pConf);
85
86 // mark the configuration to be re-evaluted
87 int InvalidateSources() {fNofSources=-1; return 0;}
88
89 // return the arguments array
90 int GetArguments(int* pArgc, const char*** pArgv);
91
92 protected:
93
94 //int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
95
96 private:
97 /* extract the source configurations from the sources string
98 */
99 int ExtractSources();
100
101 /* extract arguments from the argument string
102 */
103 int ExtractArguments();
104
105 /* helper function to build a vector from an argument string
106 */
107 int InterpreteString(const char* arg, vector<char*>& argList);
108
109 const char* fID; // id of this configuration
110 const char* fComponent; // component id of this configuration
111
112 const char* fStringSources; // the 'sources' string as passed to the constructor
113 int fNofSources;
114 vector<AliHLTConfiguration*> fListSources; // list of sources
115 vector<AliHLTConfiguration*>::iterator fListSrcElement; // iterator for the above list
116
117 const char* fArguments; // the arguments string as passed to the constructor
118 int fArgc; // number of arguments
119 char** fArgv; // argument array
120
121 ClassDef(AliHLTConfiguration, 0);
122};
123
124struct AliHLTComponent_BlockData;
125class AliHLTComponent;
126class AliHLTComponentHandler;
127
128/*****************************************************************************************************
129 *
130 * AliHLTTask
131 *
132 *
133 */
134class AliHLTTask : public TObject, public AliHLTLogging {
135 public:
136 AliHLTTask();
137 AliHLTTask(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
138 virtual ~AliHLTTask();
139
140 /* initialize the task
141 */
142 int Init(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
143
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;
147
148 /* return pointer to configuration
149 */
150 AliHLTConfiguration* GetConf();
151
152 /* return pointer to configuration
153 */
154 AliHLTComponent* GetComponent();
155
156 /* find a dependency with name/id
157 */
158 AliHLTTask* FindDependency(const char* id);
159
160 /* insert block data to the list
161 * the data has to come from a task the current one depend on
162 * result:
163 * -EEXIST : the block data from this task has already been inserted
164 * -ENOENT : no dependencies to the task the data is coming from
165 */
166 int InsertBlockData(AliHLTComponent_BlockData* pBlock, AliHLTTask* pSource);
167
168 /* add a dependency for the task
169 */
170 int SetDependency(AliHLTTask* pDep);
171
172 /* return number of unresolved dependencies
173 */
174 int CheckDependencies();
175
176 /* 1 if the current task depends upon pTask
177 * 0 if no dependency
178 */
179 int Depends(AliHLTTask* pTask);
180
181 /* find a target
182 */
183 AliHLTTask* FindTarget(const char* id);
184
185 /* insert task into target list
186 */
187 int SetTarget(AliHLTTask* pDep);
188
189 // build a monolithic array of block data
190 // result: array size, pointer to array in the target pTgt
191 //
192 int BuildBlockDataArray(AliHLTComponent_BlockData*& pTgt);
193
194 /* process the task if all dependencies are resolved
195 * reset the source block data list
196 */
197 //int ProcessTask(...);
198
199 // clear the list of source data blocks
200 // the list of source data blocks has to be cleared at the beginning of
201 // a new event
202 int ClearSourceBlocks();
203
204 // print the status of the task with component, dependencies and targets
205 void PrintStatus();
206
207 // search task dependency list recursively to find a dependency
208 // parameter:
209 // id - the task to search for
210 // pTgtList - (optional) target list to receive the dependency tree
211 // result:
212 // 0 if not found
213 // n found in the n-th level
214 // dependency list in the target list
215 int FollowDependency(const char* id, TList* pTgtList=NULL);
216
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
222 // parameter:
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);
226
227 private:
228 AliHLTConfiguration* fpConfiguration;
229 AliHLTComponent* fpComponent;
230 vector<AliHLTComponent_BlockData*> fSources;
231 TList fListTargets;
232 TList fListDependencies;
233
234 AliHLTComponent_BlockData* fpBlockDataArray;
235
236 ClassDef(AliHLTTask, 0);
237};
238
239class AliHLTConfigurationHandler : public AliHLTLogging {
240 public:
241 AliHLTConfigurationHandler();
242 AliHLTConfigurationHandler(AliHLTConfiguration* pConf);
243 virtual ~AliHLTConfigurationHandler();
244
245 /****************************************************************************************************
246 * registration
247 */
248
249 // register a configuration to the global list of configurations
250 static int RegisterConfiguration(AliHLTConfiguration* pConf);
251
252 // create a configuration and register it
253 static int CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
254
255 // remove a configuration from the global list
256 static int RemoveConfiguration(AliHLTConfiguration* pConf);
257 static int RemoveConfiguration(const char* id);
258
259 // find a configuration from the global list
260 static AliHLTConfiguration* FindConfiguration(const char* id);
261
262 // print the registered configurations to the logging function
263 static void PrintConfigurations();
264
265
266 private:
267 static TList fListConfigurations; // the list of registered configurations
268 static TList fListDynamicConfigurations; // the list of dynamic configurations (for proper cleanup)
269
270 ClassDef(AliHLTConfigurationHandler, 0);
271};
272
273#endif