]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTConfiguration.h
workaround for ROOT bug: in order to avoid crashes when unloading
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTConfiguration.h
CommitLineData
3495cce2 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
0c0c9d99 8/** @file AliHLTConfiguration.h
9 @author Matthias Richter
10 @date
b22e91eb 11 @brief Base class and handling of HLT configurations.
12 @note The class is used in Offline (AliRoot) context
0c0c9d99 13*/
3495cce2 14
3b35e87c 15#include <cerrno>
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 *
0c0c9d99 29 * This class describes a certain configuration af an HLT processing step
30 * by the following parameters:
31 * - a unique id string/name
32 * - the id of the component
33 * - the ids of the configurations it requires input from
34 * - the arguments, which are passed to the component when it is initialized
3495cce2 35 *
0c0c9d99 36 * The setup of a configuration requires simply the creation of a global object
bfccbf68 37 * of @ref AliHLTConfiguration. The Configuration is automatically registered
38 * in the list of available configurations maintained by the @ref
0c0c9d99 39 * AliHLTConfigurationHandler. The list is used by to resolve the dependencies
40 * on other configurations. Hierarchies can be built up in an easy way.
3495cce2 41 *
bfccbf68 42 * A configuration is interpreted by the @ref AliHLTConfigurationHandler and
0c0c9d99 43 * transformed into a Task List.
b22e91eb 44 *
45 * @note This class is only used for the @ref alihlt_system.
46 *
47 * @ingroup alihlt_system
3495cce2 48 */
49class AliHLTConfiguration : public TObject, public AliHLTLogging {
50 public:
0c0c9d99 51 /**
52 * standard constructor. The configuration is automatically registered in the
53 * global configuration manager
54 */
3495cce2 55 AliHLTConfiguration();
0c0c9d99 56 /**
57 * constructor. The configuration is automatically registered in the
58 * global configuration manager
59 * @param id unique id of the configuration
60 * @param component component id
61 * @param sources blank separated list of source configuration ids
62 * @param arguments argument string passed to the component at initialization
63 */
64 AliHLTConfiguration(const char* id, const char* component,
65 const char* sources, const char* arguments);
fc455fba 66 /** copy constructor */
67 AliHLTConfiguration(const AliHLTConfiguration& src);
68 /** assignment op */
69 AliHLTConfiguration& operator=(const AliHLTConfiguration& src);
0c0c9d99 70 /** destructor */
3495cce2 71 virtual ~AliHLTConfiguration();
72
0c0c9d99 73 /*****************************************************************************
85465857 74 * global initialization
75 */
0c0c9d99 76
77 /**
78 * Global initialization of the configuration handler.
79 */
85465857 80 static int GlobalInit(AliHLTConfigurationHandler* pHandler);
81
0c0c9d99 82 /**
83 * Global de-init and cleanup of the global configuration handler
84 */
fc455fba 85 static int GlobalDeinit(AliHLTConfigurationHandler* pHandler);
85465857 86
0c0c9d99 87 /*****************************************************************************
88 * properties of the configuration
3495cce2 89 */
90
0c0c9d99 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 */
3495cce2 97 const char *GetName() const;
98
0c0c9d99 99 /**
100 * Get id of the component.
101 * The id is a unique string.
102 * @return id of the component
103 */
70ed7d01 104 const char* GetComponentID() const {return fComponent;}
3495cce2 105
0c0c9d99 106 /**
107 * Print status info.
108 * Short summary on id, component, sources and unresolved sources.
109 */
3495cce2 110 void PrintStatus();
111
0c0c9d99 112 /**
113 * Get a certain source.
114 * @param id of the source configuration
115 * @result pointer to the corresponding configuration descriptor
116 */
3495cce2 117 AliHLTConfiguration* GetSource(const char* id);
118
0c0c9d99 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 */
3495cce2 128 int FollowDependency(const char* id, TList* pTgtList=NULL);
129
0c0c9d99 130 /**
131 * Get the number of resolved sources.
132 * @return number of resolved sources
133 */
3495cce2 134 int GetNofSources() {return fListSources.size();}
135
0c0c9d99 136 /**
137 * Check resolving status.
138 * @param bAuto resolve if ==1
139 * @return 1 if all sources resolved
140 */
3495cce2 141 int SourcesResolved(int bAuto=0);
142
0c0c9d99 143 /**
144 * Start iteration and get the first source.
145 * @result pointer to the first configuration descriptor
146 */
3495cce2 147 AliHLTConfiguration* GetFirstSource();
148
0c0c9d99 149 /**
150 * Continue iteration and get the next source.
151 * @result pointer to the next configuration descriptor in the list
152 */
3495cce2 153 AliHLTConfiguration* GetNextSource();
154
0c0c9d99 155 /**
156 * Invalidate a dependency and mark the configuration to be re-evaluted.
157 * @param pConf pointer to configuration descriptor
158 */
3495cce2 159 int InvalidateSource(AliHLTConfiguration* pConf);
160
0c0c9d99 161 /**
162 * Mark the configuration to be re-evaluted.
163 */
3495cce2 164 int InvalidateSources() {fNofSources=-1; return 0;}
165
0c0c9d99 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);
3495cce2 172
173 protected:
174
3495cce2 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
70ed7d01 185 /**
186 * Helper function to build a vector from an argument string
187 * @param arg pointer to argument string
188 * @param argList target to receive the argument list
3495cce2 189 */
190 int InterpreteString(const char* arg, vector<char*>& argList);
191
0c0c9d99 192 /** id of this configuration */
52c1c164 193 TString fID; // see above
0c0c9d99 194 /** component id of this configuration */
52c1c164 195 TString fComponent; // see above
3495cce2 196
0c0c9d99 197 /** the <i>sources</i> string as passed to the constructor */
52c1c164 198 TString fStringSources; // see above
0c0c9d99 199 /** number of resolved sources, -1 indicates re-evaluation */
70ed7d01 200 int fNofSources; // see above
0c0c9d99 201 /** list of sources */
70ed7d01 202 vector<AliHLTConfiguration*> fListSources; // see above
0c0c9d99 203 /** iterator for the above list */
70ed7d01 204 vector<AliHLTConfiguration*>::iterator fListSrcElement; // see above
0c0c9d99 205
206 /**
207 * The argument string as passed to the constructor.
208 * Specifies the arguments for the Analysys component. The string will
209 * be parsed and the separated arguments stored in the @ref fArgv array
210 * and @ref fArgc member.
211 */
52c1c164 212 TString fArguments; // see above
0c0c9d99 213 /** number of arguments */
70ed7d01 214 int fArgc; // see above
0c0c9d99 215 /** argument array */
70ed7d01 216 char** fArgv; // see above
3495cce2 217
70ed7d01 218 /** the instance of the global configuration handler */
219 static AliHLTConfigurationHandler* fgConfigurationHandler; //! transient
85465857 220
3495cce2 221 ClassDef(AliHLTConfiguration, 0);
222};
223
3495cce2 224#endif