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