]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTConfiguration.h
fix in Gain
[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
3b35e87c 12#include <cerrno>
3495cce2 13#include <TObject.h>
14#include <TList.h>
15#include "AliHLTDataTypes.h"
16#include "AliHLTLogging.h"
17
85465857 18class AliHLTConfigurationHandler;
3495cce2 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
85465857 42 /****************************************************************************************************
43 * global initialization
44 */
45 static int GlobalInit(AliHLTConfigurationHandler* pHandler);
46
47 static int GlobalDeinit();
48
3495cce2 49 /****************************************************************************************************
50 * properties
51 */
52
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;
57
58 // id of the component
014d39ce 59 const char* GetComponentID() {return fComponent;}
3495cce2 60
61 // print status info
62 void PrintStatus();
63
64 // get a certain source
65 AliHLTConfiguration* GetSource(const char* id);
66
67 // try to find a dependency recursively in the list of sources
68 // parameter:
69 // id - the source to search for
70 // pTgtList - (optional) target list to receive the dependency tree
71 // result:
72 // 0 if not found
73 // n found in the n-th level
74 // dependency list in the target list
75 int FollowDependency(const char* id, TList* pTgtList=NULL);
76
77 // get the number of resolved sources
78 int GetNofSources() {return fListSources.size();}
79
80 // 1 if all sources are resolved
81 // try to resolve if bAuto==1
82 int SourcesResolved(int bAuto=0);
83
84 // start iteration and get the first source
85 AliHLTConfiguration* GetFirstSource();
86
87 // continue iteration and get the next source
88 AliHLTConfiguration* GetNextSource();
89
90 // invalidate a dependency and mark the configuration to be re-evaluted
91 int InvalidateSource(AliHLTConfiguration* pConf);
92
93 // mark the configuration to be re-evaluted
94 int InvalidateSources() {fNofSources=-1; return 0;}
95
96 // return the arguments array
97 int GetArguments(int* pArgc, const char*** pArgv);
98
99 protected:
100
3495cce2 101
102 private:
103 /* extract the source configurations from the sources string
104 */
105 int ExtractSources();
106
107 /* extract arguments from the argument string
108 */
109 int ExtractArguments();
110
111 /* helper function to build a vector from an argument string
112 */
113 int InterpreteString(const char* arg, vector<char*>& argList);
114
115 const char* fID; // id of this configuration
116 const char* fComponent; // component id of this configuration
117
118 const char* fStringSources; // the 'sources' string as passed to the constructor
119 int fNofSources;
120 vector<AliHLTConfiguration*> fListSources; // list of sources
121 vector<AliHLTConfiguration*>::iterator fListSrcElement; // iterator for the above list
122
123 const char* fArguments; // the arguments string as passed to the constructor
124 int fArgc; // number of arguments
125 char** fArgv; // argument array
126
85465857 127 static AliHLTConfigurationHandler* fConfigurationHandler;
128
3495cce2 129 ClassDef(AliHLTConfiguration, 0);
130};
131
132struct AliHLTComponent_BlockData;
133class AliHLTComponent;
134class AliHLTComponentHandler;
135
136/*****************************************************************************************************
137 *
138 * AliHLTTask
139 *
3b35e87c 140 * a task collects all the information which is necessary to process a certain step in the HLT data
141 * processing chain:
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
144 * tasks/components
145 * 3. a list of all dependencies
146 * 4. a list of consumers
147 * 5. the task object holds the configuration object
3495cce2 148 */
149class AliHLTTask : public TObject, public AliHLTLogging {
150 public:
151 AliHLTTask();
152 AliHLTTask(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
153 virtual ~AliHLTTask();
154
155 /* initialize the task
156 */
157 int Init(AliHLTConfiguration* fConf, AliHLTComponentHandler* pCH);
158
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;
162
163 /* return pointer to configuration
3b35e87c 164 * the tasks holds internally the configuration object, which is returned by the function
3495cce2 165 */
166 AliHLTConfiguration* GetConf();
167
3b35e87c 168 /* return pointer to component, which the task internally holds
3495cce2 169 */
170 AliHLTComponent* GetComponent();
171
172 /* find a dependency with name/id
3b35e87c 173 * searches in the list of dependencies for a task
174 * NOTE: the id specifies a CONFIGURATION not a COMPONENT
3495cce2 175 */
176 AliHLTTask* FindDependency(const char* id);
177
178 /* insert block data to the list
179 * the data has to come from a task the current one depend on
180 * result:
181 * -EEXIST : the block data from this task has already been inserted
182 * -ENOENT : no dependencies to the task the data is coming from
183 */
184 int InsertBlockData(AliHLTComponent_BlockData* pBlock, AliHLTTask* pSource);
185
186 /* add a dependency for the task
3b35e87c 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
190 *
3495cce2 191 */
192 int SetDependency(AliHLTTask* pDep);
193
194 /* return number of unresolved dependencies
3b35e87c 195 * iterate through all the configurations the task depends on and check whether a corresponding
196 * task is available in the list
3495cce2 197 */
198 int CheckDependencies();
199
3b35e87c 200 /* check whether the current task depends on the task pTask
201 * result:
202 * 1 the current task depends upon pTask
203 * 0 no dependency
204 * neg error code if failure
3495cce2 205 */
206 int Depends(AliHLTTask* pTask);
207
208 /* find a target
209 */
210 AliHLTTask* FindTarget(const char* id);
211
212 /* insert task into target list
213 */
214 int SetTarget(AliHLTTask* pDep);
215
216 // build a monolithic array of block data
217 // result: array size, pointer to array in the target pTgt
218 //
219 int BuildBlockDataArray(AliHLTComponent_BlockData*& pTgt);
220
221 /* process the task if all dependencies are resolved
222 * reset the source block data list
223 */
224 //int ProcessTask(...);
225
226 // clear the list of source data blocks
227 // the list of source data blocks has to be cleared at the beginning of
228 // a new event
229 int ClearSourceBlocks();
230
231 // print the status of the task with component, dependencies and targets
232 void PrintStatus();
233
234 // search task dependency list recursively to find a dependency
235 // parameter:
236 // id - the task to search for
237 // pTgtList - (optional) target list to receive the dependency tree
238 // result:
239 // 0 if not found
240 // n found in the n-th level
241 // dependency list in the target list
242 int FollowDependency(const char* id, TList* pTgtList=NULL);
243
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
249 // parameter:
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);
253
254 private:
255 AliHLTConfiguration* fpConfiguration;
256 AliHLTComponent* fpComponent;
257 vector<AliHLTComponent_BlockData*> fSources;
258 TList fListTargets;
259 TList fListDependencies;
260
261 AliHLTComponent_BlockData* fpBlockDataArray;
262
263 ClassDef(AliHLTTask, 0);
264};
265
266class AliHLTConfigurationHandler : public AliHLTLogging {
267 public:
268 AliHLTConfigurationHandler();
014d39ce 269 //AliHLTConfigurationHandler(AliHLTConfiguration* pConf);
3495cce2 270 virtual ~AliHLTConfigurationHandler();
271
272 /****************************************************************************************************
273 * registration
274 */
275
276 // register a configuration to the global list of configurations
85465857 277 int RegisterConfiguration(AliHLTConfiguration* pConf);
3495cce2 278
279 // create a configuration and register it
85465857 280 int CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
3495cce2 281
282 // remove a configuration from the global list
85465857 283 int RemoveConfiguration(AliHLTConfiguration* pConf);
284 int RemoveConfiguration(const char* id);
3495cce2 285
286 // find a configuration from the global list
85465857 287 AliHLTConfiguration* FindConfiguration(const char* id);
3495cce2 288
289 // print the registered configurations to the logging function
85465857 290 void PrintConfigurations();
3495cce2 291
292
293 private:
294 static TList fListConfigurations; // the list of registered configurations
295 static TList fListDynamicConfigurations; // the list of dynamic configurations (for proper cleanup)
296
297 ClassDef(AliHLTConfigurationHandler, 0);
298};
299
300#endif