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
19 #include "AliHLTDataTypes.h"
20 #include "AliHLTLogging.h"
21 #include "AliHLTDataBuffer.h"
23 class AliHLTConfigurationHandler;
26 * @class AliHLTConfiguration
27 * @brief Description of HLT processing chains.
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
36 * The definition of a configuration requires simply the creation of an object
37 * of type @ref AliHLTConfiguration.
39 * AliHLTConfiguration myprocessor("MyProcessor", "Dummy", "publisher", "-output_percentage 80")
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.
50 * The registration mechanism requires the HLT system to be available. The
51 * global instance of AliHLTSystem is created and retrieved by
53 * // setup the HLT system
54 * AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
57 * A configuration is transformed into a list of AliHLTTask objects by the
58 * function AliHLTSystem::BuildTaskList().
60 * This class is only used in the HLT offline environment, see @ref alihlt_system
63 * @ingroup alihlt_system
65 class AliHLTConfiguration : public TObject, public AliHLTLogging {
68 * standard constructor. The configuration is automatically registered in the
69 * global configuration manager
71 AliHLTConfiguration();
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
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'
82 AliHLTConfiguration(const char* id, const char* component,
83 const char* sources, const char* arguments,
84 const char* bufsize=NULL);
85 /** copy constructor */
86 AliHLTConfiguration(const AliHLTConfiguration& src);
88 AliHLTConfiguration& operator=(const AliHLTConfiguration& src);
90 virtual ~AliHLTConfiguration();
92 /*****************************************************************************
93 * global initialization
97 * Global initialization of the configuration handler.
99 static int GlobalInit(AliHLTConfigurationHandler* pHandler);
102 * Global de-init and cleanup of the global configuration handler
104 static int GlobalDeinit(AliHLTConfigurationHandler* pHandler);
106 /*****************************************************************************
107 * properties of the configuration
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
116 const char *GetName() const;
119 * Get id of the component.
120 * The id is a unique string.
121 * @return id of the component
123 const char* GetComponentID() const {return fComponent;}
126 * Return the source string.
128 const char* GetSourceSettings() const {return fStringSources;}
131 * Return the argument string.
133 const char* GetArgumentSettings() const {return fArguments;}
137 * Short summary on id, component, sources and unresolved sources.
139 void PrintStatus() const;
142 * overloaded from TObject
144 * status - print status including the resolved sources
146 virtual void Print(const char* option="") const;
149 * Get a certain source.
150 * @param id of the source configuration
151 * @result pointer to the corresponding configuration descriptor
153 AliHLTConfiguration* GetSource(const char* id);
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
161 * n found in the n-th level
162 * dependency list in the target list
164 int FollowDependency(const char* id, TList* pTgtList=NULL);
167 * Get the number of resolved sources.
168 * @return number of resolved sources
170 int GetNofSources() {return fListSources.size();}
173 * Check resolving status.
174 * @return 1 if all sources resolved, 0 if not yet extracted or not resolved
176 int SourcesResolved() const;
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
183 int ExtractSources();
186 * Start iteration and get the first source.
187 * @result pointer to the first configuration descriptor
189 AliHLTConfiguration* GetFirstSource() const;
192 * Continue iteration and get the next source.
193 * @result pointer to the next configuration descriptor in the list
195 AliHLTConfiguration* GetNextSource() const;
198 * Invalidate a dependency and mark the configuration to be re-evaluted.
199 * @param pConf pointer to configuration descriptor
201 int InvalidateSource(AliHLTConfiguration* pConf);
204 * Mark the configuration to be re-evaluted.
206 int InvalidateSources() {fNofSources=-1; return 0;}
209 * Get the arguments array.
210 * @param pArgv pointer to receive argument array pointer
211 * @return argc if succeeded, neg. error code if failed
213 int GetArguments(const char*** pArgv) const;
216 * Get output buffer size.
217 * @return size in byte or -1 if not specified
219 int GetOutputBufferSize() const {return fBufferSize;}
222 * Two configurations are considered equal if all properties match
224 bool operator==(const AliHLTConfiguration& c) const {
225 return (fID==c.fID) && (fComponent==c.fComponent) && (fStringSources==c.fStringSources) && (fArguments==c.fArguments);
227 bool operator!=(const AliHLTConfiguration& c) const {
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
238 static int InterpreteString(const char* arg, vector<char*>& argList);
244 /* extract arguments from the argument string
246 int ExtractArguments();
249 * Convert buffer size string to number
251 int ConvertSizeString(const char* strSize) const;
253 /** id of this configuration */
254 TString fID; // see above
255 /** component id of this configuration */
256 TString fComponent; // see above
258 /** the <i>sources</i> string as passed to the constructor */
259 TString fStringSources; // see above
260 /** number of resolved sources, -1 indicates re-evaluation */
261 int fNofSources; //! transient
262 /** list of sources */
263 vector<AliHLTConfiguration*> fListSources; //! transient
264 /** index of the current element in the list of sources */
265 int fListSrcElementIdx; //! transient
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.
273 TString fArguments; // see above
274 /** number of arguments */
275 int fArgc; //! transient
276 /** argument array */
277 char** fArgv; //! transient
279 /** size of the output buffer */
280 int fBufferSize; // see above
282 /** the instance of the global configuration handler */
283 static AliHLTConfigurationHandler* fgConfigurationHandler; //! transient
285 ClassDef(AliHLTConfiguration, 1);