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