]>
Commit | Line | Data |
---|---|---|
30338a30 | 1 | //-*- Mode: C++ -*- |
3495cce2 | 2 | // @(#) $Id$ |
3 | ||
4 | #ifndef ALIHLTCONFIGURATION_H | |
5 | #define ALIHLTCONFIGURATION_H | |
b6800be0 | 6 | /* This file is property of and copyright by the ALICE HLT Project * |
7 | * ALICE Experiment at CERN, All rights reserved. * | |
3495cce2 | 8 | * See cxx source for full Copyright notice */ |
9 | ||
0c0c9d99 | 10 | /** @file AliHLTConfiguration.h |
11 | @author Matthias Richter | |
12 | @date | |
b22e91eb | 13 | @brief Base class and handling of HLT configurations. |
14 | @note The class is used in Offline (AliRoot) context | |
0c0c9d99 | 15 | */ |
3495cce2 | 16 | |
30338a30 | 17 | // see below for class documentation |
18 | // or | |
19 | // refer to README to build package | |
20 | // or | |
21 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
22 | ||
8ede8717 | 23 | #include <vector> |
3495cce2 | 24 | #include <TObject.h> |
25 | #include <TList.h> | |
26 | #include "AliHLTDataTypes.h" | |
27 | #include "AliHLTLogging.h" | |
0c0c9d99 | 28 | #include "AliHLTDataBuffer.h" |
3495cce2 | 29 | |
85465857 | 30 | class AliHLTConfigurationHandler; |
0c0c9d99 | 31 | |
32 | /** | |
33 | * @class AliHLTConfiguration | |
bfccbf68 | 34 | * @brief Description of HLT processing chains. |
b22e91eb | 35 | * |
0c0c9d99 | 36 | * This class describes a certain configuration af an HLT processing step |
37 | * by the following parameters: | |
38 | * - a unique id string/name | |
39 | * - the id of the component | |
40 | * - the ids of the configurations it requires input from | |
41 | * - the arguments, which are passed to the component when it is initialized | |
3495cce2 | 42 | * |
0c0c9d99 | 43 | * The setup of a configuration requires simply the creation of a global object |
bfccbf68 | 44 | * of @ref AliHLTConfiguration. The Configuration is automatically registered |
45 | * in the list of available configurations maintained by the @ref | |
0c0c9d99 | 46 | * AliHLTConfigurationHandler. The list is used by to resolve the dependencies |
47 | * on other configurations. Hierarchies can be built up in an easy way. | |
3495cce2 | 48 | * |
bfccbf68 | 49 | * A configuration is interpreted by the @ref AliHLTConfigurationHandler and |
0c0c9d99 | 50 | * transformed into a Task List. |
b22e91eb | 51 | * |
52 | * @note This class is only used for the @ref alihlt_system. | |
53 | * | |
54 | * @ingroup alihlt_system | |
3495cce2 | 55 | */ |
56 | class AliHLTConfiguration : public TObject, public AliHLTLogging { | |
57 | public: | |
0c0c9d99 | 58 | /** |
59 | * standard constructor. The configuration is automatically registered in the | |
60 | * global configuration manager | |
61 | */ | |
3495cce2 | 62 | AliHLTConfiguration(); |
0c0c9d99 | 63 | /** |
64 | * constructor. The configuration is automatically registered in the | |
65 | * global configuration manager | |
66 | * @param id unique id of the configuration | |
67 | * @param component component id | |
68 | * @param sources blank separated list of source configuration ids | |
69 | * @param arguments argument string passed to the component at initialization | |
70 | */ | |
71 | AliHLTConfiguration(const char* id, const char* component, | |
72 | const char* sources, const char* arguments); | |
fc455fba | 73 | /** copy constructor */ |
74 | AliHLTConfiguration(const AliHLTConfiguration& src); | |
75 | /** assignment op */ | |
76 | AliHLTConfiguration& operator=(const AliHLTConfiguration& src); | |
0c0c9d99 | 77 | /** destructor */ |
3495cce2 | 78 | virtual ~AliHLTConfiguration(); |
79 | ||
0c0c9d99 | 80 | /***************************************************************************** |
85465857 | 81 | * global initialization |
82 | */ | |
0c0c9d99 | 83 | |
84 | /** | |
85 | * Global initialization of the configuration handler. | |
86 | */ | |
85465857 | 87 | static int GlobalInit(AliHLTConfigurationHandler* pHandler); |
88 | ||
0c0c9d99 | 89 | /** |
90 | * Global de-init and cleanup of the global configuration handler | |
91 | */ | |
fc455fba | 92 | static int GlobalDeinit(AliHLTConfigurationHandler* pHandler); |
85465857 | 93 | |
0c0c9d99 | 94 | /***************************************************************************** |
95 | * properties of the configuration | |
3495cce2 | 96 | */ |
97 | ||
0c0c9d99 | 98 | /** |
99 | * Get configuration id, a unique name | |
100 | * This is an overridden TObject function in order to return the configuration | |
101 | * name instead of the class name. Enables use of TList standard functions. | |
102 | * @return configuration id | |
103 | */ | |
3495cce2 | 104 | const char *GetName() const; |
105 | ||
0c0c9d99 | 106 | /** |
107 | * Get id of the component. | |
108 | * The id is a unique string. | |
109 | * @return id of the component | |
110 | */ | |
70ed7d01 | 111 | const char* GetComponentID() const {return fComponent;} |
3495cce2 | 112 | |
0c0c9d99 | 113 | /** |
114 | * Print status info. | |
115 | * Short summary on id, component, sources and unresolved sources. | |
116 | */ | |
3495cce2 | 117 | void PrintStatus(); |
118 | ||
0c0c9d99 | 119 | /** |
120 | * Get a certain source. | |
121 | * @param id of the source configuration | |
122 | * @result pointer to the corresponding configuration descriptor | |
123 | */ | |
3495cce2 | 124 | AliHLTConfiguration* GetSource(const char* id); |
125 | ||
0c0c9d99 | 126 | /** |
127 | * Try to find a dependency recursively in the list of sources. | |
128 | * @param id the source to search for | |
129 | * @param pTgtList (optional) target list to receive the dependency tree | |
130 | * @return | |
131 | * 0 if not found | |
132 | * n found in the n-th level | |
133 | * dependency list in the target list | |
134 | */ | |
3495cce2 | 135 | int FollowDependency(const char* id, TList* pTgtList=NULL); |
136 | ||
0c0c9d99 | 137 | /** |
138 | * Get the number of resolved sources. | |
139 | * @return number of resolved sources | |
140 | */ | |
3495cce2 | 141 | int GetNofSources() {return fListSources.size();} |
142 | ||
0c0c9d99 | 143 | /** |
144 | * Check resolving status. | |
145 | * @param bAuto resolve if ==1 | |
146 | * @return 1 if all sources resolved | |
147 | */ | |
3495cce2 | 148 | int SourcesResolved(int bAuto=0); |
149 | ||
0c0c9d99 | 150 | /** |
151 | * Start iteration and get the first source. | |
152 | * @result pointer to the first configuration descriptor | |
153 | */ | |
3495cce2 | 154 | AliHLTConfiguration* GetFirstSource(); |
155 | ||
0c0c9d99 | 156 | /** |
157 | * Continue iteration and get the next source. | |
158 | * @result pointer to the next configuration descriptor in the list | |
159 | */ | |
3495cce2 | 160 | AliHLTConfiguration* GetNextSource(); |
161 | ||
0c0c9d99 | 162 | /** |
163 | * Invalidate a dependency and mark the configuration to be re-evaluted. | |
164 | * @param pConf pointer to configuration descriptor | |
165 | */ | |
3495cce2 | 166 | int InvalidateSource(AliHLTConfiguration* pConf); |
167 | ||
0c0c9d99 | 168 | /** |
169 | * Mark the configuration to be re-evaluted. | |
170 | */ | |
3495cce2 | 171 | int InvalidateSources() {fNofSources=-1; return 0;} |
172 | ||
0c0c9d99 | 173 | /** |
174 | * Get the arguments array. | |
175 | * @param pArgv pointer to receive argument array pointer | |
176 | * @return argc if succeeded, neg. error code if failed | |
177 | */ | |
178 | int GetArguments(const char*** pArgv); | |
3495cce2 | 179 | |
180 | protected: | |
181 | ||
3495cce2 | 182 | |
183 | private: | |
184 | /* extract the source configurations from the sources string | |
185 | */ | |
186 | int ExtractSources(); | |
187 | ||
188 | /* extract arguments from the argument string | |
189 | */ | |
190 | int ExtractArguments(); | |
191 | ||
70ed7d01 | 192 | /** |
193 | * Helper function to build a vector from an argument string | |
194 | * @param arg pointer to argument string | |
195 | * @param argList target to receive the argument list | |
3495cce2 | 196 | */ |
197 | int InterpreteString(const char* arg, vector<char*>& argList); | |
198 | ||
0c0c9d99 | 199 | /** id of this configuration */ |
52c1c164 | 200 | TString fID; // see above |
0c0c9d99 | 201 | /** component id of this configuration */ |
52c1c164 | 202 | TString fComponent; // see above |
3495cce2 | 203 | |
0c0c9d99 | 204 | /** the <i>sources</i> string as passed to the constructor */ |
52c1c164 | 205 | TString fStringSources; // see above |
0c0c9d99 | 206 | /** number of resolved sources, -1 indicates re-evaluation */ |
70ed7d01 | 207 | int fNofSources; // see above |
0c0c9d99 | 208 | /** list of sources */ |
70ed7d01 | 209 | vector<AliHLTConfiguration*> fListSources; // see above |
0c0c9d99 | 210 | /** iterator for the above list */ |
70ed7d01 | 211 | vector<AliHLTConfiguration*>::iterator fListSrcElement; // see above |
0c0c9d99 | 212 | |
213 | /** | |
214 | * The argument string as passed to the constructor. | |
215 | * Specifies the arguments for the Analysys component. The string will | |
216 | * be parsed and the separated arguments stored in the @ref fArgv array | |
217 | * and @ref fArgc member. | |
218 | */ | |
52c1c164 | 219 | TString fArguments; // see above |
0c0c9d99 | 220 | /** number of arguments */ |
70ed7d01 | 221 | int fArgc; // see above |
0c0c9d99 | 222 | /** argument array */ |
70ed7d01 | 223 | char** fArgv; // see above |
3495cce2 | 224 | |
70ed7d01 | 225 | /** the instance of the global configuration handler */ |
226 | static AliHLTConfigurationHandler* fgConfigurationHandler; //! transient | |
85465857 | 227 | |
3495cce2 | 228 | ClassDef(AliHLTConfiguration, 0); |
229 | }; | |
230 | ||
3495cce2 | 231 | #endif |