4 #ifndef ALIHLTCONFIGURATION_H
5 #define ALIHLTCONFIGURATION_H
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 */
10 /** @file AliHLTConfiguration.h
11 @author Matthias Richter
13 @brief Base class and handling of HLT configurations.
14 @note The class is used in Offline (AliRoot) context
17 // see below for class documentation
19 // refer to README to build package
21 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
26 #include "AliHLTDataTypes.h"
27 #include "AliHLTLogging.h"
28 #include "AliHLTDataBuffer.h"
30 class AliHLTConfigurationHandler;
33 * @class AliHLTConfiguration
34 * @brief Description of HLT processing chains.
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
43 * The setup of a configuration requires simply the creation of a global object
44 * of @ref AliHLTConfiguration. The Configuration is automatically registered
45 * in the list of available configurations maintained by the @ref
46 * AliHLTConfigurationHandler. The list is used by to resolve the dependencies
47 * on other configurations. Hierarchies can be built up in an easy way.
49 * A configuration is interpreted by the @ref AliHLTConfigurationHandler and
50 * transformed into a Task List.
52 * @note This class is only used for the @ref alihlt_system.
54 * @ingroup alihlt_system
56 class AliHLTConfiguration : public TObject, public AliHLTLogging {
59 * standard constructor. The configuration is automatically registered in the
60 * global configuration manager
62 AliHLTConfiguration();
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
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'
73 AliHLTConfiguration(const char* id, const char* component,
74 const char* sources, const char* arguments,
75 const char* bufsize=NULL);
76 /** copy constructor */
77 AliHLTConfiguration(const AliHLTConfiguration& src);
79 AliHLTConfiguration& operator=(const AliHLTConfiguration& src);
81 virtual ~AliHLTConfiguration();
83 /*****************************************************************************
84 * global initialization
88 * Global initialization of the configuration handler.
90 static int GlobalInit(AliHLTConfigurationHandler* pHandler);
93 * Global de-init and cleanup of the global configuration handler
95 static int GlobalDeinit(AliHLTConfigurationHandler* pHandler);
97 /*****************************************************************************
98 * properties of the configuration
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
107 const char *GetName() const;
110 * Get id of the component.
111 * The id is a unique string.
112 * @return id of the component
114 const char* GetComponentID() const {return fComponent;}
117 * Return the source string.
119 const char* GetSourceSettings() const {return fStringSources;}
122 * Return the argument string.
124 const char* GetArgumentSettings() const {return fArguments;}
128 * Short summary on id, component, sources and unresolved sources.
133 * Get a certain source.
134 * @param id of the source configuration
135 * @result pointer to the corresponding configuration descriptor
137 AliHLTConfiguration* GetSource(const char* id);
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
145 * n found in the n-th level
146 * dependency list in the target list
148 int FollowDependency(const char* id, TList* pTgtList=NULL);
151 * Get the number of resolved sources.
152 * @return number of resolved sources
154 int GetNofSources() {return fListSources.size();}
157 * Check resolving status.
158 * @param bAuto resolve if ==1
159 * @return 1 if all sources resolved
161 int SourcesResolved(int bAuto=0);
164 * Start iteration and get the first source.
165 * @result pointer to the first configuration descriptor
167 AliHLTConfiguration* GetFirstSource();
170 * Continue iteration and get the next source.
171 * @result pointer to the next configuration descriptor in the list
173 AliHLTConfiguration* GetNextSource();
176 * Invalidate a dependency and mark the configuration to be re-evaluted.
177 * @param pConf pointer to configuration descriptor
179 int InvalidateSource(AliHLTConfiguration* pConf);
182 * Mark the configuration to be re-evaluted.
184 int InvalidateSources() {fNofSources=-1; return 0;}
187 * Get the arguments array.
188 * @param pArgv pointer to receive argument array pointer
189 * @return argc if succeeded, neg. error code if failed
191 int GetArguments(const char*** pArgv);
194 * Get output buffer size.
195 * @return size in byte or -1 if not specified
197 int GetOutputBufferSize() const {return fBufferSize;}
200 * Two configurations are considered equal if all properties match
202 bool operator==(const AliHLTConfiguration& c) const {
203 return (fID==c.fID) && (fComponent==c.fComponent) && (fStringSources==c.fStringSources) && (fArguments==c.fArguments);
205 bool operator!=(const AliHLTConfiguration& c) const {
210 * Helper function to build a vector from an argument string.
211 * The function allocates memory for each token. The caller is responsible
212 * for cleaning the strings recursively.
213 * @param arg pointer to argument string
214 * @param argList target to receive the argument list
216 static int InterpreteString(const char* arg, vector<char*>& argList);
222 /* extract the source configurations from the sources string
224 int ExtractSources();
226 /* extract arguments from the argument string
228 int ExtractArguments();
231 * Convert buffer size string to number
233 int ConvertSizeString(const char* strSize) const;
235 /** id of this configuration */
236 TString fID; // see above
237 /** component id of this configuration */
238 TString fComponent; // see above
240 /** the <i>sources</i> string as passed to the constructor */
241 TString fStringSources; // see above
242 /** number of resolved sources, -1 indicates re-evaluation */
243 int fNofSources; // see above
244 /** list of sources */
245 vector<AliHLTConfiguration*> fListSources; // see above
246 /** iterator for the above list */
247 vector<AliHLTConfiguration*>::iterator fListSrcElement; // see above
250 * The argument string as passed to the constructor.
251 * Specifies the arguments for the Analysys component. The string will
252 * be parsed and the separated arguments stored in the @ref fArgv array
253 * and @ref fArgc member.
255 TString fArguments; // see above
256 /** number of arguments */
257 int fArgc; // see above
258 /** argument array */
259 char** fArgv; // see above
261 /** size of the output buffer */
262 int fBufferSize; // see above
264 /** the instance of the global configuration handler */
265 static AliHLTConfigurationHandler* fgConfigurationHandler; //! transient
267 ClassDef(AliHLTConfiguration, 0);