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"
14 #include "GaudiKernel/IIncidentListener.h"
15 #include "GaudiKernel/ChronoEntity.h"
16 #include "GaudiKernel/StatEntity.h"
17 #include "GaudiKernel/StringKey.h"
18 #include "GaudiKernel/IDODAlgMapper.h"
19 #include "GaudiKernel/IDODNodeMapper.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  std::string name ;
120  unsigned long num = 0;
121  bool executing = false;
123  bool dataObject = false ; // trivial object? DataObject?
124  // =======================================================================
125  Node() = default;
126  // ========================================================================
127  Node ( ClassH c ,
128  bool e ,
129  std::string n )
130  : clazz ( c )
131  , name ( std::move(n) )
132  , executing ( e )
133  , dataObject ( "DataObject" == name )
134  {}
135  //
136  Node( const Node& c )
137  : clazz ( c.clazz )
138  , name ( c.name )
139  , num ( c.num )
140  , executing ( c.executing )
141  , dataObject ( c.dataObject )
142  {}
143  // ========================================================================
144  };
145  // ==========================================================================
147  struct Leaf
148  {
149  IAlgorithm* algorithm = nullptr;
150  std::string name ;
151  std::string type ;
152  unsigned long num = 0;
153  bool executing = false;
154  Leaf() = default;
155  Leaf(const Leaf& l) = default;
156  Leaf(std::string t, std::string n)
157  : name(std::move(n)), type(std::move(t)) {}
158  };
159  // ==========================================================================
160 public:
161  // ==========================================================================
165  StatusCode initialize() override;
167  StatusCode finalize() override;
169  StatusCode reinitialize() override;
171  void handle(const Incident& incident) override;
178  ( const std::string& name , // Service instance name
179  ISvcLocator* svc ) ; // Pointer to service locator
181  ~DataOnDemandSvc() override = default; // Standard destructor
182  // ==========================================================================
183 protected:
184  // ==========================================================================
190  // ==========================================================================
196  StatusCode execHandler(const std::string& tag, Leaf& leaf);
197  // ==========================================================================
203  StatusCode execHandler(const std::string& tag, Node& node);
204  // ==========================================================================
207  // ==========================================================================
210  // ==========================================================================
212  StatusCode setup();
214  void i_setNodeHandler(const std::string &name, const std::string &type);
216  StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg);
217  // ==========================================================================
218 public:
219  // ==========================================================================
220  void update_1 ( Property& p ) ;
221  void update_2 ( Property& p ) ;
222  void update_3 ( Property& p ) ;
224  void update_dump ( Property& /* p */ ) ;// update handler for 'Dump' property
225  // ==========================================================================
226 protected:
227  // ==========================================================================
229  StatusCode update() ;
231  inline MsgStream& stream () const
232  {
233  if ( !m_log ) m_log.reset( new MsgStream( msgSvc() , name() ) );
234  return *m_log;
235  }
240  void dump ( const MSG::Level level , const bool mode = true ) const ;
241  // ==========================================================================
242 private:
243  // ==========================================================================
253  std::string m_trapType = "DataFault";
255  std::string m_dataSvcName = "EventDataSvc" ;
257  bool m_partialPath = true;
259  bool m_dump = false;
261  bool m_init = false;
264  bool m_allowInitFailure = false;
270  AlgMap m_algs;
272  NodeMap m_nodes;
273  //
274  typedef std::map<std::string,std::string> Map ;
276  Map m_algMap ; // { 'data' : 'algorithm' }
278  Map m_nodeMap ; // { 'data' : 'type' }
279  bool m_updateRequired = true ;
280  std::string m_prefix = "/Event/" ;
281  mutable std::unique_ptr<MsgStream> m_log ;
282  // ==========================================================================
287  // ==========================================================================
291  bool m_locked_nodes = false ;
292  bool m_locked_algs = false ;
293  bool m_locked_all = false ;
294  // ==========================================================================
295  std::vector<std::string> m_nodeMapTools;
296  std::vector<IDODNodeMapper *> m_nodeMappers;
297  std::vector<std::string> m_algMapTools;
298  std::vector<IDODAlgMapper *> m_algMappers;
299 };
300 // ============================================================================
301 
302 // ============================================================================
303 // The END
304 // ============================================================================
305 #endif // GAUDISVC_DATAONDEMANDSVC_H
306 // ============================================================================
307 
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
tuple c
Definition: gaudirun.py:391
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: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
MsgStream & stream() const
get the message stream
SmartIF< IIncidentSvc > m_incSvc
Incident service.
void handle(const Incident &incident) override
IIncidentListener interfaces overrides: incident handling.
std::vector< std::string > Setup
std::unique_ptr< MsgStream > m_log
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.
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
ulonglong m_statNode
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
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:23
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: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.
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
string type
Definition: gaudirun.py:151
GaudiUtils::HashMap< Gaudi::StringKey, Leaf > AlgMap