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