| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 extends<Service,
91 IIncidentListener>
92 {
93 public:
94 // ==========================================================================
95 // Typedefs
96 typedef std::vector<std::string> Setup;
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
120 std::string name ;
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;
151 std::string name ;
152 std::string type ;
153 unsigned long num = 0;
154 bool executing = false;
155 Leaf() = default;
156 Leaf(const Leaf& l) = default;
157 Leaf(std::string t, std::string n)
158 : name(std::move(n)), type(std::move(t)) {}
159 };
160 // ==========================================================================
161 public:
162 // ==========================================================================
163 typedef GaudiUtils::HashMap<Gaudi::StringKey, Node> NodeMap;
164 typedef GaudiUtils::HashMap<Gaudi::StringKey, Leaf> AlgMap;
166 StatusCode initialize() override;
168 StatusCode finalize() override;
170 StatusCode reinitialize() override;
172 void handle(const Incident& incident) override;
178 DataOnDemandSvc
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 // ==========================================================================
190 StatusCode configureHandler(Leaf& leaf);
191 // ==========================================================================
197 StatusCode execHandler(const std::string& tag, Leaf& leaf);
198 // ==========================================================================
204 StatusCode execHandler(const std::string& tag, Node& node);
205 // ==========================================================================
207 StatusCode setupNodeHandlers();
208 // ==========================================================================
210 StatusCode setupAlgHandlers();
211 // ==========================================================================
213 StatusCode setup();
215 void i_setNodeHandler(const std::string &name, const std::string &type);
217 StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg);
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 // ==========================================================================
240 SmartIF<IIncidentSvc> m_incSvc = nullptr;
242 SmartIF<IAlgManager> m_algMgr = nullptr;
244 SmartIF<IDataProviderSvc> m_dataSvc = nullptr;
246 SmartIF<IToolSvc> m_toolSvc;
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;
261 Setup m_algMapping;
263 Setup m_nodeMapping;
265 AlgMap m_algs;
267 NodeMap m_nodes;
268 //
269 typedef std::map<std::string,std::string> Map ;
271 Map m_algMap ; // { 'data' : 'algorithm' }
273 Map m_nodeMap ; // { 'data' : 'type' }
274 bool m_updateRequired = true ;
275 std::string m_prefix = "/Event/" ;
276 // ==========================================================================
277 ChronoEntity m_total ;
278 ulonglong m_statAlg = 0;
279 ulonglong m_statNode = 0;
280 ulonglong m_stat = 0;
281 // ==========================================================================
282 ChronoEntity m_timer_nodes ;
283 ChronoEntity m_timer_algs ;
284 ChronoEntity m_timer_all ;
285 bool m_locked_nodes = false ;
286 bool m_locked_algs = false ;
287 bool m_locked_all = false ;
288 // ==========================================================================
289 std::vector<std::string> m_nodeMapTools;
290 std::vector<IDODNodeMapper *> m_nodeMappers;
291 std::vector<std::string> m_algMapTools;
292 std::vector<IDODAlgMapper *> m_algMappers;
293 };
294 // ============================================================================
295
296 // ============================================================================
297 // The END
298 // ============================================================================
299 #endif // GAUDISVC_DATAONDEMANDSVC_H
300 // ============================================================================
301
DataOnDemandSvc::i_setNodeHandler
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
Definition: DataOnDemandSvc.cpp:207
IToolSvc
The interface implemented by the IToolSvc base class.
Definition: IToolSvc.h:18
DataOnDemandSvc::m_timer_all
ChronoEntity m_timer_all
Definition: DataOnDemandSvc.h:284
SmartIF< IIncidentSvc >
DataOnDemandSvc::Node::name
std::string name
Definition: DataOnDemandSvc.h:120
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
DataOnDemandSvc::Node::num
unsigned long num
Definition: DataOnDemandSvc.h:121
DataOnDemandSvc::ClassH
TClass * ClassH
Definition: DataOnDemandSvc.h:97
DataOnDemandSvc
The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable ...
Definition: DataOnDemandSvc.h:90
DataOnDemandSvc::m_timer_algs
ChronoEntity m_timer_algs
Definition: DataOnDemandSvc.h:283
DataOnDemandSvc::m_stat
ulonglong m_stat
Definition: DataOnDemandSvc.h:280
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
DataOnDemandSvc::m_nodeMappers
std::vector< IDODNodeMapper * > m_nodeMappers
Definition: DataOnDemandSvc.h:290
gaudirun.c
tuple c
Definition: gaudirun.py:391
DataOnDemandSvc::Leaf::type
std::string type
Definition: DataOnDemandSvc.h:152
DataOnDemandSvc::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Incident service.
Definition: DataOnDemandSvc.h:240
DataOnDemandSvc::handle
void handle(const Incident &incident) override
IIncidentListener interfaces overrides: incident handling.
Definition: DataOnDemandSvc.cpp:625
DataOnDemandSvc::Leaf::algorithm
IAlgorithm * algorithm
Definition: DataOnDemandSvc.h:150
DataOnDemandSvc::Setup
std::vector< std::string > Setup
Definition: DataOnDemandSvc.h:96
IAlgManager
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
DataOnDemandSvc::m_algMapTools
std::vector< std::string > m_algMapTools
Definition: DataOnDemandSvc.h:291
DataOnDemandSvc::m_trapType
std::string m_trapType
Trap name.
Definition: DataOnDemandSvc.h:248
std
STL namespace.
DataOnDemandSvc::m_locked_nodes
bool m_locked_nodes
Definition: DataOnDemandSvc.h:285
DataOnDemandSvc::Leaf
Definition: DataOnDemandSvc.h:148
DataOnDemandSvc::m_dataSvcName
std::string m_dataSvcName
Data service name.
Definition: DataOnDemandSvc.h:250
DataOnDemandSvc::m_nodeMapping
Setup m_nodeMapping
Mapping to nodes.
Definition: DataOnDemandSvc.h:263
DataOnDemandSvc::Leaf::executing
bool executing
Definition: DataOnDemandSvc.h:154
DataOnDemandSvc::Protection::m_bool
bool & m_bool
Definition: DataOnDemandSvc.h:105
DataOnDemandSvc::m_algMap
Map m_algMap
the major configuration property { 'data' : 'algorithm' }
Definition: DataOnDemandSvc.h:271
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:45
DataOnDemandSvc::m_statAlg
ulonglong m_statAlg
Definition: DataOnDemandSvc.h:278
DataOnDemandSvc::initialize
StatusCode initialize() override
Inherited Service overrides: Service initialization.
Definition: DataOnDemandSvc.cpp:298
std::map< std::string, std::string >
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
DataOnDemandSvc::Node::Node
Node()=default
std::string
STL class.
DataOnDemandSvc::m_dataSvc
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
Definition: DataOnDemandSvc.h:244
Service.h
DataOnDemandSvc::m_statNode
ulonglong m_statNode
Definition: DataOnDemandSvc.h:279
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
DataOnDemandSvc::Node::clazz
ClassH clazz
the actual class
Definition: DataOnDemandSvc.h:119
MSG::Level
Level
Definition: IMessageSvc.h:15
DataOnDemandSvc::m_algMapping
Setup m_algMapping
Mapping to algorithms.
Definition: DataOnDemandSvc.h:261
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
gaudirun.type
string type
Definition: gaudirun.py:151
DataOnDemandSvc::setup
StatusCode setup()
Setup routine (called by (re-) initialize.
Definition: DataOnDemandSvc.cpp:400
DataOnDemandSvc::Leaf::num
unsigned long num
Definition: DataOnDemandSvc.h:153
DataOnDemandSvc::m_allowInitFailure
bool m_allowInitFailure
flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithm...
Definition: DataOnDemandSvc.h:259
__longlong
Definition: Kernel.h:56
DataOnDemandSvc::Node::Node
Node(const Node &c)
Definition: DataOnDemandSvc.h:137
DataOnDemandSvc::execHandler
StatusCode execHandler(const std::string &tag, Leaf &leaf)
Execute leaf handler (algorithm)
Definition: DataOnDemandSvc.cpp:750
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
DataOnDemandSvc::update_dump
void update_dump(Property &)
update handler for 'Dump' property
Definition: DataOnDemandSvc.cpp:122
DataOnDemandSvc::setupNodeHandlers
StatusCode setupNodeHandlers()
Initialize node handlers.
Definition: DataOnDemandSvc.cpp:450
DataOnDemandSvc::Protection
Helper class of the DataOnDemandSvc.
Definition: DataOnDemandSvc.h:103
DataOnDemandSvc::m_nodeMapTools
std::vector< std::string > m_nodeMapTools
Definition: DataOnDemandSvc.h:289
StringKey.h
DataOnDemandSvc::m_nodes
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
Definition: DataOnDemandSvc.h:267
DataOnDemandSvc::Protection::~Protection
~Protection()
Definition: DataOnDemandSvc.h:107
DataOnDemandSvc::m_prefix
std::string m_prefix
Definition: DataOnDemandSvc.h:275
DataOnDemandSvc::dump
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
Definition: DataOnDemandSvc.cpp:789
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
gaudirun.l
dictionary l
Definition: gaudirun.py:421
DataOnDemandSvc::m_partialPath
bool m_partialPath
Flag to allow for the creation of partial leaves.
Definition: DataOnDemandSvc.h:252
DataOnDemandSvc::m_algMappers
std::vector< IDODAlgMapper * > m_algMappers
Definition: DataOnDemandSvc.h:292
DataOnDemandSvc::Map
std::map< std::string, std::string > Map
Definition: DataOnDemandSvc.h:269
DataOnDemandSvc::Leaf::name
std::string name
Definition: DataOnDemandSvc.h:151
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
DataOnDemandSvc::Protection::Protection
Protection(bool &b)
Definition: DataOnDemandSvc.h:106
std::vector< std::string >
DataOnDemandSvc::m_algMgr
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
Definition: DataOnDemandSvc.h:242
DataOnDemandSvc::Node::Node
Node(ClassH c, bool e, std::string n)
Definition: DataOnDemandSvc.h:128
DataOnDemandSvc::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
Definition: DataOnDemandSvc.h:246
DataOnDemandSvc::Node::executing
bool executing
Definition: DataOnDemandSvc.h:122
DataOnDemandSvc::m_algs
AlgMap m_algs
Map of algorithms to handle incidents.
Definition: DataOnDemandSvc.h:265
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
DataOnDemandSvc::m_dump
bool m_dump
flag to force the printout
Definition: DataOnDemandSvc.h:254
DataOnDemandSvc::m_init
bool m_init
flag to warm up the configuration
Definition: DataOnDemandSvc.h:256
DataOnDemandSvc::Leaf::Leaf
Leaf(std::string t, std::string n)
Definition: DataOnDemandSvc.h:157
DataOnDemandSvc::m_timer_nodes
ChronoEntity m_timer_nodes
Definition: DataOnDemandSvc.h:282
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
DataOnDemandSvc::m_updateRequired
bool m_updateRequired
Definition: DataOnDemandSvc.h:274
StatEntity.h
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
DataOnDemandSvc::Node::dataObject
bool dataObject
trivial object? DataObject?
Definition: DataOnDemandSvc.h:124
DataOnDemandSvc::DataOnDemandSvc
DataOnDemandSvc(const std::string &name, ISvcLocator *svc)
Standard initializing service constructor.
Definition: DataOnDemandSvc.cpp:41
DataOnDemandSvc::finalize
StatusCode finalize() override
Inherited Service overrides: Service finalization.
Definition: DataOnDemandSvc.cpp:316
GaudiUtils::HashMap< Gaudi::StringKey, Node >
IIncidentListener.h
gaudirun.level
level
Definition: gaudirun.py:261
DataOnDemandSvc::NodeMap
GaudiUtils::HashMap< Gaudi::StringKey, Node > NodeMap
Definition: DataOnDemandSvc.h:163
DataOnDemandSvc::~DataOnDemandSvc
~DataOnDemandSvc() override=default
Standard destructor.
DataOnDemandSvc::m_total
ChronoEntity m_total
Definition: DataOnDemandSvc.h:277
DataOnDemandSvc::Leaf::Leaf
Leaf()=default
DataOnDemandSvc::m_nodeMap
Map m_nodeMap
the major configuration property { 'data' : 'type' }
Definition: DataOnDemandSvc.h:273
DataOnDemandSvc::setupAlgHandlers
StatusCode setupAlgHandlers()
Initialize leaf handlers.
Definition: DataOnDemandSvc.cpp:486
DataOnDemandSvc::Node
Helper class of the DataOnDemandSvc.
Definition: DataOnDemandSvc.h:115
ChronoEntity.h
DataOnDemandSvc::i_setAlgHandler
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
Definition: DataOnDemandSvc.cpp:217
DataOnDemandSvc::configureHandler
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
Definition: DataOnDemandSvc.cpp:520
DataOnDemandSvc::update_2
void update_2(Property &p)
Definition: DataOnDemandSvc.cpp:110
DataOnDemandSvc::m_locked_algs
bool m_locked_algs
Definition: DataOnDemandSvc.h:286
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21
DataOnDemandSvc::update_3
void update_3(Property &p)
Definition: DataOnDemandSvc.cpp:98
IDODNodeMapper.h
DataOnDemandSvc::update_1
void update_1(Property &p)
Definition: DataOnDemandSvc.cpp:89
DataOnDemandSvc::reinitialize
StatusCode reinitialize() override
Inherited Service overrides: Service reinitialization.
Definition: DataOnDemandSvc.cpp:370
DataOnDemandSvc::update
StatusCode update()
update the handlers
Definition: DataOnDemandSvc.cpp:239
DataOnDemandSvc::AlgMap
GaudiUtils::HashMap< Gaudi::StringKey, Leaf > AlgMap
Definition: DataOnDemandSvc.h:164
IDODAlgMapper.h
DataOnDemandSvc::m_locked_all
bool m_locked_all
Definition: DataOnDemandSvc.h:287