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 extends<Service,
91  IIncidentListener>
92 {
93 public:
94  // ==========================================================================
95  // Typedefs
97  typedef TClass* ClassH;
98  // ==========================================================================
103  struct Protection
104  {
105  bool& m_bool;
106  Protection(bool& b) : m_bool(b) { m_bool = true; }
107  ~Protection() { m_bool = false; }
108  };
109  // ==========================================================================
115  struct Node
116  {
117  // ========================================================================
119  ClassH clazz ; // the actual class
121  unsigned long num = 0;
122  bool executing = false;
124  bool dataObject = false ; // trivial object? DataObject?
125  // =======================================================================
126  Node() = default;
127  // ========================================================================
128  Node ( ClassH c ,
129  bool e ,
130  std::string n )
131  : clazz ( c )
132  , name ( std::move(n) )
133  , executing ( e )
134  , dataObject ( "DataObject" == name )
135  {}
136  //
137  Node( const Node& c )
138  : clazz ( c.clazz )
139  , name ( c.name )
140  , num ( c.num )
141  , executing ( c.executing )
142  , dataObject ( c.dataObject )
143  {}
144  // ========================================================================
145  };
146  // ==========================================================================
148  struct Leaf
149  {
150  IAlgorithm* algorithm = nullptr;
153  unsigned long num = 0;
154  bool executing = false;
155  Leaf() = default;
156  Leaf(const Leaf& l) = default;
158  : name(std::move(n)), type(std::move(t)) {}
159  };
160  // ==========================================================================
161 public:
162  // ==========================================================================
166  StatusCode initialize() override;
168  StatusCode finalize() override;
170  StatusCode reinitialize() override;
172  void handle(const Incident& incident) override;
179  ( const std::string& name , // Service instance name
180  ISvcLocator* svc ) ; // Pointer to service locator
182  ~DataOnDemandSvc() override = default; // Standard destructor
183  // ==========================================================================
184 protected:
185  // ==========================================================================
191  // ==========================================================================
197  StatusCode execHandler(const std::string& tag, Leaf& leaf);
198  // ==========================================================================
204  StatusCode execHandler(const std::string& tag, Node& node);
205  // ==========================================================================
208  // ==========================================================================
211  // ==========================================================================
213  StatusCode setup();
215  void i_setNodeHandler(const std::string &name, const std::string &type);
218  // ==========================================================================
219 public:
220  // ==========================================================================
221  void update_1 ( Property& p ) ;
222  void update_2 ( Property& p ) ;
223  void update_3 ( Property& p ) ;
225  void update_dump ( Property& /* p */ ) ;// update handler for 'Dump' property
226  // ==========================================================================
227 protected:
228  // ==========================================================================
230  StatusCode update() ;
235  void dump ( const MSG::Level level , const bool mode = true ) const ;
236  // ==========================================================================
237 private:
238  // ==========================================================================
248  std::string m_trapType = "DataFault";
250  std::string m_dataSvcName = "EventDataSvc" ;
252  bool m_partialPath = true;
254  bool m_dump = false;
256  bool m_init = false;
259  bool m_allowInitFailure = false;
265  AlgMap m_algs;
267  NodeMap m_nodes;
268  //
271  Map m_algMap ; // { 'data' : 'algorithm' }
273  Map m_nodeMap ; // { 'data' : 'type' }
274  bool m_updateRequired = true ;
275  std::string m_prefix = "/Event/" ;
276  // ==========================================================================
281  // ==========================================================================
285  bool m_locked_nodes = false ;
286  bool m_locked_algs = false ;
287  bool m_locked_all = false ;
288  // ==========================================================================
293 };
294 // ============================================================================
295 
296 // ============================================================================
297 // The END
298 // ============================================================================
299 #endif // GAUDISVC_DATAONDEMANDSVC_H
300 // ============================================================================
301 
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:18
ChronoEntity m_timer_all
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
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::vector< IDODNodeMapper * > m_nodeMappers
tuple c
Definition: gaudirun.py:391
SmartIF< IIncidentSvc > m_incSvc
Incident service.
void handle(const Incident &incident) override
IIncidentListener interfaces overrides: incident handling.
std::vector< std::string > Setup
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
std::vector< std::string > m_algMapTools
std::string m_trapType
Trap name.
STL namespace.
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.
StatusCode initialize() override
Inherited Service overrides: Service initialization.
STL class.
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
ulonglong m_statNode
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
ClassH clazz
the actual class
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:151
StatusCode setup()
Setup routine (called by (re-) initialize.
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:26
void update_dump(Property &)
update handler for 'Dump' property
StatusCode setupNodeHandlers()
Initialize node handlers.
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:25
dictionary l
Definition: gaudirun.py:421
bool m_partialPath
Flag to allow for the creation of partial leaves.
std::vector< IDODAlgMapper * > m_algMappers
std::map< std::string, std::string > Map
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
Node(ClassH c, bool e, std::string n)
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
AlgMap m_algs
Map of algorithms to handle incidents.
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
bool m_dump
flag to force the printout
bool m_init
flag to warm up the configuration
Leaf(std::string t, std::string n)
ChronoEntity m_timer_nodes
Base class for all Incidents (computing events).
Definition: Incident.h:17
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.
StatusCode finalize() override
Inherited Service overrides: Service finalization.
GaudiUtils::HashMap< Gaudi::StringKey, Node > NodeMap
~DataOnDemandSvc() override=default
Standard destructor.
ChronoEntity m_total
Map m_nodeMap
the major configuration property { 'data' : 'type' }
StatusCode setupAlgHandlers()
Initialize leaf handlers.
Helper class of the DataOnDemandSvc.
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
void update_2(Property &p)
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21
void update_3(Property &p)
void update_1(Property &p)
StatusCode reinitialize() override
Inherited Service overrides: Service reinitialization.
StatusCode update()
update the handlers
GaudiUtils::HashMap< Gaudi::StringKey, Leaf > AlgMap