The Gaudi Framework  v33r1 (b1225454)
DataOnDemandSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDISVC_DATAONDEMANDSVC_H
12 #define GAUDISVC_DATAONDEMANDSVC_H
13 // ============================================================================
14 // Include Files
15 // ============================================================================
16 // STD & STL
17 // ============================================================================
18 #include <map>
19 #include <vector>
20 // ============================================================================
21 // GaudiKernel
22 // ============================================================================
27 #include "GaudiKernel/Service.h"
28 #include "GaudiKernel/StatEntity.h"
29 #include "GaudiKernel/StringKey.h"
30 // ============================================================================
31 // ROOT TClass
32 // ============================================================================
33 #include "TClass.h"
34 // ============================================================================
35 // Forward declarations
36 // ============================================================================
37 class IAlgTool;
38 class IAlgorithm;
39 class IAlgManager;
40 class IIncidentSvc;
41 class IDataProviderSvc;
42 class IToolSvc;
43 // ============================================================================
100 class DataOnDemandSvc : public extends<Service, IIncidentListener> {
101 public:
102  // ==========================================================================
103  // Typedefs
105  typedef TClass* ClassH;
106  // ==========================================================================
111  struct Protection {
112  bool& m_bool;
113  Protection( bool& b ) : m_bool( b ) { m_bool = true; }
114  ~Protection() { m_bool = false; }
115  };
116  // ==========================================================================
122  struct Node final {
123  // ========================================================================
125  ClassH clazz; // the actual class
127  unsigned long num = 0;
128  bool executing = false;
130  bool dataObject = false; // trivial object? DataObject?
131  // =======================================================================
132  Node() = default;
133  // ========================================================================
134  Node( ClassH c, bool e, std::string n )
135  : clazz( c ), name( std::move( n ) ), executing( e ), dataObject( "DataObject" == name ) {}
136  // ========================================================================
137  };
138  // ==========================================================================
140  struct Leaf {
141  IAlgorithm* algorithm = nullptr;
144  unsigned long num = 0;
145  bool executing = false;
146  Leaf() = default;
147  Leaf( const Leaf& l ) = default;
148  Leaf( std::string t, std::string n ) : name( std::move( n ) ), type( std::move( t ) ) {}
149  };
150  // ==========================================================================
151 public:
152  // ==========================================================================
156  StatusCode initialize() override;
158  StatusCode finalize() override;
160  StatusCode reinitialize() override;
162  void handle( const Incident& incident ) override;
164  using extends::extends;
165  // ==========================================================================
166 protected:
167  // ==========================================================================
173  // ==========================================================================
179  StatusCode execHandler( const std::string& tag, Leaf& leaf );
180  // ==========================================================================
186  StatusCode execHandler( const std::string& tag, Node& node );
187  // ==========================================================================
190  // ==========================================================================
193  // ==========================================================================
195  StatusCode setup();
197  void i_setNodeHandler( const std::string& name, const std::string& type );
200  // ==========================================================================
201 protected:
202  // ==========================================================================
204  StatusCode update();
209  void dump( const MSG::Level level, const bool mode = true ) const;
210  // ==========================================================================
211 private:
212  // ==========================================================================
214  verbose() << "updated property " << p.name() << ", forcing update" << endmsg;
215  m_updateRequired = true;
216  };
218  warning() << p.name() << " " << p.documentation() << endmsg;
219  force_update( p );
220  };
221 
222  // ==========================================================================
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  },
263  "dump configuration and stastics, if set to True after initialize it triggers a dump immediately"};
264  Gaudi::Property<bool> m_init{this, "PreInitialize", false, "(pre)initialize all algorithms"};
266  this, "AllowPreInitializeFailure", false,
267  "allow (pre)initialization of algorithms to fail without stopping the application"};
268 
270  this, "Algorithms", {}, &DataOnDemandSvc::deprecated_property, "[[deprecated]] use AlgMap"};
272  this, "Nodes", {}, &DataOnDemandSvc::deprecated_property, "[[deprecated]] use NodeMap"};
273 
275  Gaudi::Property<Map> m_algMap{this, "AlgMap", {}, &DataOnDemandSvc::force_update, "mapping {'data': 'algorithm'}"};
276  Gaudi::Property<Map> m_nodeMap{this, "NodeMap", {}, &DataOnDemandSvc::force_update, "mapping {'data': 'type'}"};
277 
278  Gaudi::Property<std::string> m_prefix{this, "Prefix", "/Event/"};
279 
281  this, "NodeMappingTools", {}, "list of tools of type IDODNodeMapper"};
283  this, "AlgMappingTools", {}, "list of tools of type IDODAlgMapper"};
284 };
285 // ============================================================================
286 
287 // ============================================================================
288 // The END
289 // ============================================================================
290 #endif // GAUDISVC_DATAONDEMANDSVC_H
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:29
ChronoEntity m_timer_all
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:370
ChronoEntity m_timer_algs
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:62
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:31
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:37
Gaudi::Property< std::string > m_trapType
STL namespace.
Gaudi::Property< Map > m_nodeMap
Gaudi::Property< bool > m_init
const std::string name() const
property name
Definition: Property.h:46
Data provider interface definition.
StatusCode initialize() override
Inherited Service overrides: Service initialization.
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
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
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
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.
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:61
StatusCode setupNodeHandlers()
Initialize node handlers.
Helper class of the DataOnDemandSvc.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
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:42
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:38
dictionary l
Definition: gaudirun.py:543
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:20
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:27
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:33
bool dataObject
trivial object? DataObject?
StatusCode finalize() override
Inherited Service overrides: Service finalization.
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:202
unsigned long long m_statNode
std::string documentation() const
property documentation
Definition: Property.h:48
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:33
unsigned long long m_statAlg
StatusCode reinitialize() override
Inherited Service overrides: Service reinitialization.
StatusCode update()
update the handlers
GaudiUtils::HashMap< Gaudi::StringKey, Leaf > AlgMap