The Gaudi Framework  v30r4 (9b837755)
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 // ============================================================================
17 #include "GaudiKernel/Service.h"
18 #include "GaudiKernel/StatEntity.h"
19 #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, IIncidentListener>
91 {
92 public:
93  // ==========================================================================
94  // Typedefs
96  typedef TClass* ClassH;
97  // ==========================================================================
102  struct Protection {
103  bool& m_bool;
104  Protection( bool& b ) : m_bool( b ) { m_bool = true; }
105  ~Protection() { m_bool = false; }
106  };
107  // ==========================================================================
113  struct Node {
114  // ========================================================================
116  ClassH clazz; // the actual class
118  unsigned long num = 0;
119  bool executing = false;
121  bool dataObject = false; // trivial object? DataObject?
122  // =======================================================================
123  Node() = default;
124  // ========================================================================
125  Node( ClassH c, bool e, std::string n )
126  : clazz( c ), name( std::move( n ) ), executing( e ), dataObject( "DataObject" == name )
127  {
128  }
129  //
130  Node( const Node& c )
131  : clazz( c.clazz ), name( c.name ), num( c.num ), executing( c.executing ), dataObject( c.dataObject )
132  {
133  }
134  // ========================================================================
135  };
136  // ==========================================================================
138  struct Leaf {
139  IAlgorithm* algorithm = nullptr;
142  unsigned long num = 0;
143  bool executing = false;
144  Leaf() = default;
145  Leaf( const Leaf& l ) = default;
146  Leaf( std::string t, std::string n ) : name( std::move( n ) ), type( std::move( t ) ) {}
147  };
148  // ==========================================================================
149 public:
150  // ==========================================================================
154  StatusCode initialize() override;
156  StatusCode finalize() override;
158  StatusCode reinitialize() override;
160  void handle( const Incident& incident ) override;
162  using extends::extends;
163  // ==========================================================================
164 protected:
165  // ==========================================================================
171  // ==========================================================================
177  StatusCode execHandler( const std::string& tag, Leaf& leaf );
178  // ==========================================================================
184  StatusCode execHandler( const std::string& tag, Node& node );
185  // ==========================================================================
188  // ==========================================================================
191  // ==========================================================================
193  StatusCode setup();
195  void i_setNodeHandler( const std::string& name, const std::string& type );
198  // ==========================================================================
199 protected:
200  // ==========================================================================
202  StatusCode update();
207  void dump( const MSG::Level level, const bool mode = true ) const;
208  // ==========================================================================
209 private:
210  // ==========================================================================
212  {
213  verbose() << "updated property " << p.name() << ", forcing update" << endmsg;
214  m_updateRequired = true;
215  };
217  {
218  warning() << p.name() << " " << p.documentation() << endmsg;
219  force_update( p );
220  };
221 
222  // ==========================================================================
232  AlgMap m_algs;
234  NodeMap m_nodes;
235 
236  bool m_updateRequired = true;
237  // ==========================================================================
239  unsigned long long m_statAlg = 0;
240  unsigned long long m_statNode = 0;
241  unsigned long long m_stat = 0;
242  // ==========================================================================
246  bool m_locked_nodes = false;
247  bool m_locked_algs = false;
248  bool m_locked_all = false;
249  // ==========================================================================
252  // ==========================================================================
253  // Properties
254  Gaudi::Property<std::string> m_trapType{this, "IncidentName", "DataFault", "the type of handled Incident"};
255  Gaudi::Property<std::string> m_dataSvcName{this, "DataSvc", "EventDataSvc", "DataSvc name"};
256 
257  Gaudi::Property<bool> m_partialPath{this, "UsePreceedingPath", true, "allow creation of partial leaves"};
259  this, "Dump", false,
260  [this]( auto& ) {
262  dump( MSG::ALWAYS );
263  }
264  },
265  "dump configuration and stastics, if set to True after initialize it triggers a dump immediately"};
266  Gaudi::Property<bool> m_init{this, "PreInitialize", false, "(pre)initialize all algorithms"};
268  this, "AllowPreInitializeFailure", false,
269  "allow (pre)initialization of algorithms to fail without stopping the application"};
270 
272  this, "Algorithms", {}, &DataOnDemandSvc::deprecated_property, "[[deprecated]] use AlgMap"};
274  this, "Nodes", {}, &DataOnDemandSvc::deprecated_property, "[[deprecated]] use NodeMap"};
275 
277  Gaudi::Property<Map> m_algMap{this, "AlgMap", {}, &DataOnDemandSvc::force_update, "mapping {'data': 'algorithm'}"};
278  Gaudi::Property<Map> m_nodeMap{this, "NodeMap", {}, &DataOnDemandSvc::force_update, "mapping {'data': 'type'}"};
279 
280  Gaudi::Property<std::string> m_prefix{this, "Prefix", "/Event/"};
281 
283  this, "NodeMappingTools", {}, "list of tools of type IDODNodeMapper"};
285  this, "AlgMappingTools", {}, "list of tools of type IDODAlgMapper"};
286 };
287 // ============================================================================
288 
289 // ============================================================================
290 // The END
291 // ============================================================================
292 #endif // GAUDISVC_DATAONDEMANDSVC_H
293 // ============================================================================
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:19
ChronoEntity m_timer_all
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable ...
Implementation of property with value of concrete type.
Definition: Property.h:383
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
const std::string name() const
property name
Definition: Property.h:39
SmartIF< IIncidentSvc > m_incSvc
Incident service.
void handle(const Incident &incident) override
IIncidentListener interfaces overrides: incident handling.
std::vector< std::string > Setup
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
Gaudi::Property< std::string > m_trapType
STL namespace.
Gaudi::Property< Map > m_nodeMap
Gaudi::Property< bool > m_init
Data provider interface definition.
StatusCode initialize() override
Inherited Service overrides: Service initialization.
void force_update(Gaudi::Details::PropertyBase &p)
void deprecated_property(Gaudi::Details::PropertyBase &p)
STL class.
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
Gaudi::Property< Setup > m_algMapping
Gaudi::Property< std::vector< std::string > > m_algMapTools
ClassH clazz
the actual class
Gaudi::Property< std::string > m_prefix
unsigned long long m_stat
Gaudi::Property< std::vector< std::string > > m_nodeMapTools
Helper class to parse a string of format "type/name".
Gaudi::Property< Map > m_algMap
StatusCode setup()
Setup routine (called by (re-) initialize.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
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:51
StatusCode setupNodeHandlers()
Initialize node handlers.
Helper class of the DataOnDemandSvc.
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:34
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:28
dictionary l
Definition: gaudirun.py:453
Gaudi::Property< bool > m_partialPath
std::vector< IDODNodeMapper * > m_nodeMappers
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
Gaudi::Property< Setup > m_nodeMapping
Leaf(std::string t, std::string n)
ChronoEntity m_timer_nodes
Gaudi::Property< std::string > m_dataSvcName
Base class for all Incidents (computing events).
Definition: Incident.h:17
std::string documentation() const
property documentation
Definition: Property.h:41
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
StatusCode finalize() override
Inherited Service overrides: Service finalization.
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:53
GaudiUtils::HashMap< Gaudi::StringKey, Node > NodeMap
ChronoEntity m_total
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.
Gaudi::Property< bool > m_dump
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
Gaudi::Property< bool > m_allowInitFailure
std::vector< IDODAlgMapper * > m_algMappers
std::map< std::string, std::string > Map
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
unsigned long long m_statNode
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
unsigned long long m_statAlg
StatusCode reinitialize() override
Inherited Service overrides: Service reinitialization.
StatusCode update()
update the handlers
GaudiUtils::HashMap< Gaudi::StringKey, Leaf > AlgMap