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 HLT configuration description for a single component.
14 // @note The class is used in Offline (AliRoot) context
16 // see below for class documentation
18 // refer to README to build package
20 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
25 #include "AliHLTDataTypes.h"
26 #include "AliHLTLogging.h"
27 #include "AliHLTDataBuffer.h"
29 class AliHLTConfigurationHandler;
32 * @class AliHLTConfiguration
33 * @brief Description of HLT processing chains.
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
42 * The definition of a configuration requires simply the creation of an object
43 * of type @ref AliHLTConfiguration.
45 * AliHLTConfiguration myprocessor("MyProcessor", "Dummy", "publisher", "-output_percentage 80")
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.
56 * The registration mechanism requires the HLT system to be available. The
57 * global instance of AliHLTSystem is created and retrieved by
59 * // setup the HLT system
60 * AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
63 * A configuration is transformed into a list of AliHLTTask objects by the
64 * function AliHLTSystem::BuildTaskList().
66 * This class is only used in the HLT offline environment, see @ref alihlt_system
69 * @ingroup alihlt_system
71 class AliHLTConfiguration : public TObject, public AliHLTLogging {
74 * standard constructor. The configuration is automatically registered in the
75 * global configuration manager
77 AliHLTConfiguration();
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
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'
88 AliHLTConfiguration(const char* id, const char* component,
89 const char* sources, const char* arguments,
90 const char* bufsize=NULL);
91 /** copy constructor */
92 AliHLTConfiguration(const AliHLTConfiguration& src);
94 AliHLTConfiguration& operator=(const AliHLTConfiguration& src);
96 virtual ~AliHLTConfiguration();
98 /*****************************************************************************
99 * global initialization
103 * Global initialization of the configuration handler.
105 static int GlobalInit(AliHLTConfigurationHandler* pHandler);
108 * Global de-init and cleanup of the global configuration handler
110 static int GlobalDeinit(AliHLTConfigurationHandler* pHandler);
112 /*****************************************************************************
113 * properties of the configuration
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
122 const char *GetName() const;
125 * Get id of the component.
126 * The id is a unique string.
127 * @return id of the component
129 const char* GetComponentID() const {return fComponent;}
132 * Return the source string.
134 const char* GetSourceSettings() const {return fStringSources;}
137 * Return the argument string.
139 const char* GetArgumentSettings() const {return fArguments;}
143 * Short summary on id, component, sources and unresolved sources.
148 * Get a certain source.
149 * @param id of the source configuration
150 * @result pointer to the corresponding configuration descriptor
152 AliHLTConfiguration* GetSource(const char* id);
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
160 * n found in the n-th level
161 * dependency list in the target list
163 int FollowDependency(const char* id, TList* pTgtList=NULL);
166 * Get the number of resolved sources.
167 * @return number of resolved sources
169 int GetNofSources() {return fListSources.size();}
172 * Check resolving status.
173 * @param bAuto resolve if ==1
174 * @return 1 if all sources resolved
176 int SourcesResolved(int bAuto=0);
179 * Start iteration and get the first source.
180 * @result pointer to the first configuration descriptor
182 AliHLTConfiguration* GetFirstSource();
185 * Continue iteration and get the next source.
186 * @result pointer to the next configuration descriptor in the list
188 AliHLTConfiguration* GetNextSource();
191 * Invalidate a dependency and mark the configuration to be re-evaluted.
192 * @param pConf pointer to configuration descriptor
194 int InvalidateSource(AliHLTConfiguration* pConf);
197 * Mark the configuration to be re-evaluted.
199 int InvalidateSources() {fNofSources=-1; return 0;}
202 * Get the arguments array.
203 * @param pArgv pointer to receive argument array pointer
204 * @return argc if succeeded, neg. error code if failed
206 int GetArguments(const char*** pArgv) const;
209 * Get output buffer size.
210 * @return size in byte or -1 if not specified
212 int GetOutputBufferSize() const {return fBufferSize;}
215 * Two configurations are considered equal if all properties match
217 bool operator==(const AliHLTConfiguration& c) const {
218 return (fID==c.fID) && (fComponent==c.fComponent) && (fStringSources==c.fStringSources) && (fArguments==c.fArguments);
220 bool operator!=(const AliHLTConfiguration& c) const {
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
231 static int InterpreteString(const char* arg, vector<char*>& argList);
237 /* extract the source configurations from the sources string
239 int ExtractSources();
241 /* extract arguments from the argument string
243 int ExtractArguments();
246 * Convert buffer size string to number
248 int ConvertSizeString(const char* strSize) const;
250 /** id of this configuration */
251 TString fID; // see above
252 /** component id of this configuration */
253 TString fComponent; // see above
255 /** the <i>sources</i> string as passed to the constructor */
256 TString fStringSources; // see above
257 /** number of resolved sources, -1 indicates re-evaluation */
258 int fNofSources; // see above
259 /** list of sources */
260 vector<AliHLTConfiguration*> fListSources; // see above
261 /** iterator for the above list */
262 vector<AliHLTConfiguration*>::iterator fListSrcElement; // see above
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.
270 TString fArguments; // see above
271 /** number of arguments */
272 int fArgc; // see above
273 /** argument array */
274 char** fArgv; // see above
276 /** size of the output buffer */
277 int fBufferSize; // see above
279 /** the instance of the global configuration handler */
280 static AliHLTConfigurationHandler* fgConfigurationHandler; //! transient
282 ClassDef(AliHLTConfiguration, 0);