]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTModuleAgent.h
HLT sample applications
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTModuleAgent.h
1 // @(#) $Id$
2
3 #ifndef ALIHLTMODULEAGENT_H
4 #define ALIHLTMODULEAGENT_H
5 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6  * See cxx source for full Copyright notice                               */
7
8 /** @file   AliHLTModuleAgent.h
9     @author Matthias Richter
10     @date   
11     @brief  Agent helper class for component libraries.
12     @note   The class is used in Offline (AliRoot) context
13 */
14
15 #include <TObject.h>
16 #include <TList.h>
17 #include "AliHLTLogging.h"
18 #include "AliHLTConfiguration.h"
19 #include "AliHLTConfigurationHandler.h"
20
21 class AliRunLoader;
22
23 /**
24  * @class AliHLTModuleAgent
25  * @brief Agent helper class for HLT sub modules, e.g. PHOS, TPC, Trigger
26  *
27  * This class implements the agent base class for the HLT sub modules.
28  * The agent of a library gives information on the features of the library/
29  * components, like the configurations to run and other component libraries
30  * it depends on.
31  * @note There must not be more than one agent per module/library.
32  *
33  * All HLT component libraries are loaded on demand through the HLT steering
34  * instance (@ref AliHLTSystem). A library can implement an agent derived 
35  * from this base class, and has to define one global object of this agent
36  * in the code. The agent will be registered automatically, and the features
37  * can be queried when required.
38  *
39  * This is usually done during running the AliRoot reconstruction (see AliRoot
40  * documentation on <tt> AliReconstruction</tt>). The HLT implemets the @ref
41  * AliHLTReconstructor which holds the HLT steering object. Several flags can
42  * be specified as options via the <tt>SetOption</tt> method of 
43  * <tt>AliReconstruction</tt>, including the component libraries to be loaded.
44  *
45  * @section alihltmoduleagent_interface Agent interface
46  * The child can implement the following functions:
47  * - @ref CreateConfigurations                                              <br>
48  *       create HLT configuration forming an HLT analysis chain.
49  *
50  * - @ref GetLocalRecConfigurations                                         <br>
51  *       configurations run during local event reconstruction. 
52  *       @note Local event reconstruction is the first step of the 
53  *       reconstruction chain. All events are processed at once.
54  *                                                                          <br>
55  * - @ref GetEventRecConfigurations                                         <br>
56  *       configurations run during event reconstruction.
57  *       @note This is the reconstruction on event by event basis.
58  *                                                                          <br>
59  * - @ref GetRequiredComponentLibraries                                     <br>
60  *       can indicate further libraries which are required for running the
61  *       chains (e.g. if components of another library are used).
62  *
63  * - @ref RegisterComponents                                                <br>
64  *       register componens, this can be used to avoid the component
65  *       registration via global objects 
66  *       @see @ref alihltcomponent-handling
67  *                                                                          <br>
68  * @section alihltmoduleagent_references References
69  * @see @ref AliHLTReconstructor interface to the AliRoot reconstruction
70  * @see @ref AliHLTAgentSample agent for the libAliHLTSample library
71  *
72  * @ingroup alihlt_system
73  */
74 class AliHLTModuleAgent : public TObject, public AliHLTLogging {
75  public:
76   /**
77    * standard constructor. The agent is automatically registered in the
78    * global agent manager
79    */
80   AliHLTModuleAgent();
81   /** not a valid copy constructor, defined according to effective C++ style */
82   AliHLTModuleAgent(const AliHLTModuleAgent&);
83   /** not a valid assignment op, but defined according to effective C++ style */
84   AliHLTModuleAgent& operator=(const AliHLTModuleAgent&);
85   /** destructor */
86   virtual ~AliHLTModuleAgent();
87
88   /**
89    * Print status info.
90    * Short summary on registered agents. This function acts globally on the
91    * list of agents if no specific agent is specified.
92    */
93   static void PrintStatus(const char* agent=NULL);
94
95   /**
96    * Get the first agent in the list
97    * @return  pointer to first agent in the list, NULL if empty
98    */
99   static AliHLTModuleAgent* GetFirstAgent();
100
101   /**
102    * Get the next agent in the list
103    * @return  pointer to next agent in the list, NULL if end of list
104    */
105   static AliHLTModuleAgent* GetNextAgent();
106
107   /**
108    * Register all configurations belonging to this module with the
109    * AliHLTConfigurationHandler. The agent can adapt the configurations
110    * to be registered to the current AliRoot setup by checking the
111    * runloader.
112    * @param handler   [in] the configuration handler
113    * @param runloader [in] AliRoot runloader
114    * @return neg. error code if failed
115    */
116   virtual int CreateConfigurations(AliHLTConfigurationHandler* handler,
117                                    AliRunLoader* runloader=NULL) const;
118
119   /**
120    * Get the top configurations for local event reconstruction.
121    * A top configuration describes a processing chain. It can simply be
122    * described by the last configuration(s) in the chain. 
123    * The agent can adapt the configurations to be registered to the current
124    * AliRoot setup by checking the runloader.
125    * @param runloader  [in] AliRoot runloader
126    * @return string containing the top configurations separated by blanks
127    */
128   virtual const char* GetLocalRecConfigurations(AliRunLoader* runloader=NULL) const;
129
130   /**
131    * Get the top configurations for event reconstruction.
132    * The same as for @ref GetLocalRecConfigurations, but for the reconstruction on
133    * event by event basis.
134    * @param runloader  [in] AliRoot runloader
135    * @return string containing the top configurations separated by blanks
136    */
137   virtual const char* GetEventRecConfigurations(AliRunLoader* runloader=NULL) const;
138
139   /**
140    * Component libraries which the configurations of this agent depend on.
141    * @return list of component libraries as a blank-separated string.
142    */
143   virtual const char* GetRequiredComponentLibraries() const;
144
145   /**
146    * Register componets.
147    * This method can be used to register components for the module instead
148    * of the 'static object approach'. Registration is don by passing a
149    * sample object to @ref AliHLTComponentHandler::RegisterComponent<br>
150    * \em Note: The sample object is owned by the agent, make sure to delete
151    * it.
152    */
153   virtual int RegisterComponents(AliRunLoader* runloader=NULL) const;
154
155   /**
156    * Old method kept for backward compatibility, redirected to @ref
157    * GetLocalRecConfigurations.
158    */
159   const char* GetTopConfigurations(AliRunLoader* runloader=NULL) const {
160     return GetLocalRecConfigurations(runloader);
161   }
162
163  protected:
164
165  private:
166   /**
167    * Register agent in the global list.
168    * @return neg. error code if failed
169    */
170   static int Register(AliHLTModuleAgent* pAgent);
171
172   /**
173    * Unregister agent in the global list.
174    * @return neg. error code if failed
175    */
176   static int Unregister(AliHLTModuleAgent* pAgent);
177
178   /** the list of active agents */
179   static TList fgAgentList;
180
181   /** the current object link (list position) */
182   static TObjLink* fgCurrentLnk;
183
184   ClassDef(AliHLTModuleAgent, 0);
185 };
186
187 #endif