]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTConfigurationHandler.h
flat friends update
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTConfigurationHandler.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 #ifndef ALIHLTCONFIGURATIONHANDLER_H
5 #define ALIHLTCONFIGURATIONHANDLER_H
6 ///* This file is property of and copyright by the                          * 
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 ///
15
16 #include <TList.h>
17
18 #include "AliHLTLogging.h"
19 class AliHLTConfiguration;
20 class TMap;
21
22 /**
23  * @class AliHLTConfigurationHandler
24  * @brief Global Handling of HLT configurations.
25  *
26  * This class implements the global handling of @ref AliHLTConfiguration objects.
27  * It is a list of all configuration descriptors currently available in the system.
28  * Each @ref AliHLTConfiguration object is registered automatically with the
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  */
35 class AliHLTConfigurationHandler : public AliHLTLogging {
36  public:
37   /** standard constructor */
38   AliHLTConfigurationHandler();
39   
40   /** destructor */
41   virtual ~AliHLTConfigurationHandler();
42
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
59   /**
60    * Get the instance of the global singleton.
61    * Does not create the global instance.
62    */
63   static AliHLTConfigurationHandler* Instance() {
64     if (!fgpInstance) return NULL;
65     return fgpInstance;
66   }
67
68   /*****************************************************************************
69    * activation, affects if the handler will accept new registrations
70    */
71
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);
77
78   /**
79    * Activate the handler, AliHLTConfiguration objects will register again
80    */
81   int Activate();
82
83   /// check if active
84   bool IsActive() const {return (fFlags&kInactive)==0;}
85   
86   /// check if scheduling
87   bool IsScheduling() const {return (fFlags&kScheduling)>0;}
88   
89   /// clear scheduled registrations
90   void ClearScheduledRegistrations() {fgListScheduledRegistrations.Delete();}
91
92   /// signal a missed registration
93   static int MissedRegistration(const char* name=NULL);
94
95   /*****************************************************************************
96    * registration
97    */
98
99   /**
100    * Register a configuration to the global list of configurations.
101    * @param pConf     The configuration to register
102    */
103   int RegisterConfiguration(AliHLTConfiguration* pConf);
104
105   /**
106    * Create a configuration and register it.
107    * @param id
108    * @param component
109    * @param sources
110    * @param arguments
111    */
112   int CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
113
114   /**
115    * Remove a configuration from the global list.
116    * @param pConf     The configuration to remove
117    */
118   int RemoveConfiguration(AliHLTConfiguration* pConf);
119
120   /**
121    * Remove a configuration from the global list.
122    * @param id     The configuration to remove
123    */
124   int RemoveConfiguration(const char* id);
125
126   /**
127    * Find a configuration from the global list.
128    * @param id     Id of the configuration to find
129    */
130   AliHLTConfiguration* FindConfiguration(const char* id);
131
132   /**
133    * Print the registered configurations to the logging function.
134    */
135   void PrintConfigurations();
136
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
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);
167
168  private:
169   enum {
170     kInactive = 0x1,
171     kScheduling = 0x2
172   };
173
174   /** the list of registered configurations */
175   TList fgListConfigurations;                                      // see above
176   
177   /** list of configurations scheduled to be registered */
178   TList fgListScheduledRegistrations;                              // see above
179
180   /** status of the handler */
181   unsigned fFlags;                                                 //! transient
182
183   /** the global singleton */
184   static AliHLTConfigurationHandler* fgpInstance;                  //!transient
185   /** number of used instances of the global singleton */
186   static int fgNofInstances;                                       //!transient 
187
188   /// component substitution map
189   /// key: either TObjString with component id or AliHLTConfiguration object
190   static TMap* fgpSubstitutions;                                   //!transient 
191
192   ClassDef(AliHLTConfigurationHandler, 0);
193 };
194
195 #endif