All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DataOnDemandSvc.h
Go to the documentation of this file.
1 #ifndef GAUDISVC_DATAONDEMANDSVC_H
2 #define GAUDISVC_DATAONDEMANDSVC_H
3 // ============================================================================
4 // Include Files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <map>
9 #include <vector>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
13 #include "GaudiKernel/Service.h"
16 #include "GaudiKernel/StatEntity.h"
17 #include "GaudiKernel/StringKey.h"
20 // ============================================================================
21 // ROOT TClass
22 // ============================================================================
23 #include "TClass.h"
24 // ============================================================================
25 // Forward declarations
26 // ============================================================================
27 class IAlgTool;
28 class IAlgorithm;
29 class IAlgManager;
30 class IIncidentSvc;
31 class IDataProviderSvc;
32 class IToolSvc;
33 // ============================================================================
90 class DataOnDemandSvc: public extends1<Service, IIncidentListener>
91 {
92 public:
93  // ==========================================================================
94  // Typedefs
95  typedef std::vector<std::string> Setup;
96  typedef TClass* ClassH;
97  // ==========================================================================
102  struct Protection
103  {
104  bool& m_bool;
105  Protection(bool& b) : m_bool(b) { m_bool = true; }
106  ~Protection() { m_bool = false; }
107  };
108  // ==========================================================================
114  struct Node
115  {
116  // ========================================================================
118  ClassH clazz ; // the actual class
119  bool executing ;
120  std::string name ;
121  unsigned long num ;
123  bool dataObject ; // trivial object? DataObject?
124  // =======================================================================
126  : clazz ( )
127  , executing ( false )
128  , name ( )
129  , num ( 0 )
130  , dataObject ( false )
131  {}
132  // ========================================================================
134  bool e ,
135  const std::string& n )
136  : clazz ( c )
137  , executing ( e )
138  , name ( n )
139  , num ( 0 )
140  , dataObject ( "DataObject" == n )
141  {}
142  //
143  Node( const Node& c )
144  : clazz ( c.clazz )
145  , executing ( c.executing )
146  , name ( c.name )
147  , num ( c.num )
148  , dataObject ( c.dataObject )
149  {}
150  // ========================================================================
151  };
152  // ==========================================================================
154  struct Leaf
155  {
157  bool executing ;
158  std::string name ;
159  std::string type ;
160  unsigned long num ;
161  Leaf() : algorithm ( 0 ) , executing (false ) , name() , type() , num ( 0 ) {}
162  Leaf(const Leaf& l)
163  : algorithm(l.algorithm),
164  executing(l.executing), name(l.name), type(l.type), num(l.num) {}
165  Leaf(const std::string& t, const std::string& n)
166  : algorithm(0), executing(false), name(n), type(t), num(0) {}
167  };
168  // ==========================================================================
169 public:
170  // ==========================================================================
174  virtual StatusCode initialize();
176  virtual StatusCode finalize();
178  virtual StatusCode reinitialize();
180  virtual void handle(const Incident& incident);
187  ( const std::string& name , // Service instance name
188  ISvcLocator* svc ) ; // Pointer to service locator
190  virtual ~DataOnDemandSvc(); // Standard destructor
191  // ==========================================================================
192 protected:
193  // ==========================================================================
199  // ==========================================================================
205  StatusCode execHandler(const std::string& tag, Leaf& leaf);
206  // ==========================================================================
212  StatusCode execHandler(const std::string& tag, Node& node);
213  // ==========================================================================
216  // ==========================================================================
219  // ==========================================================================
221  StatusCode setup();
223  void i_setNodeHandler(const std::string &name, const std::string &type);
225  StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg);
226  // ==========================================================================
227 public:
228  // ==========================================================================
229  void update_1 ( Property& p ) ;
230  void update_2 ( Property& p ) ;
231  void update_3 ( Property& p ) ;
233  void update_dump ( Property& /* p */ ) ;// update handler for 'Dump' property
234  // ==========================================================================
235 protected:
236  // ==========================================================================
238  StatusCode update() ;
240  inline MsgStream& stream () const
241  {
242  if ( 0 == m_log ) { m_log = new MsgStream( msgSvc() , name() ) ; }
243  return *m_log;
244  }
249  void dump ( const MSG::Level level , const bool mode = true ) const ;
250  // ==========================================================================
251 private:
252  // ==========================================================================
262  std::string m_trapType;
264  std::string m_dataSvcName;
268  bool m_dump ;
270  bool m_init ;
282  //
283  typedef std::map<std::string,std::string> Map ;
285  Map m_algMap ; // { 'data' : 'algorithm' }
287  Map m_nodeMap ; // { 'data' : 'type' }
289  std::string m_prefix ;
290  mutable MsgStream* m_log ;
291  // ==========================================================================
296  // ==========================================================================
303  // ==========================================================================
304  std::vector<std::string> m_nodeMapTools;
305  std::list<IDODNodeMapper *> m_nodeMappers;
306  std::vector<std::string> m_algMapTools;
307  std::list<IDODAlgMapper *> m_algMappers;
308 };
309 // ============================================================================
310 
311 // ============================================================================
312 // The END
313 // ============================================================================
314 #endif // GAUDISVC_DATAONDEMANDSVC_H
315 // ============================================================================
316 
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
The interface implemented by the IToolSvc base class.
Definition: IToolSvc.h:17
ChronoEntity m_timer_all
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable ...
ChronoEntity m_timer_algs
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
std::list< IDODNodeMapper * > m_nodeMappers
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream * m_log
tuple c
Definition: gaudirun.py:341
MsgStream & stream() const
get the message stream
SmartIF< IIncidentSvc > m_incSvc
Incident service.
virtual StatusCode reinitialize()
Inherited Service overrides: Service reinitialization.
std::vector< std::string > Setup
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:28
std::vector< std::string > m_algMapTools
std::string m_trapType
Trap name.
std::string m_dataSvcName
Data service name.
Setup m_nodeMapping
Mapping to nodes.
Map m_algMap
the major configuration property { 'data' : 'algorithm' }
Data provider interface definition.
virtual StatusCode initialize()
Inherited Service overrides: Service initialization.
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
ulonglong m_statNode
ClassH clazz
the actual class
std::list< IDODAlgMapper * > m_algMappers
Setup m_algMapping
Mapping to algorithms.
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
string type
Definition: gaudirun.py:126
StatusCode setup()
Setup routine (called by (re-) initialize.
virtual void handle(const Incident &incident)
IIncidentListener interfaces overrides: incident handling.
bool m_allowInitFailure
flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithm...
StatusCode execHandler(const std::string &tag, Leaf &leaf)
Execute leaf handler (algorithm)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
void update_dump(Property &)
update handler for 'Dump' property
StatusCode setupNodeHandlers()
Initialize node handlers.
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
Helper class of the DataOnDemandSvc.
std::vector< std::string > m_nodeMapTools
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
std::string m_prefix
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:20
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
dictionary l
Definition: gaudirun.py:365
bool m_partialPath
Flag to allow for the creation of partial leaves.
std::map< std::string, std::string > Map
Leaf(const std::string &t, const std::string &n)
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
AlgMap m_algs
Map of algorithms to handle incidents.
bool m_dump
flag to force the printout
bool m_init
flag to warm up the configuration
ChronoEntity m_timer_nodes
Base class for all Incidents (computing events).
Definition: Incident.h:16
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
bool dataObject
trivial object? DataObject?
DataOnDemandSvc(const std::string &name, ISvcLocator *svc)
Standard initializing service constructor.
virtual StatusCode finalize()
Inherited Service overrides: Service finalization.
GaudiUtils::HashMap< Gaudi::StringKey, Node > NodeMap
ChronoEntity m_total
Map m_nodeMap
the major configuration property { 'data' : 'type' }
StatusCode setupAlgHandlers()
Initialize leaf handlers.
Helper class of the DataOnDemandSvc.
virtual ~DataOnDemandSvc()
Standard destructor.
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
Node(ClassH c, bool e, const std::string &n)
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
void update_2(Property &p)
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:22
void update_3(Property &p)
void update_1(Property &p)
StatusCode update()
update the handlers
GaudiUtils::HashMap< Gaudi::StringKey, Leaf > AlgMap