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