| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
DataOnDemandSvc Class Reference

The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable name "IncidentName". More...

`#include <DataOnDemandSvc.h>`

Inheritance diagram for DataOnDemandSvc:
[legend]
Collaboration diagram for DataOnDemandSvc:
[legend]

## Classes
struct | Leaf
struct | Node
| Helper class of the DataOnDemandSvc. More...
struct | Protection
| Helper class of the DataOnDemandSvc. More...

## Public Types
typedef std::vector< std::string > | Setup
typedef TClass * | ClassH
typedef GaudiUtils::HashMap < Gaudi::StringKey, Node > | NodeMap
typedef GaudiUtils::HashMap < Gaudi::StringKey, Leaf > | AlgMap
Public Types inherited from extends1< Service, IIncidentListener >
typedef extends1 | base_class
| Typedef to this class.
typedef extend_interfaces1 < IIncidentListener > | extend_interfaces_base
| Typedef to the base of this class.
typedef extend_interfaces_base::ext_iids | interfaces
| MPL set of all the implemented interfaces.
Public Types inherited from Service
typedef Gaudi::PluginService::Factory2 < IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging | base_class
Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 | base_class
| Typedef to this class.
typedef extend_interfaces3 < IService, IProperty, IStateful > | extend_interfaces_base
| Typedef to the base of this class.
typedef extend_interfaces_base::ext_iids | interfaces
| MPL set of all the implemented interfaces.
Public Types inherited from extend_interfaces3< I1, I2, I3 >
typedef mpl::fold< typename I1::iid::iids::type, typename mpl::fold< typename I2::iid::iids::type, typename I3::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type, mpl::insert< mpl::_1, mpl::_2 > >::type | ext_iids
| MPL set of interfaces extended by this one.
Public Types inherited from extend_interfaces1< IIncidentListener >
typedef IIncidentListener::iid::iids::type | ext_iids
| MPL set of interfaces extended by this one.

## Public Member Functions
virtual StatusCode | initialize ()
| Inherited Service overrides: Service initialization.
virtual StatusCode | finalize ()
| Inherited Service overrides: Service finalization.
virtual StatusCode | reinitialize ()
| Inherited Service overrides: Service reinitialization.
virtual void | handle (const Incident &incident)
| IIncidentListener interfaces overrides: incident handling.
| DataOnDemandSvc (const std::string &name, ISvcLocator *svc)
| Standard initializing service constructor.
virtual | ~DataOnDemandSvc ()
| Standard destructor.
void | update_1 (Property &p)
void | update_2 (Property &p)
void | update_3 (Property &p)
void | update_dump (Property &)
| update handler for 'Dump' property
Public Member Functions inherited from extends1< Service, IIncidentListener >
| extends1 (A1 a1, A2 a2, A3 a3)
| Templated constructor with 3 arguments.
| extends1 (A1 a1, A2 a2)
| Templated constructor with 2 arguments.
| extends1 (A1 a1)
| Templated constructor with 1 argument.
| extends1 ()
| Default constructor.
virtual void * | i_cast (const InterfaceID &tid) const
| Implementation of IInterface::i_cast.
virtual StatusCode | queryInterface (const InterfaceID &ti, void **pp)
| Implementation of IInterface::queryInterface.
virtual std::vector< std::string > | getInterfaceNames () const
| Implementation of IInterface::getInterfaceNames.
virtual | ~extends1 ()
| Virtual destructor.
Public Member Functions inherited from Service
virtual unsigned long | release ()
| Release Interface instance.
virtual const std::string & | name () const
| Retrieve name of the service.
virtual StatusCode | configure ()
virtual StatusCode | start ()
virtual StatusCode | stop ()
virtual StatusCode | terminate ()
virtual Gaudi::StateMachine::State | FSMState () const
virtual Gaudi::StateMachine::State | targetFSMState () const
virtual StatusCode | restart ()
virtual StatusCode | sysInitialize ()
| Initialize Service.
virtual StatusCode | sysStart ()
| Initialize Service.
virtual StatusCode | sysStop ()
| Initialize Service.
virtual StatusCode | sysFinalize ()
| Finalize Service.
virtual StatusCode | sysReinitialize ()
| Re-initialize the Service.
virtual StatusCode | sysRestart ()
| Re-initialize the Service.
virtual StatusCode | setProperty (const Property &p)
virtual StatusCode | setProperty (const std::string &s)
virtual StatusCode | setProperty (const std::string &n, const std::string &v)
virtual StatusCode | getProperty (Property *p) const
virtual const Property & | getProperty (const std::string &name) const
virtual StatusCode | getProperty (const std::string &n, std::string &v) const
virtual const std::vector < Property * > & | getProperties () const
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value
| Service (const std::string &name, ISvcLocator *svcloc)
| Standard Constructor.
SmartIF< ISvcLocator > & | serviceLocator () const
| Retrieve pointer to service locator.
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job.
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist.
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist.
template<class T >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property.
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties.
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
| CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
| Templated constructor with 3 arguments.
| CommonMessaging (const A1 &a1, const A2 &a2)
| Templated constructor with 2 arguments.
| CommonMessaging (const A1 &a1)
| Templated constructor with 1 argument.
| CommonMessaging ()
| Default constructor.
virtual | ~CommonMessaging ()
| Virtual destructor.
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service.
MsgStream & | msgStream () const
| Return an uninitialized MsgStream.
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts.
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL)
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR)
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR)
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING)
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO)
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG)
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO)
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream
Public Member Functions inherited from extend_interfaces1< IIncidentListener >
virtual | ~extend_interfaces1 ()
| Virtual destructor.
Public Member Functions inherited from IIncidentListener
| DeclareInterfaceID (IIncidentListener, 2, 0)
| InterfaceID.
Public Member Functions inherited from IInterface
virtual unsigned long | addRef ()=0
| Increment the reference count of Interface instance.
virtual unsigned long | release ()=0
| Release Interface instance.
virtual unsigned long | refCount () const =0
| Current reference count.
virtual | ~IInterface ()
| Virtual destructor.

## Protected Member Functions
StatusCode | configureHandler (Leaf &leaf)
| Configure handler for leaf.
StatusCode | execHandler (const std::string &tag, Leaf &leaf)
| Execute leaf handler (algorithm)
StatusCode | execHandler (const std::string &tag, Node &node)
| Execute node handler (simple object creation using seal reflection)
StatusCode | setupNodeHandlers ()
| Initialize node handlers.
StatusCode | setupAlgHandlers ()
| Initialize leaf handlers.
StatusCode | setup ()
| Setup routine (called by (re-) initialize.
void | i_setNodeHandler (const std::string &name, const std::string &type)
| Internal method to initialize a node handler.
StatusCode | i_setAlgHandler (const std::string &name, const Gaudi::Utils::TypeNameString &alg)
| Internal method to initialize an algorithm handler.
StatusCode | update ()
| update the handlers
MsgStream & | stream () const
| get the message stream
void | dump (const MSG::Level level, const bool mode=true) const
| dump the content of DataOnDemand service

## Private Types
typedef std::map< std::string, std::string > | Map

## Private Attributes
SmartIF< IIncidentSvc > | m_incSvc
| Incident service.
SmartIF< IAlgManager > | m_algMgr
| Algorithm manager.
SmartIF< IDataProviderSvc > | m_dataSvc
| Data provider reference.
SmartIF< IToolSvc > | m_toolSvc
| Data provider reference.
std::string | m_trapType
| Trap name.
std::string | m_dataSvcName
| Data service name.
bool | m_partialPath
| Flag to allow for the creation of partial leaves.
bool | m_dump
| flag to force the printout
bool | m_init
| flag to warm up the configuration
bool | m_allowInitFailure
| flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithms fails (m_init).
Setup | m_algMapping
| Mapping to algorithms.
Setup | m_nodeMapping
| Mapping to nodes.
AlgMap | m_algs
| Map of algorithms to handle incidents.
NodeMap | m_nodes
| Map of "empty" objects to be placed as intermediate nodes.
Map | m_algMap
| the major configuration property { 'data' : 'algorithm' }
Map | m_nodeMap
| the major configuration property { 'data' : 'type' }
bool | m_updateRequired
std::string | m_prefix
MsgStream * | m_log
ChronoEntity | m_total
ulonglong | m_statAlg
ulonglong | m_statNode
ulonglong | m_stat
ChronoEntity | m_timer_nodes
ChronoEntity | m_timer_algs
ChronoEntity | m_timer_all
bool | m_locked_nodes
bool | m_locked_algs
bool | m_locked_all
std::vector< std::string > | m_nodeMapTools
std::list< IDODNodeMapper * > | m_nodeMappers
std::vector< std::string > | m_algMapTools
std::list< IDODAlgMapper * > | m_algMappers

## Additional Inherited Members
Static Public Member Functions inherited from IInterface
static const InterfaceID & | interfaceID ()
| Return an instance of InterfaceID identifying the interface.
Protected Attributes inherited from Service
IntegerProperty | m_outputLevel
| Service output level.
Gaudi::StateMachine::State | m_state
| Service state.
Gaudi::StateMachine::State | m_targetState
| Service state.

## Detailed Description

The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable name "IncidentName".

In the job options handlers can be declared, which allow to configure this service. Such handlers are either:

- Node handlers, if objects other than the default object type have to be instantiated. DataOnDemandSvc.Nodes = { "DATA='/Event/Rec' TYPE='DataObject'", "DATA='/Event/Rec/Muon' TYPE='DataObject'" };

- Leaf handlers (Algorithms), which get instantiated and executed on demand. DataOnDemandSvc.Algorithms = { "DATA='/Event/Rec/Muon/Digits' TYPE='MuonDigitAlg/MyMuonDigits'" }; If the algorithm name is omitted the class name will be the instance name.

The handlers only get called if the exact path matches. In the event already the partial path to any handler is missing a leaf handler may be triggered, which includes the partial paths ( DataOnDemandSvc.UsePreceedingPath = true )

2006-10-15: New options (using map-like semantics:)

DataOnDemandSvc.AlgMap +=
{ "Phys/StdLoosePions/Particles" : "PreLoadParticles/StdLoosePions" ,
"Phys/StdLoosePions/Vertioces" : "PreLoadParticles/StdLoosePions" } ;
DataOnDemandSvc.NodeMap +=
{ "Phys" : "DataObject" ,
"MC" : "DataObject" } ;

New treatment of preceding paths. for each registered leaf or node the all parent nodes are added into the node-map with default directory type 'DataObject'

The major properties are equipped with handlers (more or less mandatory for interactive work in python)

From now the default prefix ( "/Event/" ) could be omitted from any data-item. It will be added automatically.

Author
  M.Frank

Version
  1.0

Definition at line 90 of file DataOnDemandSvc.h.

## Member Typedef Documentation

typedef GaudiUtils::HashMap<Gaudi::StringKey, Leaf> DataOnDemandSvc::AlgMap

Definition at line 172 of file DataOnDemandSvc.h.

typedef TClass* DataOnDemandSvc::ClassH

Definition at line 96 of file DataOnDemandSvc.h.

typedef std::map<std::string,std::string> DataOnDemandSvc::Map
| private

Definition at line 283 of file DataOnDemandSvc.h.

typedef GaudiUtils::HashMap<Gaudi::StringKey, Node> DataOnDemandSvc::NodeMap

Definition at line 171 of file DataOnDemandSvc.h.

typedef std::vector<std::string> DataOnDemandSvc::Setup

Definition at line 95 of file DataOnDemandSvc.h.

## Constructor & Destructor Documentation

DataOnDemandSvc::DataOnDemandSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc
| ) |  |

Standard initializing service constructor.

Parameters

  name | [IN] Service instance name
  svc | [IN] Pointer to service locator

Returns
  Reference to DataOnDemandSvc object.

Definition at line 46 of file DataOnDemandSvc.cpp.

: base_class(name, svc)
, m_incSvc ( 0 )
, m_algMgr ( 0 )
, m_dataSvc ( 0 )
//
, m_trapType ( "DataFault")
, m_dataSvcName ( "EventDataSvc" )
, m_partialPath ( true )
, m_dump ( false )
, m_init ( false )
, m_allowInitFailure(false)
//
, m_algMapping ()
, m_nodeMapping ()
//
, m_algMap ( )
, m_nodeMap ( )
//
, m_updateRequired ( true )
, m_prefix ( "/Event/" )
, m_log ( 0 )
, m_total ( )
, m_statAlg ( 0 )
, m_statNode ( 0 )
, m_stat ( 0 )
//
, m_timer_nodes ()
, m_timer_algs ()
, m_timer_all ()
, m_locked_nodes ( false )
, m_locked_algs ( false )
, m_locked_all ( false )
//
{
// ==========================================================================
declareProperty
( "IncidentName" ,
m_trapType ,
"The type of handled Incident" ) ;
//
declareProperty ( "DataSvc" , m_dataSvcName ) ;
//
declareProperty ( "UsePreceedingPath" , m_partialPath ) ;
declareProperty
( "Dump" ,
m_dump ,
"Dump the configuration and stastics" ) ->
declareUpdateHandler ( &DataOnDemandSvc::update_dump , this ) ;
//
declareProperty
( "PreInitialize" ,
m_init ,
"Flag to (pre)initialize all algorithms" ) ;
declareProperty
( "AllowPreInitializeFailure" ,
m_allowInitFailure ,
"Allow (pre)initialization of algorithms to fail without stopping the application" ) ;
//
declareProperty ( "Algorithms" , m_algMapping ) ->
declareUpdateHandler ( &DataOnDemandSvc::update_2 , this ) ;
declareProperty ( "Nodes" , m_nodeMapping ) ->
declareUpdateHandler ( &DataOnDemandSvc::update_3 , this ) ;
//
declareProperty ( "AlgMap" , m_algMap ) ->
declareUpdateHandler ( &DataOnDemandSvc::update_1 , this ) ;
declareProperty ( "NodeMap" , m_nodeMap ) ->
declareUpdateHandler ( &DataOnDemandSvc::update_1 , this ) ;
declareProperty ( "Prefix" , m_prefix ) ;
declareProperty("NodeMappingTools", m_nodeMapTools,
"List of tools of type IDODNodeMapper");
declareProperty("AlgMappingTools", m_algMapTools,
"List of tools of type IDODAlgMapper");
// ==========================================================================
}

DataOnDemandSvc::~DataOnDemandSvc | ( |  | ) |
| virtual

Standard destructor.

Definition at line 341 of file DataOnDemandSvc.cpp.

{ if ( 0 != m_log ) { delete m_log ; m_log = 0 ; } }

## Member Function Documentation

StatusCode DataOnDemandSvc::configureHandler | ( | Leaf & | leaf | ) |
| protected

Configure handler for leaf.

Parameters

  leaf | [IN] Reference to leaf handler

Returns
  StatusCode indicating success or failure

Definition at line 590 of file DataOnDemandSvc.cpp.

{
if ( 0 != l.algorithm ) { return StatusCode::SUCCESS ; }
if ( 0 == m_algMgr ) { return StatusCode::FAILURE ; }
l.algorithm = m_algMgr->algorithm(l.name, false);
if ( 0 != l.algorithm ) { return StatusCode::SUCCESS ; }
// create it!
StatusCode sc = m_algMgr->createAlgorithm ( l.type , l.name , l.algorithm , true ) ;
if ( sc.isFailure() )
{
stream()
<< MSG::ERROR
<< "Failed to create algorithm "
<< l.type << "('" << l.name<< "')" << endmsg;
l.algorithm = 0 ;
return sc ; // RETURN
}
if ( l.algorithm->isInitialized() ) { return StatusCode:: SUCCESS ;}
// initialize it!
sc = l.algorithm -> sysInitialize () ;
if ( sc.isFailure() )
{
stream()
<< MSG::ERROR
<< "Failed to initialize algorithm "
<< l.type << "('" << l.name<< "')" << endmsg;
l.algorithm = 0 ;
return sc ; // RETURN
}
if ( Gaudi::StateMachine::RUNNING == l.algorithm->FSMState() )
{ return StatusCode::SUCCESS ; }
// run it!
sc = l.algorithm->sysStart() ;
if ( sc.isFailure() )
{
stream()
<< MSG::ERROR
<< "Failed to 'run' algorithm "
<< l.type << "('" << l.name<< "')" << endmsg;
l.algorithm = 0 ;
return sc ; // RETURN
}
return StatusCode::SUCCESS ;
}

void DataOnDemandSvc::dump | ( | const MSG::Level | level,
|  | const bool | mode = `true`
| ) |  | const
| protected

dump the content of DataOnDemand service

Parameters

  level | the printout level
  mode | the printout mode

Definition at line 868 of file DataOnDemandSvc.cpp.

{
if ( m_algs.empty() && m_nodes.empty() ) { return ; }
typedef std::pair<std::string,std::string> Pair ;
typedef std::map<std::string,Pair> PMap ;
PMap _m ;
for ( AlgMap::const_iterator alg = m_algs.begin() ;
m_algs.end() != alg ; ++alg )
{
PMap::const_iterator check = _m.find(alg->first) ;
if ( _m.end() != check )
{
stream()
<< MSG::WARNING
<< " The data item is activated for '"
<< check->first << "' as '" << check->second.first << "'" << endmsg ;
}
const Leaf& l = alg->second ;
std::string nam = ( l.name == l.type ? l.type : (l.type+"/"+l.name) ) ;
//
if ( !mode && 0 == l.num ) { continue ; }
//
std::string val ;
if ( mode ) { val = ( 0 == l.algorithm ) ? "F" : "T" ; }
else { val = boost::lexical_cast<std::string>( l.num ) ; }
//
_m[ no_prefix ( alg->first , m_prefix ) ] = std::make_pair ( nam , val ) ;
}
// nodes:
for ( NodeMap::const_iterator node = m_nodes.begin() ;
m_nodes.end() != node ; ++node )
{
PMap::const_iterator check = _m.find(node->first) ;
if ( _m.end() != check )
{
stream()
<< MSG::WARNING
<< " The data item is already activated for '"
<< check->first << "' as '" << check->second.first << "'" << endmsg ;
}
const Node& n = node->second ;
std::string nam = "'" + n.name + "'" ;
//
std::string val ;
if ( !mode && 0 == n.num ) { continue ; }
if ( mode ) { val = ( 0 == n.clazz ) ? "F" : "T" ; }
else { val = boost::lexical_cast<std::string>( n.num ) ; }
//
_m[ no_prefix ( node->first , m_prefix ) ] = std::make_pair ( nam , val ) ;
}
//
if ( _m.empty() ) { return ; }
// find the correct formats
size_t n1 = 0 ;
size_t n2 = 0 ;
size_t n3 = 0 ;
for ( PMap::const_iterator it = _m.begin() ; _m.end() != it ; ++it )
{
n1 = std::max ( n1 , it->first.size() ) ;
n2 = std::max ( n2 , it->second.first.size() ) ;
n3 = std::max ( n3 , it->second.second.size() ) ;
}
if ( 10 > n1 ) { n1 = 10 ; }
if ( 10 > n2 ) { n2 = 10 ; }
if ( 60 < n1 ) { n1 = 60 ; }
if ( 60 < n2 ) { n2 = 60 ; }
//
const std::string _f = " | %%1$-%1%.%1%s | %%2$-%2%.%2%s | %%3$%3%.%3%s |" ;
boost::format _ff ( _f ) ;
_ff % n1 % n2 % n3 ;
const std::string _format = _ff.str() ;
MsgStream& msg = stream() << level ;
if ( mode ) { msg << "Data-On-Demand Actions enabled for:" ; }
else { msg << "Data-On-Demand Actions has been used for:" ; }
boost::format fmt1( _format) ;
fmt1 % "Address" % "Creator" % ( mode ? "S" : "#" ) ;
//
const std::string header = fmt1.str() ;
std::string line = std::string( header.size() , '-' ) ;
line[0] = ' ' ;
msg << std::endl << line
<< std::endl << header
<< std::endl << line ;
// make the actual printout:
for ( PMap::const_iterator item = _m.begin() ;
_m.end() != item ; ++item )
{
boost::format fmt( _format) ;
msg << std::endl <<
( fmt % item->first % item->second.first % item->second.second ) ;
}
msg << std::endl << line << endmsg ;
}

StatusCode DataOnDemandSvc::execHandler | ( | const std::string & | tag,
|  | Leaf & | leaf
| ) |  |
| protected

Execute leaf handler (algorithm)

Parameters

  tag | [IN] Path to requested leaf
  leaf | [IN] Reference to leaf handler

Returns
  StatusCode indicating success or failure

Definition at line 827 of file DataOnDemandSvc.cpp.

{
Gaudi::Utils::LockedChrono timer ( m_timer_algs , m_locked_algs ) ;
//
if ( l.executing ) { return StatusCode::FAILURE ; } // RETURN
//
if ( 0 == l.algorithm )
{
StatusCode sc = configureHandler ( l ) ;
if ( sc.isFailure() )
{
stream()
<< MSG::ERROR
<< "Failed to configure handler for: "
<< l.name << "[" << l.type << "] " << tag << endmsg;
return sc ; // RETURN
}
}
//
Chrono atimer ( m_total ) ;
//
Protection p(l.executing);
StatusCode sc = l.algorithm->sysExecute();
if ( sc.isFailure() )
{
stream() << MSG::ERROR
<< "Failed to execute the algorithm:"
<< l.algorithm->name() << " for location:" << tag << endmsg;
return sc ; // RETURN
}
++l.num ;
//
return StatusCode::SUCCESS ;
}

StatusCode DataOnDemandSvc::execHandler | ( | const std::string & | tag,
|  | Node & | node
| ) |  |
| protected

Execute node handler (simple object creation using seal reflection)

Parameters

  tag | [IN] Path to requested leaf
  node | [IN] Reference to node handler

Returns
  StatusCode indicating success or failure

Definition at line 771 of file DataOnDemandSvc.cpp.

{
Gaudi::Utils::LockedChrono timer ( m_timer_nodes , m_locked_nodes ) ;
if ( n.executing ) { return StatusCode::FAILURE ; } // RETURN
Protection p(n.executing);
DataObject* object= 0 ;
if ( n.dataObject ) { object = new DataObject() ; }
else
{
// try to recover the handler
if ( !n.clazz ) { n.clazz = TClass::GetClass(n.name.c_str()) ; }
if ( !n.clazz )
{
stream()
<< MSG::ERROR
<< "Failed to get dictionary for class '"
<< n.name
<< "' for location:" << tag << endmsg;
return StatusCode::FAILURE ; // RETURN
}
object = reinterpret_cast<DataObject*>(n.clazz->New());
if ( !object )
{
stream()
<< MSG::ERROR
<< "Failed to create an object of type:"
<< n.clazz->GetName() << " for location:" << tag
<< endmsg;
return StatusCode::FAILURE ; // RETURN
}
}
//
StatusCode sc = m_dataSvc->registerObject(tag, object );
if ( sc.isFailure() )
{
stream()
<< MSG::ERROR << "Failed to register an object of type:"
<< n.name << " at location:" << tag
<< endmsg;
return sc ; // RETURN
}
++n.num ;
//
return StatusCode::SUCCESS ;
}

StatusCode DataOnDemandSvc::finalize | ( |  | ) |
| virtual

Inherited Service overrides: Service finalization.

Reimplemented from Service.

Definition at line 364 of file DataOnDemandSvc.cpp.

{
//
stream ()
<< MSG::INFO
<< "Handled \"" << m_trapType << "\" incidents: "
<< m_statAlg << "/" << m_statNode << "/" << m_stat << "(Alg/Node/Total)."
<< endmsg ;
if ( m_dump || MSG::DEBUG >= outputLevel() )
{
stream ()
<< MSG::INFO
<< m_total.outputUserTime
( "Algorithm timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
<< m_total.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
stream ()
<< MSG::INFO
<< m_timer_nodes.outputUserTime
( "Nodes timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
<< m_timer_nodes.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
stream ()
<< MSG::INFO
<< m_timer_algs .outputUserTime
( "Algs timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
<< m_timer_algs .outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
stream ()
<< MSG::INFO
<< m_timer_all .outputUserTime
( "All timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
<< m_timer_all .outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
}
// dump it!
if ( m_dump ) { dump ( MSG::INFO , false ) ; }
else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG , false ) ; }
//
if ( m_incSvc )
{
m_incSvc->removeListener(this, m_trapType);
m_incSvc.reset();
}
m_algMgr.reset();
m_dataSvc.reset();
if (m_toolSvc) { // we may not have retrieved the ToolSvc
// Do not call releaseTool if the ToolSvc was already finalized.
if (SmartIF<IStateful>(m_toolSvc)->FSMState() > Gaudi::StateMachine::CONFIGURED) {
for(std::list<IDODNodeMapper*>::iterator i = m_nodeMappers.begin(); i != m_nodeMappers.end(); ++i)
m_toolSvc->releaseTool(*i).ignore();
for(std::list<IDODAlgMapper*>::iterator i = m_algMappers.begin(); i != m_algMappers.end(); ++i)
m_toolSvc->releaseTool(*i).ignore();
} else {
warning() << "ToolSvc already finalized: cannot release tools. Check options." << endmsg;
}
m_nodeMappers.clear();
m_algMappers.clear();
m_toolSvc.reset();
}
return Service::finalize();
}

void DataOnDemandSvc::handle | ( | const Incident & | incident | ) |
| virtual

IIncidentListener interfaces overrides: incident handling.

Implements IIncidentListener.

Definition at line 698 of file DataOnDemandSvc.cpp.

{
Gaudi::Utils::LockedChrono timer ( m_timer_all , m_locked_all ) ;
++m_stat ;
// proper incident type?
if ( incident.type() != m_trapType ) { return ; } // RETURN
const DataIncident* inc = dynamic_cast<const DataIncident*>(&incident);
if ( 0 == inc ) { return ; } // RETURN
// update if needed!
if ( m_updateRequired ) { update() ; }
if ( MSG::VERBOSE >= outputLevel() )
{
verbose()
<< "Incident: [" << incident.type () << "] "
<< " = " << incident.source ()
<< " Location:" << inc->tag() << endmsg;
}
// ==========================================================================
// const std::string& tag = inc->tag();
Gaudi::StringKey tag ( inc->tag() ) ;
// ==========================================================================
NodeMap::iterator icl = m_nodes.find ( tag ) ;
if ( icl != m_nodes.end() )
{
StatusCode sc = execHandler ( tag , icl->second ) ;
if ( sc.isSuccess() ) { ++m_statNode ; }
return ; // RETURN
}
// ==========================================================================
AlgMap::iterator ialg = m_algs.find ( tag ) ;
if ( ialg != m_algs.end() )
{
StatusCode sc = execHandler ( tag , ialg->second ) ;
if ( sc.isSuccess() ) { ++m_statAlg ; }
return ; // RETURN
}
// ==========================================================================
// Fall back on the tools
if (m_toolSvc) {
if (MSG::VERBOSE >= outputLevel())
verbose() << "Try to find mapping with mapping tools" << endmsg;
Finder finder(no_prefix(inc->tag(), m_prefix), m_nodeMappers, m_algMappers);
// - try the node mappers
std::string node = finder.node();
if (isGood(node)) {
// if one is found update the internal node mapping and try again.
if (MSG::VERBOSE >= outputLevel())
verbose() << "Found Node handler: " << node << endmsg;
i_setNodeHandler(inc->tag(), node);
handle(incident);
--m_stat; // avoid double counting because of recursion
return;
}
// - try alg mappings
Gaudi::Utils::TypeNameString alg = finder.alg();
if (isGood(alg)) {
// we got an algorithm, update alg map and try to handle again
if (MSG::VERBOSE >= outputLevel())
verbose() << "Found Algorithm handler: " << alg << endmsg;
i_setAlgHandler(inc->tag(), alg).ignore();
handle(incident);
--m_stat; // avoid double counting because of recursion
return;
}
}
}

StatusCode DataOnDemandSvc::i_setAlgHandler | ( | const std::string & | name,
|  | const Gaudi::Utils::TypeNameString & | alg
| ) |  |
| protected

Internal method to initialize an algorithm handler.

Definition at line 257 of file DataOnDemandSvc.cpp.

{
Leaf leaf(alg.type(), alg.name());
if (m_init)
{
StatusCode sc = configureHandler(leaf);
if (sc.isFailure()) {
if (m_allowInitFailure) {
// re-store the content of the leaf object to try again to initialize
// the algorithm later (on demand)
leaf = Leaf(alg.type(), alg.name());
}
else
return sc;
}
}
m_algs[name] = leaf;
return StatusCode::SUCCESS;
}

void DataOnDemandSvc::i_setNodeHandler | ( | const std::string & | name,
|  | const std::string & | type
| ) |  |
| protected

Internal method to initialize a node handler.

Definition at line 247 of file DataOnDemandSvc.cpp.

{
ClassH cl = TClass::GetClass(type.c_str()) ;
if (!cl) {
warning()
<< "Failed to access dictionary class for "
<< name << " of type:" << type << endmsg;
}
m_nodes[name] = Node(cl, false, type);
}

StatusCode DataOnDemandSvc::initialize | ( |  | ) |
| virtual

Inherited Service overrides: Service initialization.

Reimplemented from Service.

Definition at line 346 of file DataOnDemandSvc.cpp.

{
// initialize the Service Base class
StatusCode sc = Service::initialize();
if ( sc.isFailure() ) { return sc; }
sc = setup();
if ( sc.isFailure() ) { return sc; }
//
if ( m_dump ) { dump ( MSG::INFO ) ; }
else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG ) ; }
//
if ( m_init ) { return update () ; }
//
return StatusCode::SUCCESS ;
}

StatusCode DataOnDemandSvc::reinitialize | ( |  | ) |
| virtual

Inherited Service overrides: Service reinitialization.

re-initialization of the service

Reimplemented from Service.

Definition at line 425 of file DataOnDemandSvc.cpp.

{
// reinitialize the Service Base class
if ( 0 != m_incSvc )
{
m_incSvc -> removeListener ( this , m_trapType );
m_incSvc.reset();
}
m_algMgr.reset();
m_dataSvc.reset();
for(std::list<IDODNodeMapper*>::iterator i = m_nodeMappers.begin(); i != m_nodeMappers.end(); ++i)
m_toolSvc->releaseTool(*i).ignore();
m_nodeMappers.clear();
for(std::list<IDODAlgMapper*>::iterator i = m_algMappers.begin(); i != m_algMappers.end(); ++i)
m_toolSvc->releaseTool(*i).ignore();
m_algMappers.clear();
m_toolSvc.reset();
if ( 0 != m_log ) { delete m_log ; m_log = 0 ; }
//
StatusCode sc = Service::reinitialize();
if ( sc.isFailure() ) { return sc; }
//
sc = setup() ;
if ( sc.isFailure() ) { return sc; }
//
if ( m_dump ) { dump ( MSG::INFO ) ; }
else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG ) ; }
//
return StatusCode::SUCCESS ;
}

StatusCode DataOnDemandSvc::setup | ( |  | ) |
| protected

Setup routine (called by (re-) initialize.

Definition at line 458 of file DataOnDemandSvc.cpp.

{
if ( !(m_algMgr = serviceLocator()) ) // assignment meant
{
error() << "Failed to retrieve the IAlgManager interface." << endmsg;
return StatusCode::FAILURE;
}
if ( !(m_incSvc = serviceLocator()->service("IncidentSvc")) ) // assignment meant
{
error() << "Failed to retrieve Incident service." << endmsg;
return StatusCode::FAILURE;
}
m_incSvc->addListener(this, m_trapType);
if ( !(m_dataSvc = serviceLocator()->service(m_dataSvcName)) ) // assignment meant
{
error()
<< "Failed to retrieve the data provider interface of "
<< m_dataSvcName << endmsg;
return StatusCode::FAILURE;
}
// No need to get the ToolSvc if we are not using tools
if (!(m_nodeMapTools.empty() && m_algMapTools.empty())) {
if ( !(m_toolSvc = serviceLocator()->service("ToolSvc")) ) // assignment meant
{
error() << "Failed to retrieve ToolSvc" << endmsg;
return StatusCode::FAILURE;
}
// load the node mapping tools
std::vector<std::string>::iterator i;
IDODNodeMapper *nodetool = 0;
for(i = m_nodeMapTools.begin(); i != m_nodeMapTools.end(); ++i) {
const StatusCode sc = m_toolSvc->retrieveTool(*i, nodetool);
if (sc.isFailure()) return sc;
m_nodeMappers.push_back(nodetool);
}
IDODAlgMapper *algtool = 0;
for(i = m_algMapTools.begin(); i != m_algMapTools.end(); ++i) {
const StatusCode sc = m_toolSvc->retrieveTool(*i, algtool);
if (sc.isFailure()) return sc;
m_algMappers.push_back(algtool);
}
}
return update();
}

StatusCode DataOnDemandSvc::setupAlgHandlers | ( |  | ) |
| protected

Initialize leaf handlers.

Definition at line 551 of file DataOnDemandSvc.cpp.

{
Setup::const_iterator j;
std::string typ, tag;
for(j=m_algMapping.begin(); j != m_algMapping.end(); ++j)
{
Tokenizer tok(true);
tok.analyse(*j, " ", "", "", "=", "'", "'");
for(Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); i++ ) {
const std::string& t = (*i).tag();
const std::string& v = (*i).value();
switch( ::toupper(t[0]) ) {
case 'D':
tag = v;
break;
case 'T':
typ = v;
break;
}
}
Gaudi::Utils::TypeNameString item(typ);
if ( m_algMap .end () != m_algMap .find ( tag ) ||
m_nodeMap .end () != m_nodeMap .find ( tag ) )
{
stream()
<< MSG::WARNING
<< "The obsolete property 'Algorithms' redefines the action for '"
+ tag + "' to be '" +item.type() +"/"+item.name()+"'"
<< endmsg ;
}
m_algMap[tag] = item.type() + "/" + item.name() ;
}
m_updateRequired = true ;
return StatusCode::SUCCESS;
}

StatusCode DataOnDemandSvc::setupNodeHandlers | ( |  | ) |
| protected

Initialize node handlers.

Definition at line 509 of file DataOnDemandSvc.cpp.

{
Setup::const_iterator j;
std::string nam, typ, tag;
StatusCode sc = StatusCode::SUCCESS;
// Setup for node leafs, where simply a constructor is called...
for ( j=m_nodeMapping.begin(); j != m_nodeMapping.end(); ++j)
{
Tokenizer tok(true);
tok.analyse(*j, " ", "", "", "=", "'", "'");
for ( Tokenizer::Items::iterator i = tok.items().begin();
i != tok.items().end(); i++ ) {
const std::string& t = (*i).tag();
const std::string& v = (*i).value();
switch( ::toupper(t[0]) ) {
case 'D':
tag = v;
break;
case 'T':
nam = v;
break;
}
}
if ( m_algMap .end () != m_algMap .find ( tag ) ||
m_nodeMap .end () != m_nodeMap .find ( tag ) )
{
stream()
<< MSG::WARNING
<< "The obsolete property 'Nodes' redefines the action for '"
+ tag + "' to be '" +nam+"'"
<< endmsg ;
}
m_nodeMap[tag] = nam ;
}
//
m_updateRequired = true ;
//
return sc;
}

MsgStream& DataOnDemandSvc::stream | ( |  | ) | const
| inline protected

get the message stream

Definition at line 240 of file DataOnDemandSvc.h.

{
if ( 0 == m_log ) { m_log = new MsgStream( msgSvc() , name() ) ; }
return *m_log;
}

StatusCode DataOnDemandSvc::update | ( |  | ) |
| protected

update the handlers

convert obsolete "Nodes" into new "NodeMap"

convert obsolete "Algorithms" into new "AlgMap"

add the default prefix

add the default prefix

get all directories

setup algorithms

setup nodes

Definition at line 279 of file DataOnDemandSvc.cpp.

{
if ( !m_updateRequired ) { return StatusCode::SUCCESS ; }
StatusCode sc = setupNodeHandlers() ; // convert "Nodes" new "NodeMap"
if ( sc.isFailure() )
{
stream() << MSG::ERROR << "Failed to setup old \"Nodes\"" << endmsg ;
return sc ;
}
sc = setupAlgHandlers() ; // convert "Algorithms" into "AlgMap"
if ( sc.isFailure() )
{
stream() << MSG::ERROR << "Failed to setup old \"Algorithms\"" << endmsg ;
return sc ;
}
add_prefix ( m_algMap , m_prefix ) ;
add_prefix ( m_nodeMap , m_prefix ) ;
typedef std::set<std::string> Set ;
Set dirs ;
if ( m_partialPath ){ get_dirs ( m_algMap , dirs ) ; }
if ( m_partialPath ){ get_dirs ( m_nodeMap , dirs ) ; }
//
Set::iterator _e = dirs.find("/Event") ;
if ( dirs.end() != _e ) { dirs.erase( _e ) ; }
// add all directories as nodes
for ( Set::const_iterator dir = dirs.begin() ; dirs.end() != dir ; ++dir )
{
if ( m_algMap .end () != m_algMap .find ( *dir ) ) { continue ; }
if ( m_nodeMap .end () != m_nodeMap .find ( *dir ) ) { continue ; }
m_nodeMap [*dir] = "DataObject" ;
}
//
m_algs .clear () ;
m_nodes .clear () ;
//
for ( Map::const_iterator ialg = m_algMap.begin() ;
m_algMap.end() != ialg ; ++ialg )
{
if (i_setAlgHandler(ialg->first, ialg->second).isFailure())
return StatusCode::FAILURE;
}
for ( Map::const_iterator inode = m_nodeMap.begin() ;
m_nodeMap.end() != inode ; ++inode )
{
i_setNodeHandler(inode->first, inode->second);
}
m_updateRequired = false ;
//
return StatusCode::SUCCESS ;
}

void DataOnDemandSvc::update_1 | ( | Property & | p | ) |

Definition at line 126 of file DataOnDemandSvc.cpp.

{
stream() << MSG::VERBOSE << " I am update handler for property " << p << endmsg ;
// force update
m_updateRequired = true ;
}

void DataOnDemandSvc::update_2 | ( | Property & | p | ) |

Definition at line 147 of file DataOnDemandSvc.cpp.

{
stream() << MSG::WARNING
<< "The property 'Algorithms' is obsolete, switch to map-like 'AlgMap' "
<< " = { 'data' : 'algorithm' } "
<< endmsg ;
// force update
m_updateRequired = true ;
}

void DataOnDemandSvc::update_3 | ( | Property & | p | ) |

Definition at line 135 of file DataOnDemandSvc.cpp.

{
stream() << MSG::WARNING
<< "The property 'Nodes' is obsolete, switch to map-like 'NodeMap' "
<< " = { 'data' : 'type' } "
<< endmsg ;
// force update
m_updateRequired = true ;
}

void DataOnDemandSvc::update_dump | ( | Property & |  | ) |

update handler for 'Dump' property

Definition at line 159 of file DataOnDemandSvc.cpp.

{
// no action if not yet initialized
if ( FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
// dump the configuration:
if ( m_dump ) { dump ( MSG::ALWAYS ) ; }
}

## Member Data Documentation

Map DataOnDemandSvc::m_algMap
| private

the major configuration property { 'data' : 'algorithm' }

Definition at line 285 of file DataOnDemandSvc.h.

std::list<IDODAlgMapper *> DataOnDemandSvc::m_algMappers
| private

Definition at line 307 of file DataOnDemandSvc.h.

Setup DataOnDemandSvc::m_algMapping
| private

Mapping to algorithms.

Definition at line 275 of file DataOnDemandSvc.h.

std::vector<std::string> DataOnDemandSvc::m_algMapTools
| private

Definition at line 306 of file DataOnDemandSvc.h.

SmartIF<IAlgManager> DataOnDemandSvc::m_algMgr
| private

Algorithm manager.

Definition at line 256 of file DataOnDemandSvc.h.

AlgMap DataOnDemandSvc::m_algs
| private

Map of algorithms to handle incidents.

Definition at line 279 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_allowInitFailure
| private

flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithms fails (m_init).

Definition at line 273 of file DataOnDemandSvc.h.

SmartIF<IDataProviderSvc> DataOnDemandSvc::m_dataSvc
| private

Data provider reference.

Definition at line 258 of file DataOnDemandSvc.h.

std::string DataOnDemandSvc::m_dataSvcName
| private

Data service name.

Definition at line 264 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_dump
| private

flag to force the printout

Definition at line 268 of file DataOnDemandSvc.h.

SmartIF<IIncidentSvc> DataOnDemandSvc::m_incSvc
| private

Incident service.

Definition at line 254 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_init
| private

flag to warm up the configuration

Definition at line 270 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_locked_algs
| private

Definition at line 301 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_locked_all
| private

Definition at line 302 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_locked_nodes
| private

Definition at line 300 of file DataOnDemandSvc.h.

MsgStream* DataOnDemandSvc::m_log
| mutable private

Definition at line 290 of file DataOnDemandSvc.h.

Map DataOnDemandSvc::m_nodeMap
| private

the major configuration property { 'data' : 'type' }

Definition at line 287 of file DataOnDemandSvc.h.

std::list<IDODNodeMapper *> DataOnDemandSvc::m_nodeMappers
| private

Definition at line 305 of file DataOnDemandSvc.h.

Setup DataOnDemandSvc::m_nodeMapping
| private

Mapping to nodes.

Definition at line 277 of file DataOnDemandSvc.h.

std::vector<std::string> DataOnDemandSvc::m_nodeMapTools
| private

Definition at line 304 of file DataOnDemandSvc.h.

NodeMap DataOnDemandSvc::m_nodes
| private

Map of "empty" objects to be placed as intermediate nodes.

Definition at line 281 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_partialPath
| private

Flag to allow for the creation of partial leaves.

Definition at line 266 of file DataOnDemandSvc.h.

std::string DataOnDemandSvc::m_prefix
| private

Definition at line 289 of file DataOnDemandSvc.h.

ulonglong DataOnDemandSvc::m_stat
| private

Definition at line 295 of file DataOnDemandSvc.h.

ulonglong DataOnDemandSvc::m_statAlg
| private

Definition at line 293 of file DataOnDemandSvc.h.

ulonglong DataOnDemandSvc::m_statNode
| private

Definition at line 294 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_timer_algs
| private

Definition at line 298 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_timer_all
| private

Definition at line 299 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_timer_nodes
| private

Definition at line 297 of file DataOnDemandSvc.h.

SmartIF<IToolSvc> DataOnDemandSvc::m_toolSvc
| private

Data provider reference.

Definition at line 260 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_total
| private

Definition at line 292 of file DataOnDemandSvc.h.

std::string DataOnDemandSvc::m_trapType
| private

Trap name.

Definition at line 262 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_updateRequired
| private

Definition at line 288 of file DataOnDemandSvc.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiCoreSvc/src/IncidentSvc/DataOnDemandSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiCoreSvc/src/IncidentSvc/DataOnDemandSvc.cpp