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 * properties of the configuration
97 * Get configuration id, a unique name
98 * This is an overridden TObject function in order to return the configuration
99 * name instead of the class name. Enables use of TList standard functions.
100 * @return configuration id
102 const char *GetName() const;
105 * Get id of the component.
106 * The id is a unique string.
107 * @return id of the component
109 const char* GetComponentID() const {return fComponent;}
112 * Return the source string.
114 const char* GetSourceSettings() const {return fStringSources;}
117 * Return the argument string.
119 const char* GetArgumentSettings() const {return fArguments;}
123 * Short summary on id, component, sources and unresolved sources.
125 void PrintStatus() const;
128 * overloaded from TObject
130 * status - print status including the resolved sources
132 virtual void Print(const char* option="") const;
135 * Get a certain source.
136 * @param id of the source configuration
137 * @result pointer to the corresponding configuration descriptor
139 AliHLTConfiguration* GetSource(const char* id);
142 * Try to find a dependency recursively in the list of sources.
143 * @param id the source to search for
144 * @param pTgtList (optional) target list to receive the dependency tree
147 * n found in the n-th level
148 * dependency list in the target list
150 int FollowDependency(const char* id, TList* pTgtList=NULL);
153 * Get the number of resolved sources.
154 * @return number of resolved sources
156 int GetNofSources() {return fListSources.size();}
159 * Check resolving status.
160 * @return 1 if all sources resolved, 0 if not yet extracted or not resolved
162 int SourcesResolved() const;
165 * extract the source configurations from the sources string
166 * builds up the internal list of source configurations
167 * @result 1 if sources resolved, 0 if not
169 int ExtractSources(AliHLTConfigurationHandler* pHandler);
172 * Start iteration and get the first source.
173 * @result pointer to the first configuration descriptor
175 AliHLTConfiguration* GetFirstSource() const;
178 * Continue iteration and get the next source.
179 * @result pointer to the next configuration descriptor in the list
181 AliHLTConfiguration* GetNextSource() const;
184 * Invalidate a dependency and mark the configuration to be re-evaluted.
185 * @param pConf pointer to configuration descriptor
187 int InvalidateSource(AliHLTConfiguration* pConf);
190 * Mark the configuration to be re-evaluted.
192 int InvalidateSources() {fNofSources=-1; return 0;}
195 * Get the arguments array.
196 * @param pArgv pointer to receive argument array pointer
197 * @return argc if succeeded, neg. error code if failed
199 int GetArguments(const char*** pArgv) const;
202 * Get output buffer size.
203 * @return size in byte or -1 if not specified
205 int GetOutputBufferSize() const {return fBufferSize;}
208 * Two configurations are considered equal if all properties match
210 bool operator==(const AliHLTConfiguration& c) const {
211 return (fID==c.fID) && (fComponent==c.fComponent) && (fStringSources==c.fStringSources) && (fArguments==c.fArguments);
213 bool operator!=(const AliHLTConfiguration& c) const {
218 * Helper function to build a vector from an argument string.
219 * The function allocates memory for each token. The caller is responsible
220 * for cleaning the strings recursively.
221 * @param arg pointer to argument string
222 * @param argList target to receive the argument list
224 static int InterpreteString(const char* arg, vector<char*>& argList);
230 /* extract arguments from the argument string
232 int ExtractArguments();
235 * Convert buffer size string to number
237 int ConvertSizeString(const char* strSize) const;
239 /** id of this configuration */
240 TString fID; // see above
241 /** component id of this configuration */
242 TString fComponent; // see above
244 /** the <i>sources</i> string as passed to the constructor */
245 TString fStringSources; // see above
246 /** number of resolved sources, -1 indicates re-evaluation */
247 int fNofSources; //! transient
248 /** list of sources */
249 vector<AliHLTConfiguration*> fListSources; //! transient
250 /** index of the current element in the list of sources */
251 int fListSrcElementIdx; //! transient
254 * The argument string as passed to the constructor.
255 * Specifies the arguments for the Analysys component. The string will
256 * be parsed and the separated arguments stored in the @ref fArgv array
257 * and @ref fArgc member.
259 TString fArguments; // see above
260 /** number of arguments */
261 int fArgc; //! transient
262 /** argument array */
263 char** fArgv; //! transient
265 /** size of the output buffer */
266 int fBufferSize; // see above
268 ClassDef(AliHLTConfiguration, 0);