]>
Commit | Line | Data |
---|---|---|
30338a30 | 1 | //-*- Mode: C++ -*- |
c38ba6f9 | 2 | // $Id$ |
3 | ||
4 | #ifndef ALIHLTCONFIGURATIONHANDLER_H | |
5 | #define ALIHLTCONFIGURATIONHANDLER_H | |
c515df4c | 6 | ///* This file is property of and copyright by the * |
4403fb69 | 7 | ///* ALICE Experiment at CERN, All rights reserved. * |
8 | ///* See cxx source for full Copyright notice * | |
9 | ||
10 | /// @file AliHLTConfigurationHandler.h | |
11 | /// @author Matthias Richter | |
12 | /// @date | |
13 | /// @brief Global handling of HLT configurations. | |
14 | /// | |
30338a30 | 15 | |
c38ba6f9 | 16 | #include <TList.h> |
c38ba6f9 | 17 | |
7a436c89 | 18 | #include "AliHLTLogging.h" |
52c1c164 | 19 | class AliHLTConfiguration; |
e7b1a4ad | 20 | class TMap; |
52c1c164 | 21 | |
b22e91eb | 22 | /** |
23 | * @class AliHLTConfigurationHandler | |
24 | * @brief Global Handling of HLT configurations. | |
25 | * | |
26 | * This class implements the global handling of @ref AliHLTConfiguration objects. | |
ef802306 | 27 | * It is a list of all configuration descriptors currently available in the system. |
28 | * Each @ref AliHLTConfiguration object is registered automatically with the | |
b22e91eb | 29 | * handler and put into the list. |
30 | * | |
31 | * @note This class is only used for the @ref alihlt_system. | |
32 | * | |
33 | * @ingroup alihlt_system | |
34 | */ | |
c38ba6f9 | 35 | class AliHLTConfigurationHandler : public AliHLTLogging { |
36 | public: | |
b22e91eb | 37 | /** standard constructor */ |
c38ba6f9 | 38 | AliHLTConfigurationHandler(); |
b22e91eb | 39 | |
b22e91eb | 40 | /** destructor */ |
c38ba6f9 | 41 | virtual ~AliHLTConfigurationHandler(); |
42 | ||
b005ef92 | 43 | /***************************************************************************** |
44 | * singleton handling | |
45 | */ | |
46 | ||
47 | /** | |
48 | * Create an instance from the global sigleton. | |
49 | * Instance has to be destroyed by the Destroy function | |
50 | */ | |
51 | static AliHLTConfigurationHandler* CreateHandler(); | |
52 | ||
53 | /** | |
54 | * Destroy an instance of the global singleton retrieved by | |
55 | * AliHLTConfigurationHandler::CreateHandler() | |
56 | */ | |
57 | int Destroy(); | |
58 | ||
4403fb69 | 59 | /** |
60 | * Get the instance of the global singleton. | |
ef802306 | 61 | * Does not create the global instance. |
4403fb69 | 62 | */ |
63 | static AliHLTConfigurationHandler* Instance() { | |
ef802306 | 64 | if (!fgpInstance) return NULL; |
4403fb69 | 65 | return fgpInstance; |
66 | } | |
67 | ||
68 | /***************************************************************************** | |
ef802306 | 69 | * activation, affects if the handler will accept new registrations |
4403fb69 | 70 | */ |
71 | ||
ef802306 | 72 | /** |
73 | * Deactivate the handler, AliHLTConfiguration objects will not register | |
74 | * @param schedule Store and schedule registrations pending reactivation | |
75 | */ | |
76 | int Deactivate(bool schedule=false); | |
4403fb69 | 77 | |
ef802306 | 78 | /** |
79 | * Activate the handler, AliHLTConfiguration objects will register again | |
80 | */ | |
81 | int Activate(); | |
4403fb69 | 82 | |
83 | /// check if active | |
84 | bool IsActive() const {return (fFlags&kInactive)==0;} | |
ef802306 | 85 | |
86 | /// check if scheduling | |
87 | bool IsScheduling() const {return (fFlags&kScheduling)>0;} | |
88 | ||
89 | /// clear scheduled registrations | |
90 | void ClearScheduledRegistrations() {fgListScheduledRegistrations.Delete();} | |
4403fb69 | 91 | |
92 | /// signal a missed registration | |
93 | static int MissedRegistration(const char* name=NULL); | |
94 | ||
c38ba6f9 | 95 | /***************************************************************************** |
96 | * registration | |
97 | */ | |
98 | ||
b22e91eb | 99 | /** |
100 | * Register a configuration to the global list of configurations. | |
101 | * @param pConf The configuration to register | |
102 | */ | |
c38ba6f9 | 103 | int RegisterConfiguration(AliHLTConfiguration* pConf); |
104 | ||
b22e91eb | 105 | /** |
106 | * Create a configuration and register it. | |
107 | * @param id | |
108 | * @param component | |
109 | * @param sources | |
110 | * @param arguments | |
111 | */ | |
c38ba6f9 | 112 | int CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments); |
113 | ||
b22e91eb | 114 | /** |
115 | * Remove a configuration from the global list. | |
116 | * @param pConf The configuration to remove | |
117 | */ | |
c38ba6f9 | 118 | int RemoveConfiguration(AliHLTConfiguration* pConf); |
b22e91eb | 119 | |
120 | /** | |
121 | * Remove a configuration from the global list. | |
122 | * @param id The configuration to remove | |
123 | */ | |
c38ba6f9 | 124 | int RemoveConfiguration(const char* id); |
125 | ||
b22e91eb | 126 | /** |
127 | * Find a configuration from the global list. | |
128 | * @param id Id of the configuration to find | |
129 | */ | |
c38ba6f9 | 130 | AliHLTConfiguration* FindConfiguration(const char* id); |
131 | ||
b22e91eb | 132 | /** |
133 | * Print the registered configurations to the logging function. | |
134 | */ | |
c38ba6f9 | 135 | void PrintConfigurations(); |
136 | ||
4403fb69 | 137 | /** |
138 | * Print info | |
139 | * Options: | |
140 | * - treeroot=configuration print the dependency tree for a configuration | |
141 | * default PrintConfigurations | |
142 | */ | |
143 | void Print(const char* option=""); | |
144 | ||
e7b1a4ad | 145 | /** |
146 | * Add a component substitution by component id. | |
147 | * All components of the specified component id will be replaced by the | |
148 | * substitution component, the component arguments are replaced accordingly. | |
149 | * Component substitution is in particular useful if the input to a specific | |
150 | * component should be written to file. | |
151 | */ | |
152 | static int AddSubstitution(const char* componentId, const AliHLTConfiguration& subst); | |
153 | ||
154 | /** | |
155 | * Add a component substitution by configuration id. | |
156 | * The component of the specified configuration will be replaced by the | |
157 | * substitution component, the component arguments are replaced accordingly. | |
158 | * Component substitution is in particular useful if the input to a specific | |
159 | * component should be written to file. | |
160 | */ | |
161 | static int AddSubstitution(const AliHLTConfiguration& conf , const AliHLTConfiguration& subst); | |
162 | ||
163 | /** | |
164 | * Find component substitution. | |
165 | */ | |
166 | static const AliHLTConfiguration* FindSubstitution(const AliHLTConfiguration& conf); | |
c38ba6f9 | 167 | |
168 | private: | |
4403fb69 | 169 | enum { |
ef802306 | 170 | kInactive = 0x1, |
171 | kScheduling = 0x2 | |
4403fb69 | 172 | }; |
173 | ||
b22e91eb | 174 | /** the list of registered configurations */ |
4403fb69 | 175 | TList fgListConfigurations; // see above |
ef802306 | 176 | |
177 | /** list of configurations scheduled to be registered */ | |
178 | TList fgListScheduledRegistrations; // see above | |
4403fb69 | 179 | |
180 | /** status of the handler */ | |
181 | unsigned fFlags; //! transient | |
c38ba6f9 | 182 | |
b005ef92 | 183 | /** the global singleton */ |
4403fb69 | 184 | static AliHLTConfigurationHandler* fgpInstance; //!transient |
b005ef92 | 185 | /** number of used instances of the global singleton */ |
186 | static int fgNofInstances; //!transient | |
187 | ||
e7b1a4ad | 188 | /// component substitution map |
189 | /// key: either TObjString with component id or AliHLTConfiguration object | |
4403fb69 | 190 | static TMap* fgpSubstitutions; //!transient |
e7b1a4ad | 191 | |
192 | ClassDef(AliHLTConfigurationHandler, 0); | |
c38ba6f9 | 193 | }; |
194 | ||
195 | #endif |