The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
DataOnDemandSvc.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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#pragma once
12
17#include <GaudiKernel/Service.h>
20#include <TClass.h>
21#include <map>
22#include <vector>
23
24class IAlgTool;
25class IAlgorithm;
26class IAlgManager;
27class IIncidentSvc;
29class IToolSvc;
30
87class DataOnDemandSvc : public extends<Service, IIncidentListener> {
88public:
89 typedef std::vector<std::string> Setup;
90 typedef TClass* ClassH;
91
96 struct Protection {
97 bool& m_bool;
98 Protection( bool& b ) : m_bool( b ) { m_bool = true; }
99 ~Protection() { m_bool = false; }
100 };
101
106 struct Node final {
108 ClassH clazz = nullptr; // the actual class
109 std::string name;
110 unsigned long num = 0;
111 bool executing = false;
113 bool dataObject = false; // trivial object? DataObject?
114
115 Node() = default;
116
117 Node( ClassH c, bool e, std::string n )
118 : clazz( c ), name( std::move( n ) ), executing( e ), dataObject( "DataObject" == name ) {}
119 };
120
121 struct Leaf {
123 std::string name;
124 std::string type;
125 unsigned long num = 0;
126 bool executing = false;
127 Leaf() = default;
128 Leaf( const Leaf& l ) = default;
129 Leaf& operator=( const Leaf& l ) = default;
130 Leaf( std::string t, std::string n ) : name( std::move( n ) ), type( std::move( t ) ) {}
131 };
132
133public:
137 StatusCode initialize() override;
139 StatusCode finalize() override;
141 StatusCode reinitialize() override;
143 void handle( const Incident& incident ) override;
145 using extends::extends;
146
147protected:
158 StatusCode execHandler( const std::string& tag, Leaf& leaf );
164 StatusCode execHandler( const std::string& tag, Node& node );
172 void i_setNodeHandler( const std::string& name, const std::string& type );
174 StatusCode i_setAlgHandler( const std::string& name, const Gaudi::Utils::TypeNameString& alg );
175
176protected:
183 void dump( const MSG::Level level, const bool mode = true ) const;
184
185private:
187 verbose() << "updated property " << p.name() << ", forcing update" << endmsg;
188 m_updateRequired = true;
189 };
191 warning() << p.name() << " " << p.documentation() << endmsg;
192 force_update( p );
193 };
194
207
208 bool m_updateRequired = true;
209
211 unsigned long long m_statAlg = 0;
212 unsigned long long m_statNode = 0;
213 unsigned long long m_stat = 0;
214
218 bool m_locked_nodes = false;
219 bool m_locked_algs = false;
220 bool m_locked_all = false;
221
222 std::vector<IDODNodeMapper*> m_nodeMappers;
223 std::vector<IDODAlgMapper*> m_algMappers;
224
225 Gaudi::Property<std::string> m_trapType{ this, "IncidentName", "DataFault", "the type of handled Incident" };
226 Gaudi::Property<std::string> m_dataSvcName{ this, "DataSvc", "EventDataSvc", "DataSvc name" };
227
228 Gaudi::Property<bool> m_partialPath{ this, "UsePreceedingPath", true, "allow creation of partial leaves" };
230 this, "Dump", false,
231 [this]( auto& ) {
233 },
234 "dump configuration and stastics, if set to True after initialize it triggers a dump immediately" };
235 Gaudi::Property<bool> m_init{ this, "PreInitialize", false, "(pre)initialize all algorithms" };
237 this, "AllowPreInitializeFailure", false,
238 "allow (pre)initialization of algorithms to fail without stopping the application" };
239
241 this, "Algorithms", {}, &DataOnDemandSvc::deprecated_property, "[[deprecated]] use AlgMap" };
243 this, "Nodes", {}, &DataOnDemandSvc::deprecated_property, "[[deprecated]] use NodeMap" };
244
245 typedef std::map<std::string, std::string> Map;
246 Gaudi::Property<Map> m_algMap{ this, "AlgMap", {}, &DataOnDemandSvc::force_update, "mapping {'data': 'algorithm'}" };
247 Gaudi::Property<Map> m_nodeMap{ this, "NodeMap", {}, &DataOnDemandSvc::force_update, "mapping {'data': 'type'}" };
248
249 Gaudi::Property<std::string> m_prefix{ this, "Prefix", "/Event/" };
250
252 this, "NodeMappingTools", {}, "list of tools of type IDODNodeMapper" };
254 this, "AlgMappingTools", {}, "list of tools of type IDODAlgMapper" };
255};
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable ...
GaudiUtils::HashMap< Gaudi::StringKey, Leaf > AlgMap
std::map< std::string, std::string > Map
Gaudi::Property< std::string > m_trapType
ChronoEntity m_timer_nodes
StatusCode reinitialize() override
Inherited Service overrides: Service reinitialization.
void force_update(Gaudi::Details::PropertyBase &p)
Gaudi::Property< std::vector< std::string > > m_algMapTools
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
Gaudi::Property< std::string > m_prefix
Gaudi::Property< Setup > m_algMapping
ChronoEntity m_timer_algs
StatusCode setup()
Setup routine (called by (re-) initialize.
std::vector< IDODNodeMapper * > m_nodeMappers
Gaudi::Property< std::vector< std::string > > m_nodeMapTools
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
Gaudi::Property< Setup > m_nodeMapping
Gaudi::Property< Map > m_algMap
ChronoEntity m_total
Gaudi::Property< bool > m_partialPath
SmartIF< IIncidentSvc > m_incSvc
Incident service.
Gaudi::Property< bool > m_init
unsigned long long m_statAlg
Gaudi::Property< bool > m_dump
StatusCode execHandler(const std::string &tag, Leaf &leaf)
Execute leaf handler (algorithm)
Gaudi::Property< std::string > m_dataSvcName
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
StatusCode setupAlgHandlers()
Initialize leaf handlers.
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
unsigned long long m_stat
std::vector< std::string > Setup
GaudiUtils::HashMap< Gaudi::StringKey, Node > NodeMap
StatusCode setupNodeHandlers()
Initialize node handlers.
unsigned long long m_statNode
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
StatusCode finalize() override
Inherited Service overrides: Service finalization.
StatusCode update()
update the handlers
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
void handle(const Incident &incident) override
IIncidentListener interfaces overrides: incident handling.
Gaudi::Property< Map > m_nodeMap
Gaudi::Property< bool > m_allowInitFailure
void deprecated_property(Gaudi::Details::PropertyBase &p)
std::vector< IDODAlgMapper * > m_algMappers
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
ChronoEntity m_timer_all
AlgMap m_algs
Map of algorithms to handle incidents.
StatusCode initialize() override
Inherited Service overrides: Service initialization.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
std::string documentation() const
property documentation
const std::string name() const
property name
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
Helper class to parse a string of format "type/name".
Common class providing an architecture-independent hash map.
Definition HashMap.h:80
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition IAlgManager.h:34
The interface implemented by the AlgTool base class.
Definition IAlgTool.h:29
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition IAlgorithm.h:36
Data provider interface definition.
The interface implemented by the IncidentSvc service.
The interface implemented by the IToolSvc base class.
Definition IToolSvc.h:28
Base class for all Incidents (computing events).
Definition Incident.h:24
Gaudi::StateMachine::State FSMState() const override
Definition Service.h:55
const std::string & name() const override
Retrieve name of the service.
Definition Service.cpp:333
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
Base class used to extend a class implementing other interfaces.
Definition extends.h:19
@ ALWAYS
Definition IMessageSvc.h:22
STL namespace.
Leaf & operator=(const Leaf &l)=default
Leaf(std::string t, std::string n)
Leaf(const Leaf &l)=default
Helper class of the DataOnDemandSvc.
ClassH clazz
the actual class
Node(ClassH c, bool e, std::string n)
bool dataObject
trivial object? DataObject?