]>
Commit | Line | Data |
---|---|---|
30338a30 | 1 | //-*- Mode: C++ -*- |
030da833 | 2 | // $Id$ |
3495cce2 | 3 | |
4 | #ifndef ALIHLTCONFIGURATION_H | |
5 | #define ALIHLTCONFIGURATION_H | |
030da833 | 6 | //* This file is property of and copyright by the ALICE HLT Project * |
7 | //* ALICE Experiment at CERN, All rights reserved. * | |
8 | //* See cxx source for full Copyright notice * | |
3495cce2 | 9 | |
030da833 | 10 | // @file AliHLTConfiguration.h |
11 | // @author Matthias Richter | |
12 | // @date | |
13 | // @brief HLT configuration description for a single component. | |
14 | // @note The class is used in Offline (AliRoot) context | |
3495cce2 | 15 | |
30338a30 | 16 | // see below for class documentation |
17 | // or | |
18 | // refer to README to build package | |
19 | // or | |
20 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
21 | ||
8ede8717 | 22 | #include <vector> |
3495cce2 | 23 | #include <TObject.h> |
24 | #include <TList.h> | |
25 | #include "AliHLTDataTypes.h" | |
26 | #include "AliHLTLogging.h" | |
0c0c9d99 | 27 | #include "AliHLTDataBuffer.h" |
3495cce2 | 28 | |
85465857 | 29 | class AliHLTConfigurationHandler; |
0c0c9d99 | 30 | |
31 | /** | |
32 | * @class AliHLTConfiguration | |
bfccbf68 | 33 | * @brief Description of HLT processing chains. |
b22e91eb | 34 | * |
030da833 | 35 | * This class describes a configuration for an HLT component by means of |
36 | * the following parameters: | |
37 | * - configuration id: a unique id string/name | |
38 | * - component id: id returned by AliHLTComponent::GetComponentID() | |
39 | * - parent configuartions: ids of configurations it requires input from | |
40 | * - component arguments: passed to the component when it is initialized | |
3495cce2 | 41 | * |
030da833 | 42 | * The definition of a configuration requires simply the creation of an object |
43 | * of type @ref AliHLTConfiguration. | |
44 | * <pre> | |
45 | * AliHLTConfiguration myprocessor("MyProcessor", "Dummy", "publisher", "-output_percentage 80") | |
46 | * </pre> | |
3495cce2 | 47 | * |
030da833 | 48 | * The Configuration is automatically registered in the list of available |
49 | * configurations maintained by the @ref AliHLTConfigurationHandler. | |
50 | * The list is used to resolve the dependencies on other configurations. | |
51 | * Hierarchies can be built up by specifying the configuration id of parent | |
52 | * configurations as input in the . | |
53 | * A configuration entry is persistent and must be explicitly removed from | |
54 | * the AliHLTConfigurationHandler if desired. | |
b22e91eb | 55 | * |
030da833 | 56 | * The registration mechanism requires the HLT system to be available. The |
57 | * global instance of AliHLTSystem is created and retrieved by | |
58 | * <pre> | |
59 | * // setup the HLT system | |
60 | * AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance(); | |
61 | * </pre> | |
62 | * | |
63 | * A configuration is transformed into a list of AliHLTTask objects by the | |
64 | * function AliHLTSystem::BuildTaskList(). | |
65 | * | |
66 | * This class is only used in the HLT offline environment, see @ref alihlt_system | |
67 | * for more details. | |
b22e91eb | 68 | * |
69 | * @ingroup alihlt_system | |
3495cce2 | 70 | */ |
71 | class AliHLTConfiguration : public TObject, public AliHLTLogging { | |
72 | public: | |
0c0c9d99 | 73 | /** |
74 | * standard constructor. The configuration is automatically registered in the | |
75 | * global configuration manager | |
76 | */ | |
3495cce2 | 77 | AliHLTConfiguration(); |
0c0c9d99 | 78 | /** |
79 | * constructor. The configuration is automatically registered in the | |
80 | * global configuration manager | |
81 | * @param id unique id of the configuration | |
82 | * @param component component id | |
83 | * @param sources blank separated list of source configuration ids | |
84 | * @param arguments argument string passed to the component at initialization | |
032c5e5e | 85 | * @param bufsize size of the output buffer in byte, the string can contain a |
86 | * number prepended by a unit, e.g. 1M, allowed units 'k' and 'M' | |
0c0c9d99 | 87 | */ |
88 | AliHLTConfiguration(const char* id, const char* component, | |
032c5e5e | 89 | const char* sources, const char* arguments, |
90 | const char* bufsize=NULL); | |
fc455fba | 91 | /** copy constructor */ |
92 | AliHLTConfiguration(const AliHLTConfiguration& src); | |
93 | /** assignment op */ | |
94 | AliHLTConfiguration& operator=(const AliHLTConfiguration& src); | |
0c0c9d99 | 95 | /** destructor */ |
3495cce2 | 96 | virtual ~AliHLTConfiguration(); |
97 | ||
0c0c9d99 | 98 | /***************************************************************************** |
85465857 | 99 | * global initialization |
100 | */ | |
0c0c9d99 | 101 | |
102 | /** | |
103 | * Global initialization of the configuration handler. | |
104 | */ | |
85465857 | 105 | static int GlobalInit(AliHLTConfigurationHandler* pHandler); |
106 | ||
0c0c9d99 | 107 | /** |
108 | * Global de-init and cleanup of the global configuration handler | |
109 | */ | |
fc455fba | 110 | static int GlobalDeinit(AliHLTConfigurationHandler* pHandler); |
85465857 | 111 | |
0c0c9d99 | 112 | /***************************************************************************** |
113 | * properties of the configuration | |
3495cce2 | 114 | */ |
115 | ||
0c0c9d99 | 116 | /** |
117 | * Get configuration id, a unique name | |
118 | * This is an overridden TObject function in order to return the configuration | |
119 | * name instead of the class name. Enables use of TList standard functions. | |
120 | * @return configuration id | |
121 | */ | |
3495cce2 | 122 | const char *GetName() const; |
123 | ||
0c0c9d99 | 124 | /** |
125 | * Get id of the component. | |
126 | * The id is a unique string. | |
127 | * @return id of the component | |
128 | */ | |
70ed7d01 | 129 | const char* GetComponentID() const {return fComponent;} |
3495cce2 | 130 | |
19b5c321 | 131 | /** |
132 | * Return the source string. | |
133 | */ | |
134 | const char* GetSourceSettings() const {return fStringSources;} | |
135 | ||
136 | /** | |
137 | * Return the argument string. | |
138 | */ | |
139 | const char* GetArgumentSettings() const {return fArguments;} | |
140 | ||
0c0c9d99 | 141 | /** |
142 | * Print status info. | |
143 | * Short summary on id, component, sources and unresolved sources. | |
144 | */ | |
3495cce2 | 145 | void PrintStatus(); |
146 | ||
0c0c9d99 | 147 | /** |
148 | * Get a certain source. | |
149 | * @param id of the source configuration | |
150 | * @result pointer to the corresponding configuration descriptor | |
151 | */ | |
3495cce2 | 152 | AliHLTConfiguration* GetSource(const char* id); |
153 | ||
0c0c9d99 | 154 | /** |
155 | * Try to find a dependency recursively in the list of sources. | |
156 | * @param id the source to search for | |
157 | * @param pTgtList (optional) target list to receive the dependency tree | |
158 | * @return | |
159 | * 0 if not found | |
160 | * n found in the n-th level | |
161 | * dependency list in the target list | |
162 | */ | |
3495cce2 | 163 | int FollowDependency(const char* id, TList* pTgtList=NULL); |
164 | ||
0c0c9d99 | 165 | /** |
166 | * Get the number of resolved sources. | |
167 | * @return number of resolved sources | |
168 | */ | |
3495cce2 | 169 | int GetNofSources() {return fListSources.size();} |
170 | ||
0c0c9d99 | 171 | /** |
172 | * Check resolving status. | |
173 | * @param bAuto resolve if ==1 | |
174 | * @return 1 if all sources resolved | |
175 | */ | |
3495cce2 | 176 | int SourcesResolved(int bAuto=0); |
177 | ||
0c0c9d99 | 178 | /** |
179 | * Start iteration and get the first source. | |
180 | * @result pointer to the first configuration descriptor | |
181 | */ | |
3495cce2 | 182 | AliHLTConfiguration* GetFirstSource(); |
183 | ||
0c0c9d99 | 184 | /** |
185 | * Continue iteration and get the next source. | |
186 | * @result pointer to the next configuration descriptor in the list | |
187 | */ | |
3495cce2 | 188 | AliHLTConfiguration* GetNextSource(); |
189 | ||
0c0c9d99 | 190 | /** |
191 | * Invalidate a dependency and mark the configuration to be re-evaluted. | |
192 | * @param pConf pointer to configuration descriptor | |
193 | */ | |
3495cce2 | 194 | int InvalidateSource(AliHLTConfiguration* pConf); |
195 | ||
0c0c9d99 | 196 | /** |
197 | * Mark the configuration to be re-evaluted. | |
198 | */ | |
3495cce2 | 199 | int InvalidateSources() {fNofSources=-1; return 0;} |
200 | ||
0c0c9d99 | 201 | /** |
202 | * Get the arguments array. | |
203 | * @param pArgv pointer to receive argument array pointer | |
204 | * @return argc if succeeded, neg. error code if failed | |
205 | */ | |
d489ab09 | 206 | int GetArguments(const char*** pArgv) const; |
3495cce2 | 207 | |
032c5e5e | 208 | /** |
209 | * Get output buffer size. | |
210 | * @return size in byte or -1 if not specified | |
211 | */ | |
212 | int GetOutputBufferSize() const {return fBufferSize;} | |
d4a18597 | 213 | |
214 | /** | |
215 | * Two configurations are considered equal if all properties match | |
216 | */ | |
217 | bool operator==(const AliHLTConfiguration& c) const { | |
218 | return (fID==c.fID) && (fComponent==c.fComponent) && (fStringSources==c.fStringSources) && (fArguments==c.fArguments); | |
219 | } | |
220 | bool operator!=(const AliHLTConfiguration& c) const { | |
221 | return !(*this==c); | |
222 | } | |
223 | ||
4b31e06b | 224 | /** |
225 | * Helper function to build a vector from an argument string. | |
226 | * The function allocates memory for each token. The caller is responsible | |
227 | * for cleaning the strings recursively. | |
228 | * @param arg pointer to argument string | |
229 | * @param argList target to receive the argument list | |
230 | */ | |
231 | static int InterpreteString(const char* arg, vector<char*>& argList); | |
232 | ||
3495cce2 | 233 | protected: |
234 | ||
3495cce2 | 235 | |
236 | private: | |
237 | /* extract the source configurations from the sources string | |
238 | */ | |
239 | int ExtractSources(); | |
240 | ||
241 | /* extract arguments from the argument string | |
242 | */ | |
243 | int ExtractArguments(); | |
244 | ||
032c5e5e | 245 | /** |
246 | * Convert buffer size string to number | |
247 | */ | |
248 | int ConvertSizeString(const char* strSize) const; | |
3495cce2 | 249 | |
0c0c9d99 | 250 | /** id of this configuration */ |
52c1c164 | 251 | TString fID; // see above |
0c0c9d99 | 252 | /** component id of this configuration */ |
52c1c164 | 253 | TString fComponent; // see above |
3495cce2 | 254 | |
0c0c9d99 | 255 | /** the <i>sources</i> string as passed to the constructor */ |
52c1c164 | 256 | TString fStringSources; // see above |
0c0c9d99 | 257 | /** number of resolved sources, -1 indicates re-evaluation */ |
70ed7d01 | 258 | int fNofSources; // see above |
0c0c9d99 | 259 | /** list of sources */ |
70ed7d01 | 260 | vector<AliHLTConfiguration*> fListSources; // see above |
0c0c9d99 | 261 | /** iterator for the above list */ |
70ed7d01 | 262 | vector<AliHLTConfiguration*>::iterator fListSrcElement; // see above |
0c0c9d99 | 263 | |
264 | /** | |
265 | * The argument string as passed to the constructor. | |
266 | * Specifies the arguments for the Analysys component. The string will | |
267 | * be parsed and the separated arguments stored in the @ref fArgv array | |
268 | * and @ref fArgc member. | |
269 | */ | |
52c1c164 | 270 | TString fArguments; // see above |
0c0c9d99 | 271 | /** number of arguments */ |
70ed7d01 | 272 | int fArgc; // see above |
0c0c9d99 | 273 | /** argument array */ |
70ed7d01 | 274 | char** fArgv; // see above |
3495cce2 | 275 | |
032c5e5e | 276 | /** size of the output buffer */ |
277 | int fBufferSize; // see above | |
278 | ||
70ed7d01 | 279 | /** the instance of the global configuration handler */ |
280 | static AliHLTConfigurationHandler* fgConfigurationHandler; //! transient | |
85465857 | 281 | |
3495cce2 | 282 | ClassDef(AliHLTConfiguration, 0); |
283 | }; | |
284 | ||
3495cce2 | 285 | #endif |