]>
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 | |
032c5e5e | 70 | * @param bufsize size of the output buffer in byte, the string can contain a |
71 | * number prepended by a unit, e.g. 1M, allowed units 'k' and 'M' | |
0c0c9d99 | 72 | */ |
73 | AliHLTConfiguration(const char* id, const char* component, | |
032c5e5e | 74 | const char* sources, const char* arguments, |
75 | const char* bufsize=NULL); | |
fc455fba | 76 | /** copy constructor */ |
77 | AliHLTConfiguration(const AliHLTConfiguration& src); | |
78 | /** assignment op */ | |
79 | AliHLTConfiguration& operator=(const AliHLTConfiguration& src); | |
0c0c9d99 | 80 | /** destructor */ |
3495cce2 | 81 | virtual ~AliHLTConfiguration(); |
82 | ||
0c0c9d99 | 83 | /***************************************************************************** |
85465857 | 84 | * global initialization |
85 | */ | |
0c0c9d99 | 86 | |
87 | /** | |
88 | * Global initialization of the configuration handler. | |
89 | */ | |
85465857 | 90 | static int GlobalInit(AliHLTConfigurationHandler* pHandler); |
91 | ||
0c0c9d99 | 92 | /** |
93 | * Global de-init and cleanup of the global configuration handler | |
94 | */ | |
fc455fba | 95 | static int GlobalDeinit(AliHLTConfigurationHandler* pHandler); |
85465857 | 96 | |
0c0c9d99 | 97 | /***************************************************************************** |
98 | * properties of the configuration | |
3495cce2 | 99 | */ |
100 | ||
0c0c9d99 | 101 | /** |
102 | * Get configuration id, a unique name | |
103 | * This is an overridden TObject function in order to return the configuration | |
104 | * name instead of the class name. Enables use of TList standard functions. | |
105 | * @return configuration id | |
106 | */ | |
3495cce2 | 107 | const char *GetName() const; |
108 | ||
0c0c9d99 | 109 | /** |
110 | * Get id of the component. | |
111 | * The id is a unique string. | |
112 | * @return id of the component | |
113 | */ | |
70ed7d01 | 114 | const char* GetComponentID() const {return fComponent;} |
3495cce2 | 115 | |
19b5c321 | 116 | /** |
117 | * Return the source string. | |
118 | */ | |
119 | const char* GetSourceSettings() const {return fStringSources;} | |
120 | ||
121 | /** | |
122 | * Return the argument string. | |
123 | */ | |
124 | const char* GetArgumentSettings() const {return fArguments;} | |
125 | ||
0c0c9d99 | 126 | /** |
127 | * Print status info. | |
128 | * Short summary on id, component, sources and unresolved sources. | |
129 | */ | |
3495cce2 | 130 | void PrintStatus(); |
131 | ||
0c0c9d99 | 132 | /** |
133 | * Get a certain source. | |
134 | * @param id of the source configuration | |
135 | * @result pointer to the corresponding configuration descriptor | |
136 | */ | |
3495cce2 | 137 | AliHLTConfiguration* GetSource(const char* id); |
138 | ||
0c0c9d99 | 139 | /** |
140 | * Try to find a dependency recursively in the list of sources. | |
141 | * @param id the source to search for | |
142 | * @param pTgtList (optional) target list to receive the dependency tree | |
143 | * @return | |
144 | * 0 if not found | |
145 | * n found in the n-th level | |
146 | * dependency list in the target list | |
147 | */ | |
3495cce2 | 148 | int FollowDependency(const char* id, TList* pTgtList=NULL); |
149 | ||
0c0c9d99 | 150 | /** |
151 | * Get the number of resolved sources. | |
152 | * @return number of resolved sources | |
153 | */ | |
3495cce2 | 154 | int GetNofSources() {return fListSources.size();} |
155 | ||
0c0c9d99 | 156 | /** |
157 | * Check resolving status. | |
158 | * @param bAuto resolve if ==1 | |
159 | * @return 1 if all sources resolved | |
160 | */ | |
3495cce2 | 161 | int SourcesResolved(int bAuto=0); |
162 | ||
0c0c9d99 | 163 | /** |
164 | * Start iteration and get the first source. | |
165 | * @result pointer to the first configuration descriptor | |
166 | */ | |
3495cce2 | 167 | AliHLTConfiguration* GetFirstSource(); |
168 | ||
0c0c9d99 | 169 | /** |
170 | * Continue iteration and get the next source. | |
171 | * @result pointer to the next configuration descriptor in the list | |
172 | */ | |
3495cce2 | 173 | AliHLTConfiguration* GetNextSource(); |
174 | ||
0c0c9d99 | 175 | /** |
176 | * Invalidate a dependency and mark the configuration to be re-evaluted. | |
177 | * @param pConf pointer to configuration descriptor | |
178 | */ | |
3495cce2 | 179 | int InvalidateSource(AliHLTConfiguration* pConf); |
180 | ||
0c0c9d99 | 181 | /** |
182 | * Mark the configuration to be re-evaluted. | |
183 | */ | |
3495cce2 | 184 | int InvalidateSources() {fNofSources=-1; return 0;} |
185 | ||
0c0c9d99 | 186 | /** |
187 | * Get the arguments array. | |
188 | * @param pArgv pointer to receive argument array pointer | |
189 | * @return argc if succeeded, neg. error code if failed | |
190 | */ | |
191 | int GetArguments(const char*** pArgv); | |
3495cce2 | 192 | |
032c5e5e | 193 | /** |
194 | * Get output buffer size. | |
195 | * @return size in byte or -1 if not specified | |
196 | */ | |
197 | int GetOutputBufferSize() const {return fBufferSize;} | |
d4a18597 | 198 | |
199 | /** | |
200 | * Two configurations are considered equal if all properties match | |
201 | */ | |
202 | bool operator==(const AliHLTConfiguration& c) const { | |
203 | return (fID==c.fID) && (fComponent==c.fComponent) && (fStringSources==c.fStringSources) && (fArguments==c.fArguments); | |
204 | } | |
205 | bool operator!=(const AliHLTConfiguration& c) const { | |
206 | return !(*this==c); | |
207 | } | |
208 | ||
3495cce2 | 209 | protected: |
210 | ||
3495cce2 | 211 | |
212 | private: | |
213 | /* extract the source configurations from the sources string | |
214 | */ | |
215 | int ExtractSources(); | |
216 | ||
217 | /* extract arguments from the argument string | |
218 | */ | |
219 | int ExtractArguments(); | |
220 | ||
70ed7d01 | 221 | /** |
222 | * Helper function to build a vector from an argument string | |
223 | * @param arg pointer to argument string | |
224 | * @param argList target to receive the argument list | |
3495cce2 | 225 | */ |
032c5e5e | 226 | int InterpreteString(const char* arg, vector<char*>& argList) const; |
227 | ||
228 | /** | |
229 | * Convert buffer size string to number | |
230 | */ | |
231 | int ConvertSizeString(const char* strSize) const; | |
3495cce2 | 232 | |
0c0c9d99 | 233 | /** id of this configuration */ |
52c1c164 | 234 | TString fID; // see above |
0c0c9d99 | 235 | /** component id of this configuration */ |
52c1c164 | 236 | TString fComponent; // see above |
3495cce2 | 237 | |
0c0c9d99 | 238 | /** the <i>sources</i> string as passed to the constructor */ |
52c1c164 | 239 | TString fStringSources; // see above |
0c0c9d99 | 240 | /** number of resolved sources, -1 indicates re-evaluation */ |
70ed7d01 | 241 | int fNofSources; // see above |
0c0c9d99 | 242 | /** list of sources */ |
70ed7d01 | 243 | vector<AliHLTConfiguration*> fListSources; // see above |
0c0c9d99 | 244 | /** iterator for the above list */ |
70ed7d01 | 245 | vector<AliHLTConfiguration*>::iterator fListSrcElement; // see above |
0c0c9d99 | 246 | |
247 | /** | |
248 | * The argument string as passed to the constructor. | |
249 | * Specifies the arguments for the Analysys component. The string will | |
250 | * be parsed and the separated arguments stored in the @ref fArgv array | |
251 | * and @ref fArgc member. | |
252 | */ | |
52c1c164 | 253 | TString fArguments; // see above |
0c0c9d99 | 254 | /** number of arguments */ |
70ed7d01 | 255 | int fArgc; // see above |
0c0c9d99 | 256 | /** argument array */ |
70ed7d01 | 257 | char** fArgv; // see above |
3495cce2 | 258 | |
032c5e5e | 259 | /** size of the output buffer */ |
260 | int fBufferSize; // see above | |
261 | ||
70ed7d01 | 262 | /** the instance of the global configuration handler */ |
263 | static AliHLTConfigurationHandler* fgConfigurationHandler; //! transient | |
85465857 | 264 | |
3495cce2 | 265 | ClassDef(AliHLTConfiguration, 0); |
266 | }; | |
267 | ||
3495cce2 | 268 | #endif |