]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTConfiguration.h
correcting type in forward declaration
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTConfiguration.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
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                               *
9
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
15
16 #include <vector>
17 #include <TObject.h>
18 #include <TList.h>
19 #include "AliHLTDataTypes.h"
20 #include "AliHLTLogging.h"
21 #include "AliHLTDataBuffer.h"
22
23 class AliHLTConfigurationHandler;
24
25 /**
26  * @class AliHLTConfiguration
27  * @brief Description of HLT processing chains.
28  *
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
35  *
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>
41  *
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.
49  *
50  * The registration mechanism requires the HLT system to be available. The
51  * global instance of AliHLTSystem is created and retrieved by
52  * <pre>
53  *   // setup the HLT system
54  *   AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
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.
62  *
63  * @ingroup alihlt_system
64  */
65 class AliHLTConfiguration : public TObject, public AliHLTLogging {
66  public:
67   /**
68    * standard constructor. The configuration is automatically registered in the
69    * global configuration manager
70    */
71   AliHLTConfiguration();
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
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'
81    */
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);
87   /** assignment op */
88   AliHLTConfiguration& operator=(const AliHLTConfiguration& src);
89   /** destructor */
90   virtual ~AliHLTConfiguration();
91
92   /*****************************************************************************
93    * properties of the configuration
94    */
95
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    */
102   const char *GetName() const;
103
104   /**
105    * Get id of the component.
106    * The id is a unique string.
107    * @return id of the component
108    */
109   const char* GetComponentID() const {return fComponent;}
110
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
121   /**
122    * Print status info.
123    * Short summary on id, component, sources and unresolved sources.
124    */
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;
133
134   /**
135    * Get a certain source.
136    * @param  id of the source configuration
137    * @result pointer to the corresponding configuration descriptor
138    */
139   AliHLTConfiguration* GetSource(const char* id);
140
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    */
150   int FollowDependency(const char* id, TList* pTgtList=NULL);
151
152   /**
153    * Get the number of resolved sources.
154    * @return number of resolved sources
155    */
156   int GetNofSources() {return fListSources.size();}
157
158   /**
159    * Check resolving status.
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
168    */
169   int ExtractSources(AliHLTConfigurationHandler* pHandler);
170
171   /**
172    * Start iteration and get the first source.
173    * @result pointer to the first configuration descriptor
174    */
175   AliHLTConfiguration* GetFirstSource() const;
176
177   /**
178    * Continue iteration and get the next source.
179    * @result pointer to the next configuration descriptor in the list
180    */
181   AliHLTConfiguration* GetNextSource() const;
182
183   /**
184    * Invalidate a dependency and mark the configuration to be re-evaluted. 
185    * @param pConf pointer to configuration descriptor
186    */
187   int InvalidateSource(AliHLTConfiguration* pConf);
188
189   /**
190    * Mark the configuration to be re-evaluted.
191    */
192   int InvalidateSources() {fNofSources=-1; return 0;}
193
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    */
199   int GetArguments(const char*** pArgv) const;
200
201   /**
202    * Get output buffer size.
203    * @return size in byte or -1 if not specified
204    */
205   int GetOutputBufferSize() const {return fBufferSize;}
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
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
226  protected:
227   
228
229  private:
230   /* extract arguments from the argument string
231    */
232   int ExtractArguments();
233
234   /**
235    * Convert buffer size string to number
236    */
237   int ConvertSizeString(const char* strSize) const;
238
239   /** id of this configuration */
240   TString fID;                                                     // see above
241   /** component id of this configuration */
242   TString fComponent;                                              // see above
243
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
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    */
259   TString fArguments;                                              // see above
260   /** number of arguments */
261   int fArgc;                                                       //! transient
262   /** argument array */
263   char** fArgv;                                                    //! transient
264
265   /** size of the output buffer */
266   int fBufferSize;                                                 // see above
267
268   ClassDef(AliHLTConfiguration, 0);
269 };
270
271 #endif