]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTConfiguration.h
The file publisher now closes files when it is done with them during a given event...
[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  Base class and handling of HLT configurations.
14     @note   The class is used in Offline (AliRoot) context
15 */
16
17 // see below for class documentation
18 // or
19 // refer to README to build package
20 // or
21 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt   
22
23 #include <cerrno>
24 #include <vector>
25 #include <TObject.h>
26 #include <TList.h>
27 #include "AliHLTDataTypes.h"
28 #include "AliHLTLogging.h"
29 #include "AliHLTDataBuffer.h"
30
31 class AliHLTConfigurationHandler;
32
33 /**
34  * @class AliHLTConfiguration
35  * @brief Description of HLT processing chains.
36  *
37  * This class describes a certain configuration af an HLT processing step
38  * by the following parameters:
39  * - a unique id string/name
40  * - the id of the component
41  * - the ids of the configurations it requires input from
42  * - the arguments, which are passed to the component when it is initialized
43  *
44  * The setup of a configuration requires simply the creation of a global object
45  * of @ref AliHLTConfiguration. The Configuration is automatically registered
46  * in the list of available configurations maintained by the @ref
47  * AliHLTConfigurationHandler. The list is used by to resolve the dependencies
48  * on other configurations. Hierarchies can be built up in an easy way.
49  *
50  * A configuration is interpreted by the @ref AliHLTConfigurationHandler and
51  * transformed into a Task List.
52  *
53  * @note This class is only used for the @ref alihlt_system.
54  *
55  * @ingroup alihlt_system
56  */
57 class AliHLTConfiguration : public TObject, public AliHLTLogging {
58  public:
59   /**
60    * standard constructor. The configuration is automatically registered in the
61    * global configuration manager
62    */
63   AliHLTConfiguration();
64   /**
65    * constructor. The configuration is automatically registered in the
66    * global configuration manager
67    * @param id         unique id of the configuration
68    * @param component  component id
69    * @param sources    blank separated list of source configuration ids
70    * @param arguments  argument string passed to the component at initialization
71    */
72   AliHLTConfiguration(const char* id, const char* component,
73                       const char* sources, const char* arguments);
74   /** copy constructor */
75   AliHLTConfiguration(const AliHLTConfiguration& src);
76   /** assignment op */
77   AliHLTConfiguration& operator=(const AliHLTConfiguration& src);
78   /** destructor */
79   virtual ~AliHLTConfiguration();
80
81   /*****************************************************************************
82    * global initialization
83    */
84
85   /**
86    * Global initialization of the configuration handler.
87    */
88   static int GlobalInit(AliHLTConfigurationHandler* pHandler);
89
90   /**
91    * Global de-init and cleanup of the global configuration handler
92    */
93   static int GlobalDeinit(AliHLTConfigurationHandler* pHandler);
94
95   /*****************************************************************************
96    * properties of the configuration
97    */
98
99   /**
100    * Get configuration id, a unique name
101    * This is an overridden TObject function in order to return the configuration
102    * name instead of the class name. Enables use of TList standard functions.
103    * @return configuration id
104    */
105   const char *GetName() const;
106
107   /**
108    * Get id of the component.
109    * The id is a unique string.
110    * @return id of the component
111    */
112   const char* GetComponentID() const {return fComponent;}
113
114   /**
115    * Print status info.
116    * Short summary on id, component, sources and unresolved sources.
117    */
118   void PrintStatus();
119
120   /**
121    * Get a certain source.
122    * @param  id of the source configuration
123    * @result pointer to the corresponding configuration descriptor
124    */
125   AliHLTConfiguration* GetSource(const char* id);
126
127   /**
128    * Try to find a dependency recursively in the list of sources.
129    * @param id       the source to search for
130    * @param pTgtList (optional) target list to receive the dependency tree
131    * @return
132    *   0 if not found
133    *   n found in the n-th level
134    *   dependency list in the target list  
135    */
136   int FollowDependency(const char* id, TList* pTgtList=NULL);
137
138   /**
139    * Get the number of resolved sources.
140    * @return number of resolved sources
141    */
142   int GetNofSources() {return fListSources.size();}
143
144   /**
145    * Check resolving status.
146    * @param bAuto resolve if ==1 
147    * @return 1 if all sources resolved
148    */
149   int SourcesResolved(int bAuto=0);
150
151   /**
152    * Start iteration and get the first source.
153    * @result pointer to the first configuration descriptor
154    */
155   AliHLTConfiguration* GetFirstSource();
156
157   /**
158    * Continue iteration and get the next source.
159    * @result pointer to the next configuration descriptor in the list
160    */
161   AliHLTConfiguration* GetNextSource();
162
163   /**
164    * Invalidate a dependency and mark the configuration to be re-evaluted. 
165    * @param pConf pointer to configuration descriptor
166    */
167   int InvalidateSource(AliHLTConfiguration* pConf);
168
169   /**
170    * Mark the configuration to be re-evaluted.
171    */
172   int InvalidateSources() {fNofSources=-1; return 0;}
173
174   /**
175    * Get the arguments array.
176    * @param pArgv   pointer to receive argument array pointer
177    * @return argc if succeeded, neg. error code if failed
178    */
179   int GetArguments(const char*** pArgv);
180
181  protected:
182   
183
184  private:
185   /* extract the source configurations from the sources string
186    */
187   int ExtractSources();
188
189   /* extract arguments from the argument string
190    */
191   int ExtractArguments();
192
193   /**
194    * Helper function to build a vector from an argument string
195    * @param arg       pointer to argument string
196    * @param argList   target to receive the argument list
197    */
198   int InterpreteString(const char* arg, vector<char*>& argList);
199
200   /** id of this configuration */
201   TString fID;                                                     // see above
202   /** component id of this configuration */
203   TString fComponent;                                              // see above
204
205   /** the <i>sources</i> string as passed to the constructor */
206   TString fStringSources;                                          // see above
207   /** number of resolved sources, -1 indicates re-evaluation */
208   int fNofSources;                                                 // see above
209   /** list of sources */
210   vector<AliHLTConfiguration*> fListSources;                       // see above
211   /** iterator for the above list */
212   vector<AliHLTConfiguration*>::iterator fListSrcElement;          // see above
213
214   /**
215    * The argument string as passed to the constructor.
216    * Specifies the arguments for the Analysys component. The string will
217    * be parsed and the separated arguments stored in the @ref fArgv array
218    * and @ref fArgc member.
219    */
220   TString fArguments;                                              // see above
221   /** number of arguments */
222   int fArgc;                                                       // see above
223   /** argument array */
224   char** fArgv;                                                    // see above
225
226   /** the instance of the global configuration handler */
227   static AliHLTConfigurationHandler* fgConfigurationHandler;       //! transient
228
229   ClassDef(AliHLTConfiguration, 0);
230 };
231
232 #endif