]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTConfiguration.h
updated 2D drawing macros
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTConfiguration.h
CommitLineData
30338a30 1//-*- Mode: C++ -*-
030da833 2// $Id$
3495cce2 3
4#ifndef ALIHLTCONFIGURATION_H
5#define ALIHLTCONFIGURATION_H
c515df4c 6//* This file is property of and copyright by the *
030da833 7//* ALICE Experiment at CERN, All rights reserved. *
8//* See cxx source for full Copyright notice *
3495cce2 9
d174bfc3 10/// @file AliHLTConfiguration.h
11/// @author Matthias Richter
12/// @date
13/// @brief HLT configuration description for a single component.
14/// @note The class is used in Offline (AliRoot) context
30338a30 15
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 23class AliHLTConfigurationHandler;
0c0c9d99 24
25/**
26 * @class AliHLTConfiguration
bfccbf68 27 * @brief Description of HLT processing chains.
b22e91eb 28 *
030da833 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
3495cce2 35 *
030da833 36 * The definition of a configuration requires simply the creation of an object
37 * of type @ref AliHLTConfiguration.
38 * <pre>
39 * AliHLTConfiguration myprocessor("MyProcessor", "Dummy", "publisher", "-output_percentage 80")
40 * </pre>
3495cce2 41 *
030da833 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.
b22e91eb 49 *
030da833 50 * The registration mechanism requires the HLT system to be available. The
51 * global instance of AliHLTSystem is created and retrieved by
52 * <pre>
d174bfc3 53 * // setup the HLT system
54 * AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
030da833 55 * </pre>
56 *
57 * A configuration is transformed into a list of AliHLTTask objects by the
58 * function AliHLTSystem::BuildTaskList().
59 *
60 * This class is only used in the HLT offline environment, see @ref alihlt_system
61 * for more details.
b22e91eb 62 *
63 * @ingroup alihlt_system
3495cce2 64 */
65class AliHLTConfiguration : public TObject, public AliHLTLogging {
66 public:
0c0c9d99 67 /**
68 * standard constructor. The configuration is automatically registered in the
69 * global configuration manager
70 */
3495cce2 71 AliHLTConfiguration();
0c0c9d99 72 /**
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
032c5e5e 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'
0c0c9d99 81 */
82 AliHLTConfiguration(const char* id, const char* component,
032c5e5e 83 const char* sources, const char* arguments,
84 const char* bufsize=NULL);
fc455fba 85 /** copy constructor */
86 AliHLTConfiguration(const AliHLTConfiguration& src);
87 /** assignment op */
88 AliHLTConfiguration& operator=(const AliHLTConfiguration& src);
0c0c9d99 89 /** destructor */
3495cce2 90 virtual ~AliHLTConfiguration();
91
0c0c9d99 92 /*****************************************************************************
93 * properties of the configuration
3495cce2 94 */
95
0c0c9d99 96 /**
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
101 */
3495cce2 102 const char *GetName() const;
103
0c0c9d99 104 /**
105 * Get id of the component.
106 * The id is a unique string.
107 * @return id of the component
108 */
70ed7d01 109 const char* GetComponentID() const {return fComponent;}
3495cce2 110
19b5c321 111 /**
112 * Return the source string.
113 */
114 const char* GetSourceSettings() const {return fStringSources;}
115
116 /**
117 * Return the argument string.
118 */
119 const char* GetArgumentSettings() const {return fArguments;}
120
0c0c9d99 121 /**
122 * Print status info.
123 * Short summary on id, component, sources and unresolved sources.
124 */
d174bfc3 125 void PrintStatus() const;
126
127 /**
128 * overloaded from TObject
129 * options:
130 * status - print status including the resolved sources
131 */
132 virtual void Print(const char* option="") const;
3495cce2 133
0c0c9d99 134 /**
135 * Get a certain source.
136 * @param id of the source configuration
137 * @result pointer to the corresponding configuration descriptor
138 */
3495cce2 139 AliHLTConfiguration* GetSource(const char* id);
140
0c0c9d99 141 /**
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
145 * @return
146 * 0 if not found
147 * n found in the n-th level
148 * dependency list in the target list
149 */
3495cce2 150 int FollowDependency(const char* id, TList* pTgtList=NULL);
151
0c0c9d99 152 /**
153 * Get the number of resolved sources.
154 * @return number of resolved sources
155 */
3495cce2 156 int GetNofSources() {return fListSources.size();}
157
0c0c9d99 158 /**
159 * Check resolving status.
d174bfc3 160 * @return 1 if all sources resolved, 0 if not yet extracted or not resolved
161 */
162 int SourcesResolved() const;
163
164 /**
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
0c0c9d99 168 */
a869209c 169 int ExtractSources(AliHLTConfigurationHandler* pHandler);
3495cce2 170
0c0c9d99 171 /**
172 * Start iteration and get the first source.
173 * @result pointer to the first configuration descriptor
174 */
d174bfc3 175 AliHLTConfiguration* GetFirstSource() const;
3495cce2 176
0c0c9d99 177 /**
178 * Continue iteration and get the next source.
179 * @result pointer to the next configuration descriptor in the list
180 */
d174bfc3 181 AliHLTConfiguration* GetNextSource() const;
3495cce2 182
0c0c9d99 183 /**
184 * Invalidate a dependency and mark the configuration to be re-evaluted.
185 * @param pConf pointer to configuration descriptor
186 */
3495cce2 187 int InvalidateSource(AliHLTConfiguration* pConf);
188
0c0c9d99 189 /**
190 * Mark the configuration to be re-evaluted.
191 */
3495cce2 192 int InvalidateSources() {fNofSources=-1; return 0;}
193
0c0c9d99 194 /**
195 * Get the arguments array.
196 * @param pArgv pointer to receive argument array pointer
197 * @return argc if succeeded, neg. error code if failed
198 */
d489ab09 199 int GetArguments(const char*** pArgv) const;
3495cce2 200
032c5e5e 201 /**
202 * Get output buffer size.
203 * @return size in byte or -1 if not specified
204 */
205 int GetOutputBufferSize() const {return fBufferSize;}
d4a18597 206
207 /**
208 * Two configurations are considered equal if all properties match
209 */
210 bool operator==(const AliHLTConfiguration& c) const {
211 return (fID==c.fID) && (fComponent==c.fComponent) && (fStringSources==c.fStringSources) && (fArguments==c.fArguments);
212 }
213 bool operator!=(const AliHLTConfiguration& c) const {
214 return !(*this==c);
215 }
216
4b31e06b 217 /**
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
223 */
224 static int InterpreteString(const char* arg, vector<char*>& argList);
225
3495cce2 226 protected:
227
3495cce2 228
229 private:
3495cce2 230 /* extract arguments from the argument string
231 */
232 int ExtractArguments();
233
032c5e5e 234 /**
235 * Convert buffer size string to number
236 */
237 int ConvertSizeString(const char* strSize) const;
3495cce2 238
0c0c9d99 239 /** id of this configuration */
52c1c164 240 TString fID; // see above
0c0c9d99 241 /** component id of this configuration */
52c1c164 242 TString fComponent; // see above
3495cce2 243
0c0c9d99 244 /** the <i>sources</i> string as passed to the constructor */
52c1c164 245 TString fStringSources; // see above
0c0c9d99 246 /** number of resolved sources, -1 indicates re-evaluation */
d174bfc3 247 int fNofSources; //! transient
0c0c9d99 248 /** list of sources */
d174bfc3 249 vector<AliHLTConfiguration*> fListSources; //! transient
250 /** index of the current element in the list of sources */
251 int fListSrcElementIdx; //! transient
0c0c9d99 252
253 /**
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.
258 */
52c1c164 259 TString fArguments; // see above
0c0c9d99 260 /** number of arguments */
d174bfc3 261 int fArgc; //! transient
0c0c9d99 262 /** argument array */
d174bfc3 263 char** fArgv; //! transient
3495cce2 264
032c5e5e 265 /** size of the output buffer */
266 int fBufferSize; // see above
267
4403fb69 268 ClassDef(AliHLTConfiguration, 0);
3495cce2 269};
270
3495cce2 271#endif