The Gaudi Framework  master (37c0b60a)
DataOnDemandSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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& operator=( const Leaf& l ) = default;
149  Leaf( std::string t, std::string n ) : name( std::move( n ) ), type( std::move( t ) ) {}
150  };
151  // ==========================================================================
152 public:
153  // ==========================================================================
157  StatusCode initialize() override;
159  StatusCode finalize() override;
161  StatusCode reinitialize() override;
163  void handle( const Incident& incident ) override;
165  using extends::extends;
166  // ==========================================================================
167 protected:
168  // ==========================================================================
174  // ==========================================================================
180  StatusCode execHandler( const std::string& tag, Leaf& leaf );
181  // ==========================================================================
187  StatusCode execHandler( const std::string& tag, Node& node );
188  // ==========================================================================
191  // ==========================================================================
194  // ==========================================================================
196  StatusCode setup();
198  void i_setNodeHandler( const std::string& name, const std::string& type );
201  // ==========================================================================
202 protected:
203  // ==========================================================================
205  StatusCode update();
210  void dump( const MSG::Level level, const bool mode = true ) const;
211  // ==========================================================================
212 private:
213  // ==========================================================================
215  verbose() << "updated property " << p.name() << ", forcing update" << endmsg;
216  m_updateRequired = true;
217  };
219  warning() << p.name() << " " << p.documentation() << endmsg;
220  force_update( p );
221  };
222 
223  // ==========================================================================
236 
237  bool m_updateRequired = true;
238  // ==========================================================================
240  unsigned long long m_statAlg = 0;
241  unsigned long long m_statNode = 0;
242  unsigned long long m_stat = 0;
243  // ==========================================================================
247  bool m_locked_nodes = false;
248  bool m_locked_algs = false;
249  bool m_locked_all = false;
250  // ==========================================================================
253  // ==========================================================================
254  // Properties
255  Gaudi::Property<std::string> m_trapType{ this, "IncidentName", "DataFault", "the type of handled Incident" };
256  Gaudi::Property<std::string> m_dataSvcName{ this, "DataSvc", "EventDataSvc", "DataSvc name" };
257 
258  Gaudi::Property<bool> m_partialPath{ this, "UsePreceedingPath", true, "allow creation of partial leaves" };
260  this, "Dump", false,
261  [this]( auto& ) {
263  },
264  "dump configuration and stastics, if set to True after initialize it triggers a dump immediately" };
265  Gaudi::Property<bool> m_init{ this, "PreInitialize", false, "(pre)initialize all algorithms" };
267  this, "AllowPreInitializeFailure", false,
268  "allow (pre)initialization of algorithms to fail without stopping the application" };
269 
271  this, "Algorithms", {}, &DataOnDemandSvc::deprecated_property, "[[deprecated]] use AlgMap" };
273  this, "Nodes", {}, &DataOnDemandSvc::deprecated_property, "[[deprecated]] use NodeMap" };
274 
276  Gaudi::Property<Map> m_algMap{ this, "AlgMap", {}, &DataOnDemandSvc::force_update, "mapping {'data': 'algorithm'}" };
277  Gaudi::Property<Map> m_nodeMap{ this, "NodeMap", {}, &DataOnDemandSvc::force_update, "mapping {'data': 'type'}" };
278 
279  Gaudi::Property<std::string> m_prefix{ this, "Prefix", "/Event/" };
280 
282  this, "NodeMappingTools", {}, "list of tools of type IDODNodeMapper" };
284  this, "AlgMappingTools", {}, "list of tools of type IDODAlgMapper" };
285 };
286 // ============================================================================
287 
288 // ============================================================================
289 // The END
290 // ============================================================================
291 #endif // GAUDISVC_DATAONDEMANDSVC_H
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
DataOnDemandSvc::m_locked_nodes
bool m_locked_nodes
Definition: DataOnDemandSvc.h:247
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: PropertyBase.h:39
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:106
DataOnDemandSvc::i_setNodeHandler
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
Definition: DataOnDemandSvc.cpp:100
DataOnDemandSvc::deprecated_property
void deprecated_property(Gaudi::Details::PropertyBase &p)
Definition: DataOnDemandSvc.h:218
DataOnDemandSvc::Leaf::Leaf
Leaf(const Leaf &l)=default
DataOnDemandSvc::Setup
std::vector< std::string > Setup
Definition: DataOnDemandSvc.h:104
std::string
STL class.
IAlgTool
Definition: IAlgTool.h:33
ChronoEntity
Definition: ChronoEntity.h:31
DataOnDemandSvc::m_algMapping
Gaudi::Property< Setup > m_algMapping
Definition: DataOnDemandSvc.h:270
DataOnDemandSvc::m_algMapTools
Gaudi::Property< std::vector< std::string > > m_algMapTools
Definition: DataOnDemandSvc.h:283
DataOnDemandSvc::initialize
StatusCode initialize() override
Inherited Service overrides: Service initialization.
Definition: DataOnDemandSvc.cpp:175
DataOnDemandSvc::Node::name
std::string name
Definition: DataOnDemandSvc.h:126
DataOnDemandSvc::Node::num
unsigned long num
Definition: DataOnDemandSvc.h:127
DataOnDemandSvc::Leaf::type
std::string type
Definition: DataOnDemandSvc.h:143
DataOnDemandSvc::configureHandler
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
Definition: DataOnDemandSvc.cpp:379
DataOnDemandSvc::m_allowInitFailure
Gaudi::Property< bool > m_allowInitFailure
Definition: DataOnDemandSvc.h:266
Gaudi::Details::PropertyBase::documentation
std::string documentation() const
property documentation
Definition: PropertyBase.h:41
std::vector< std::string >
IDODNodeMapper.h
DataOnDemandSvc::setupAlgHandlers
StatusCode setupAlgHandlers()
Initialize leaf handlers.
Definition: DataOnDemandSvc.cpp:350
StatEntity.h
DataOnDemandSvc::Protection
Definition: DataOnDemandSvc.h:111
StringKey.h
DataOnDemandSvc::setup
StatusCode setup()
Setup routine (called by (re-) initialize.
Definition: DataOnDemandSvc.cpp:274
DataOnDemandSvc::Leaf::operator=
Leaf & operator=(const Leaf &l)=default
DataOnDemandSvc::m_dataSvc
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
Definition: DataOnDemandSvc.h:229
DataOnDemandSvc::m_algMappers
std::vector< IDODAlgMapper * > m_algMappers
Definition: DataOnDemandSvc.h:252
DataOnDemandSvc::Leaf::algorithm
IAlgorithm * algorithm
Definition: DataOnDemandSvc.h:141
gaudirun.c
c
Definition: gaudirun.py:525
DataOnDemandSvc::m_locked_algs
bool m_locked_algs
Definition: DataOnDemandSvc.h:248
IDODAlgMapper.h
DataOnDemandSvc::force_update
void force_update(Gaudi::Details::PropertyBase &p)
Definition: DataOnDemandSvc.h:214
DataOnDemandSvc::ClassH
TClass * ClassH
Definition: DataOnDemandSvc.h:105
DataOnDemandSvc::Leaf::executing
bool executing
Definition: DataOnDemandSvc.h:145
DataOnDemandSvc::Protection::m_bool
bool & m_bool
Definition: DataOnDemandSvc.h:112
DataOnDemandSvc::Node::Node
Node()=default
Service::FSMState
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:62
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:81
DataOnDemandSvc::m_algMgr
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
Definition: DataOnDemandSvc.h:227
bug_34121.t
t
Definition: bug_34121.py:31
IAlgManager
Definition: IAlgManager.h:37
DataOnDemandSvc::m_stat
unsigned long long m_stat
Definition: DataOnDemandSvc.h:242
DataOnDemandSvc::Leaf::num
unsigned long num
Definition: DataOnDemandSvc.h:144
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:20
DataOnDemandSvc::m_partialPath
Gaudi::Property< bool > m_partialPath
Definition: DataOnDemandSvc.h:258
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
IAlgorithm
Definition: IAlgorithm.h:38
DataOnDemandSvc::m_trapType
Gaudi::Property< std::string > m_trapType
Definition: DataOnDemandSvc.h:255
DataOnDemandSvc::Node::clazz
ClassH clazz
the actual class
Definition: DataOnDemandSvc.h:125
DataOnDemandSvc::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
Definition: DataOnDemandSvc.h:231
DataOnDemandSvc::m_nodeMap
Gaudi::Property< Map > m_nodeMap
Definition: DataOnDemandSvc.h:277
DataOnDemandSvc::execHandler
StatusCode execHandler(const std::string &tag, Leaf &leaf)
Execute leaf handler (algorithm)
Definition: DataOnDemandSvc.cpp:565
DataOnDemandSvc::Node
Definition: DataOnDemandSvc.h:122
SmartIF< IIncidentSvc >
DataOnDemandSvc::m_prefix
Gaudi::Property< std::string > m_prefix
Definition: DataOnDemandSvc.h:279
genconfuser.verbose
verbose
Definition: genconfuser.py:28
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
DataOnDemandSvc::m_dump
Gaudi::Property< bool > m_dump
Definition: DataOnDemandSvc.h:259
std::map< std::string, std::string >
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
gaudirun.level
level
Definition: gaudirun.py:364
DataOnDemandSvc::m_updateRequired
bool m_updateRequired
Definition: DataOnDemandSvc.h:237
DataOnDemandSvc::m_statNode
unsigned long long m_statNode
Definition: DataOnDemandSvc.h:241
DataOnDemandSvc::Protection::~Protection
~Protection()
Definition: DataOnDemandSvc.h:114
cpluginsvc.n
n
Definition: cpluginsvc.py:234
DataOnDemandSvc::Leaf::name
std::string name
Definition: DataOnDemandSvc.h:142
DataOnDemandSvc::Protection::Protection
Protection(bool &b)
Definition: DataOnDemandSvc.h:113
DataOnDemandSvc::AlgMap
GaudiUtils::HashMap< Gaudi::StringKey, Leaf > AlgMap
Definition: DataOnDemandSvc.h:155
DataOnDemandSvc::Node::Node
Node(ClassH c, bool e, std::string n)
Definition: DataOnDemandSvc.h:134
Service.h
DataOnDemandSvc::m_nodeMapTools
Gaudi::Property< std::vector< std::string > > m_nodeMapTools
Definition: DataOnDemandSvc.h:281
DataOnDemandSvc::dump
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
Definition: DataOnDemandSvc.cpp:601
DataOnDemandSvc::m_algMap
Gaudi::Property< Map > m_algMap
Definition: DataOnDemandSvc.h:276
DataOnDemandSvc::m_algs
AlgMap m_algs
Map of algorithms to handle incidents.
Definition: DataOnDemandSvc.h:233
MSG::Level
Level
Definition: IMessageSvc.h:25
gaudirun.type
type
Definition: gaudirun.py:160
DataOnDemandSvc::m_nodeMapping
Gaudi::Property< Setup > m_nodeMapping
Definition: DataOnDemandSvc.h:272
DataOnDemandSvc::m_dataSvcName
Gaudi::Property< std::string > m_dataSvcName
Definition: DataOnDemandSvc.h:256
ChronoEntity.h
DataOnDemandSvc::Node::dataObject
bool dataObject
trivial object? DataObject?
Definition: DataOnDemandSvc.h:130
gaudirun.l
dictionary l
Definition: gaudirun.py:583
DataOnDemandSvc::setupNodeHandlers
StatusCode setupNodeHandlers()
Initialize node handlers.
Definition: DataOnDemandSvc.cpp:321
MSG::ALWAYS
@ ALWAYS
Definition: IMessageSvc.h:25
IIncidentListener.h
std
STL namespace.
Gaudi::StateMachine::INITIALIZED
@ INITIALIZED
Definition: StateMachine.h:25
DataOnDemandSvc::Node::executing
bool executing
Definition: DataOnDemandSvc.h:128
DataOnDemandSvc::Leaf::Leaf
Leaf(std::string t, std::string n)
Definition: DataOnDemandSvc.h:149
DataOnDemandSvc::m_nodes
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
Definition: DataOnDemandSvc.h:235
DataOnDemandSvc::m_timer_algs
ChronoEntity m_timer_algs
Definition: DataOnDemandSvc.h:245
DataOnDemandSvc::finalize
StatusCode finalize() override
Inherited Service overrides: Service finalization.
Definition: DataOnDemandSvc.cpp:195
DataOnDemandSvc::update
StatusCode update()
update the handlers
Definition: DataOnDemandSvc.cpp:126
IDataProviderSvc
Definition: IDataProviderSvc.h:53
GaudiUtils::HashMap< Gaudi::StringKey, Node >
DataOnDemandSvc::m_timer_nodes
ChronoEntity m_timer_nodes
Definition: DataOnDemandSvc.h:244
DataOnDemandSvc::Leaf::Leaf
Leaf()=default
IIncidentSvc
Definition: IIncidentSvc.h:33
DataOnDemandSvc::m_timer_all
ChronoEntity m_timer_all
Definition: DataOnDemandSvc.h:246
Incident
Definition: Incident.h:27
IToolSvc
Definition: IToolSvc.h:29
DataOnDemandSvc::reinitialize
StatusCode reinitialize() override
Inherited Service overrides: Service reinitialization.
Definition: DataOnDemandSvc.cpp:243
DataOnDemandSvc::Leaf
Definition: DataOnDemandSvc.h:140
Gaudi::Property< std::string >
DataOnDemandSvc::m_locked_all
bool m_locked_all
Definition: DataOnDemandSvc.h:249
DataOnDemandSvc::NodeMap
GaudiUtils::HashMap< Gaudi::StringKey, Node > NodeMap
Definition: DataOnDemandSvc.h:154
DataOnDemandSvc::m_init
Gaudi::Property< bool > m_init
Definition: DataOnDemandSvc.h:265
DataOnDemandSvc
Definition: DataOnDemandSvc.h:100
DataOnDemandSvc::m_total
ChronoEntity m_total
Definition: DataOnDemandSvc.h:239
DataOnDemandSvc::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Incident service.
Definition: DataOnDemandSvc.h:225
DataOnDemandSvc::Map
std::map< std::string, std::string > Map
Definition: DataOnDemandSvc.h:275
DataOnDemandSvc::handle
void handle(const Incident &incident) override
IIncidentListener interfaces overrides: incident handling.
Definition: DataOnDemandSvc.cpp:461
DataOnDemandSvc::m_nodeMappers
std::vector< IDODNodeMapper * > m_nodeMappers
Definition: DataOnDemandSvc.h:251
DataOnDemandSvc::m_statAlg
unsigned long long m_statAlg
Definition: DataOnDemandSvc.h:240