All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DataOnDemandSvc Class Reference

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

#include <src/IncidentSvc/DataOnDemandSvc.h>

Inheritance diagram for DataOnDemandSvc:
Collaboration diagram for DataOnDemandSvc:

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. More...
 
typedef extend_interfaces1
< IIncidentListener
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from Service
typedef
Gaudi::PluginService::Factory
< 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. More...
 
typedef extend_interfaces3
< IService, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IService, IProperty, IStateful >
typedef mpl::fold< typename
IService::iid::iids::type,
typename mpl::fold< typename
IProperty::iid::iids::type,
typename
IStateful::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. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Public Types inherited from extend_interfaces1< IIncidentListener >
typedef
IIncidentListener::iid::iids::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 

Public Member Functions

virtual StatusCode initialize ()
 Inherited Service overrides: Service initialization. More...
 
virtual StatusCode finalize ()
 Inherited Service overrides: Service finalization. More...
 
virtual StatusCode reinitialize ()
 Inherited Service overrides: Service reinitialization. More...
 
virtual void handle (const Incident &incident)
 IIncidentListener interfaces overrides: incident handling. More...
 
 DataOnDemandSvc (const std::string &name, ISvcLocator *svc)
 Standard initializing service constructor. More...
 
virtual ~DataOnDemandSvc ()
 Standard destructor. More...
 
void update_1 (Property &p)
 
void update_2 (Property &p)
 
void update_3 (Property &p)
 
void update_dump (Property &)
 update handler for 'Dump' property More...
 
- Public Member Functions inherited from extends1< Service, IIncidentListener >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends1 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends1 ()
 Default constructor. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual ~extends1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector
< Property * > & 
getProperties () const
 Get list of properties. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
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. More...
 
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. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- 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. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces3< IService, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
- Public Member Functions inherited from extend_interfaces1< IIncidentListener >
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IIncidentListener
 DeclareInterfaceID (IIncidentListener, 2, 0)
 InterfaceID. More...
 

Protected Member Functions

StatusCode configureHandler (Leaf &leaf)
 Configure handler for leaf. More...
 
StatusCode execHandler (const std::string &tag, Leaf &leaf)
 Execute leaf handler (algorithm) More...
 
StatusCode execHandler (const std::string &tag, Node &node)
 Execute node handler (simple object creation using seal reflection) More...
 
StatusCode setupNodeHandlers ()
 Initialize node handlers. More...
 
StatusCode setupAlgHandlers ()
 Initialize leaf handlers. More...
 
StatusCode setup ()
 Setup routine (called by (re-) initialize. More...
 
void i_setNodeHandler (const std::string &name, const std::string &type)
 Internal method to initialize a node handler. More...
 
StatusCode i_setAlgHandler (const std::string &name, const Gaudi::Utils::TypeNameString &alg)
 Internal method to initialize an algorithm handler. More...
 
StatusCode update ()
 update the handlers More...
 
MsgStreamstream () const
 get the message stream More...
 
void dump (const MSG::Level level, const bool mode=true) const
 dump the content of DataOnDemand service More...
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Private Types

typedef std::map< std::string,
std::string > 
Map
 

Private Attributes

SmartIF< IIncidentSvcm_incSvc
 Incident service. More...
 
SmartIF< IAlgManagerm_algMgr
 Algorithm manager. More...
 
SmartIF< IDataProviderSvcm_dataSvc
 Data provider reference. More...
 
SmartIF< IToolSvcm_toolSvc
 Data provider reference. More...
 
std::string m_trapType
 Trap name. More...
 
std::string m_dataSvcName
 Data service name. More...
 
bool m_partialPath
 Flag to allow for the creation of partial leaves. More...
 
bool m_dump
 flag to force the printout More...
 
bool m_init
 flag to warm up the configuration More...
 
bool m_allowInitFailure
 flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithms fails (m_init). More...
 
Setup m_algMapping
 Mapping to algorithms. More...
 
Setup m_nodeMapping
 Mapping to nodes. More...
 
AlgMap m_algs
 Map of algorithms to handle incidents. More...
 
NodeMap m_nodes
 Map of "empty" objects to be placed as intermediate nodes. More...
 
Map m_algMap
 the major configuration property { 'data' : 'algorithm' } More...
 
Map m_nodeMap
 the major configuration property { 'data' : 'type' } More...
 
bool m_updateRequired
 
std::string m_prefix
 
MsgStreamm_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 InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level. More...
 
Gaudi::StateMachine::State m_state
 Service state. More...
 
Gaudi::StateMachine::State m_targetState
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::auto_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

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:)

{ "Phys/StdLoosePions/Particles" : "PreLoadParticles/StdLoosePions" ,
"Phys/StdLoosePions/Vertioces" : "PreLoadParticles/StdLoosePions" } ;
{ "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 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 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.

47  : base_class(name, svc)
48  , m_incSvc ( 0 )
49  , m_algMgr ( 0 )
50  , m_dataSvc ( 0 )
51  //
52  , m_trapType ( "DataFault")
53  , m_dataSvcName ( "EventDataSvc" )
54  , m_partialPath ( true )
55  , m_dump ( false )
56  , m_init ( false )
57  , m_allowInitFailure(false)
58  //
59  , m_algMapping ()
60  , m_nodeMapping ()
61  //
62  , m_algMap ( )
63  , m_nodeMap ( )
64  //
65  , m_updateRequired ( true )
66  , m_prefix ( "/Event/" )
67  , m_log ( 0 )
68  , m_total ( )
69  , m_statAlg ( 0 )
70  , m_statNode ( 0 )
71  , m_stat ( 0 )
72  //
73  , m_timer_nodes ()
74  , m_timer_algs ()
75  , m_timer_all ()
76  , m_locked_nodes ( false )
77  , m_locked_algs ( false )
78  , m_locked_all ( false )
79  //
80 {
81  // ==========================================================================
83  ( "IncidentName" ,
84  m_trapType ,
85  "The type of handled Incident" ) ;
86  //
87  declareProperty ( "DataSvc" , m_dataSvcName ) ;
88  //
89  declareProperty ( "UsePreceedingPath" , m_partialPath ) ;
91  ( "Dump" ,
92  m_dump ,
93  "Dump the configuration and stastics" ) ->
94  declareUpdateHandler ( &DataOnDemandSvc::update_dump , this ) ;
95  //
97  ( "PreInitialize" ,
98  m_init ,
99  "Flag to (pre)initialize all algorithms" ) ;
101  ( "AllowPreInitializeFailure" ,
103  "Allow (pre)initialization of algorithms to fail without stopping the application" ) ;
104  //
105  declareProperty ( "Algorithms" , m_algMapping ) ->
106  declareUpdateHandler ( &DataOnDemandSvc::update_2 , this ) ;
107  declareProperty ( "Nodes" , m_nodeMapping ) ->
108  declareUpdateHandler ( &DataOnDemandSvc::update_3 , this ) ;
109  //
110  declareProperty ( "AlgMap" , m_algMap ) ->
111  declareUpdateHandler ( &DataOnDemandSvc::update_1 , this ) ;
112  declareProperty ( "NodeMap" , m_nodeMap ) ->
113  declareUpdateHandler ( &DataOnDemandSvc::update_1 , this ) ;
114 
115  declareProperty ( "Prefix" , m_prefix ) ;
116 
117  declareProperty("NodeMappingTools", m_nodeMapTools,
118  "List of tools of type IDODNodeMapper");
119  declareProperty("AlgMappingTools", m_algMapTools,
120  "List of tools of type IDODAlgMapper");
121  // ==========================================================================
122 }
ChronoEntity m_timer_all
ChronoEntity m_timer_algs
MsgStream * m_log
SmartIF< IIncidentSvc > m_incSvc
Incident service.
std::vector< std::string > m_algMapTools
std::string m_trapType
Trap name.
std::string m_dataSvcName
Data service name.
Setup m_nodeMapping
Mapping to nodes.
Map m_algMap
the major configuration property { 'data' : 'algorithm' }
extends1 base_class
Typedef to this class.
Definition: extends.h:12
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
ulonglong m_statNode
Setup m_algMapping
Mapping to algorithms.
bool m_allowInitFailure
flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithm...
void update_dump(Property &)
update handler for 'Dump' property
std::vector< std::string > m_nodeMapTools
std::string m_prefix
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
bool m_partialPath
Flag to allow for the creation of partial leaves.
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
bool m_dump
flag to force the printout
bool m_init
flag to warm up the configuration
ChronoEntity m_timer_nodes
ChronoEntity m_total
Map m_nodeMap
the major configuration property { 'data' : 'type' }
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:211
void update_2(Property &p)
void update_3(Property &p)
void update_1(Property &p)
DataOnDemandSvc::~DataOnDemandSvc ( )
virtual

Standard destructor.

Definition at line 341 of file DataOnDemandSvc.cpp.

342 { if ( 0 != m_log ) { delete m_log ; m_log = 0 ; } }
MsgStream * m_log

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.

591 {
592  if ( 0 != l.algorithm ) { return StatusCode::SUCCESS ; }
593  if ( 0 == m_algMgr ) { return StatusCode::FAILURE ; }
594  l.algorithm = m_algMgr->algorithm(l.name, false);
595  if ( 0 != l.algorithm ) { return StatusCode::SUCCESS ; }
596  // create it!
597  StatusCode sc = m_algMgr->createAlgorithm ( l.type , l.name , l.algorithm , true ) ;
598  if ( sc.isFailure() )
599  {
600  stream()
601  << MSG::ERROR
602  << "Failed to create algorithm "
603  << l.type << "('" << l.name<< "')" << endmsg;
604  l.algorithm = 0 ;
605  return sc ; // RETURN
606  }
607  if ( l.algorithm->isInitialized() ) { return StatusCode:: SUCCESS ;}
608  // initialize it!
609  sc = l.algorithm -> sysInitialize () ;
610  if ( sc.isFailure() )
611  {
612  stream()
613  << MSG::ERROR
614  << "Failed to initialize algorithm "
615  << l.type << "('" << l.name<< "')" << endmsg;
616  l.algorithm = 0 ;
617  return sc ; // RETURN
618  }
619  if ( Gaudi::StateMachine::RUNNING == l.algorithm->FSMState() )
620  { return StatusCode::SUCCESS ; }
621  // run it!
622  sc = l.algorithm->sysStart() ;
623  if ( sc.isFailure() )
624  {
625  stream()
626  << MSG::ERROR
627  << "Failed to 'run' algorithm "
628  << l.type << "('" << l.name<< "')" << endmsg;
629  l.algorithm = 0 ;
630  return sc ; // RETURN
631  }
632  return StatusCode::SUCCESS ;
633 }
MsgStream & stream() const
get the message stream
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode sysInitialize()
Initialize Service.
Definition: Service.cpp:37
dictionary l
Definition: gaudirun.py:365
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::dump ( const MSG::Level  level,
const bool  mode = true 
) const
protected

dump the content of DataOnDemand service

Parameters
levelthe printout level
modethe printout mode

Definition at line 868 of file DataOnDemandSvc.cpp.

870 {
871  if ( m_algs.empty() && m_nodes.empty() ) { return ; }
872 
873  typedef std::pair<std::string,std::string> Pair ;
874  typedef std::map<std::string,Pair> PMap ;
875 
876  PMap _m ;
877  for ( AlgMap::const_iterator alg = m_algs.begin() ;
878  m_algs.end() != alg ; ++alg )
879  {
880  PMap::const_iterator check = _m.find(alg->first) ;
881  if ( _m.end() != check )
882  {
883  stream()
884  << MSG::WARNING
885  << " The data item is activated for '"
886  << check->first << "' as '" << check->second.first << "'" << endmsg ;
887  }
888  const Leaf& l = alg->second ;
889  std::string nam = ( l.name == l.type ? l.type : (l.type+"/"+l.name) ) ;
890  //
891  if ( !mode && 0 == l.num ) { continue ; }
892  //
893  std::string val ;
894  if ( mode ) { val = ( 0 == l.algorithm ) ? "F" : "T" ; }
895  else { val = boost::lexical_cast<std::string>( l.num ) ; }
896  //
897  _m[ no_prefix ( alg->first , m_prefix ) ] = std::make_pair ( nam , val ) ;
898  }
899  // nodes:
900  for ( NodeMap::const_iterator node = m_nodes.begin() ;
901  m_nodes.end() != node ; ++node )
902  {
903  PMap::const_iterator check = _m.find(node->first) ;
904  if ( _m.end() != check )
905  {
906  stream()
907  << MSG::WARNING
908  << " The data item is already activated for '"
909  << check->first << "' as '" << check->second.first << "'" << endmsg ;
910  }
911  const Node& n = node->second ;
912  std::string nam = "'" + n.name + "'" ;
913  //
914  std::string val ;
915 
916  if ( !mode && 0 == n.num ) { continue ; }
917 
918  if ( mode ) { val = ( 0 == n.clazz ) ? "F" : "T" ; }
919  else { val = boost::lexical_cast<std::string>( n.num ) ; }
920  //
921  _m[ no_prefix ( node->first , m_prefix ) ] = std::make_pair ( nam , val ) ;
922  }
923  //
924  if ( _m.empty() ) { return ; }
925 
926  // find the correct formats
927  size_t n1 = 0 ;
928  size_t n2 = 0 ;
929  size_t n3 = 0 ;
930  for ( PMap::const_iterator it = _m.begin() ; _m.end() != it ; ++it )
931  {
932  n1 = std::max ( n1 , it->first.size() ) ;
933  n2 = std::max ( n2 , it->second.first.size() ) ;
934  n3 = std::max ( n3 , it->second.second.size() ) ;
935  }
936  if ( 10 > n1 ) { n1 = 10 ; }
937  if ( 10 > n2 ) { n2 = 10 ; }
938  if ( 60 < n1 ) { n1 = 60 ; }
939  if ( 60 < n2 ) { n2 = 60 ; }
940  //
941 
942  const std::string _f = " | %%1$-%1%.%1%s | %%2$-%2%.%2%s | %%3$%3%.%3%s |" ;
943  boost::format _ff ( _f ) ;
944  _ff % n1 % n2 % n3 ;
945 
946  const std::string _format = _ff.str() ;
947 
948  MsgStream& msg = stream() << level ;
949 
950  if ( mode ) { msg << "Data-On-Demand Actions enabled for:" ; }
951  else { msg << "Data-On-Demand Actions has been used for:" ; }
952 
953  boost::format fmt1( _format) ;
954  fmt1 % "Address" % "Creator" % ( mode ? "S" : "#" ) ;
955  //
956  const std::string header = fmt1.str() ;
957  std::string line = std::string( header.size() , '-' ) ;
958  line[0] = ' ' ;
959 
960  msg << std::endl << line
961  << std::endl << header
962  << std::endl << line ;
963 
964  // make the actual printout:
965  for ( PMap::const_iterator item = _m.begin() ;
966  _m.end() != item ; ++item )
967  {
968  boost::format fmt( _format) ;
969  msg << std::endl <<
970  ( fmt % item->first % item->second.first % item->second.second ) ;
971  }
972 
973  msg << std::endl << line << endmsg ;
974 
975 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:133
MsgStream & stream() const
get the message stream
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
iterator end()
Definition: Map.h:131
bool empty() const
Definition: Map.h:182
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
std::string m_prefix
map_type::const_iterator const_iterator
Definition: Map.h:99
iterator begin()
Definition: Map.h:130
dictionary l
Definition: gaudirun.py:365
AlgMap m_algs
Map of algorithms to handle incidents.
tuple item
print s1,s2
Definition: ana.py:146
list header
Definition: Test.py:33
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
int line
Definition: ana.py:50
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.

828 {
830  //
831  if ( l.executing ) { return StatusCode::FAILURE ; } // RETURN
832  //
833  if ( 0 == l.algorithm )
834  {
836  if ( sc.isFailure() )
837  {
838  stream()
839  << MSG::ERROR
840  << "Failed to configure handler for: "
841  << l.name << "[" << l.type << "] " << tag << endmsg;
842  return sc ; // RETURN
843  }
844  }
845  //
846  Chrono atimer ( m_total ) ;
847  //
848  Protection p(l.executing);
849  StatusCode sc = l.algorithm->sysExecute();
850  if ( sc.isFailure() )
851  {
852  stream() << MSG::ERROR
853  << "Failed to execute the algorithm:"
854  << l.algorithm->name() << " for location:" << tag << endmsg;
855  return sc ; // RETURN
856  }
857  ++l.num ;
858  //
859  return StatusCode::SUCCESS ;
860 }
ChronoEntity m_timer_algs
MsgStream & stream() const
get the message stream
A small utility class for chronometry of user codes.
Definition: Chrono.h:27
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
dictionary l
Definition: gaudirun.py:365
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
Definition: LockedChrono.h:54
ChronoEntity m_total
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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.

772 {
773 
775 
776  if ( n.executing ) { return StatusCode::FAILURE ; } // RETURN
777 
778  Protection p(n.executing);
779 
780  DataObject* object= 0 ;
781 
782  if ( n.dataObject ) { object = new DataObject() ; }
783  else
784  {
785  // try to recover the handler
786  if ( !n.clazz ) { n.clazz = TClass::GetClass(n.name.c_str()) ; }
787  if ( !n.clazz )
788  {
789  stream()
790  << MSG::ERROR
791  << "Failed to get dictionary for class '"
792  << n.name
793  << "' for location:" << tag << endmsg;
794  return StatusCode::FAILURE ; // RETURN
795  }
796 
797  object = reinterpret_cast<DataObject*>(n.clazz->New());
798 
799  if ( !object )
800  {
801  stream()
802  << MSG::ERROR
803  << "Failed to create an object of type:"
804  << n.clazz->GetName() << " for location:" << tag
805  << endmsg;
806  return StatusCode::FAILURE ; // RETURN
807  }
808  }
809  //
810  StatusCode sc = m_dataSvc->registerObject(tag, object );
811  if ( sc.isFailure() )
812  {
813  stream()
814  << MSG::ERROR << "Failed to register an object of type:"
815  << n.name << " at location:" << tag
816  << endmsg;
817  return sc ; // RETURN
818  }
819  ++n.num ;
820  //
821  return StatusCode::SUCCESS ;
822 }
MsgStream & stream() const
get the message stream
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
Definition: LockedChrono.h:54
ChronoEntity m_timer_nodes
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode DataOnDemandSvc::finalize ( )
virtual

Inherited Service overrides: Service finalization.

Reimplemented from Service.

Definition at line 364 of file DataOnDemandSvc.cpp.

365 {
366  //
367  stream ()
368  << MSG::INFO
369  << "Handled \"" << m_trapType << "\" incidents: "
370  << m_statAlg << "/" << m_statNode << "/" << m_stat << "(Alg/Node/Total)."
371  << endmsg ;
372  if ( m_dump || MSG::DEBUG >= outputLevel() )
373  {
374  stream ()
375  << MSG::INFO
377  ( "Algorithm timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
378  << m_total.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
379  stream ()
380  << MSG::INFO
382  ( "Nodes timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
383  << m_timer_nodes.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
384  stream ()
385  << MSG::INFO
387  ( "Algs timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
388  << m_timer_algs .outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
389  stream ()
390  << MSG::INFO
392  ( "All timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
393  << m_timer_all .outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
394  }
395  // dump it!
396  if ( m_dump ) { dump ( MSG::INFO , false ) ; }
397  else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG , false ) ; }
398  //
399  if ( m_incSvc )
400  {
401  m_incSvc->removeListener(this, m_trapType);
402  m_incSvc.reset();
403  }
404  m_algMgr.reset();
405  m_dataSvc.reset();
406  if (m_toolSvc) { // we may not have retrieved the ToolSvc
407  // Do not call releaseTool if the ToolSvc was already finalized.
409  for(std::list<IDODNodeMapper*>::iterator i = m_nodeMappers.begin(); i != m_nodeMappers.end(); ++i)
410  m_toolSvc->releaseTool(*i).ignore();
411  for(std::list<IDODAlgMapper*>::iterator i = m_algMappers.begin(); i != m_algMappers.end(); ++i)
412  m_toolSvc->releaseTool(*i).ignore();
413  } else {
414  warning() << "ToolSvc already finalized: cannot release tools. Check options." << endmsg;
415  }
416  m_nodeMappers.clear();
417  m_algMappers.clear();
418  m_toolSvc.reset();
419  }
420  return Service::finalize();
421 }
ChronoEntity m_timer_all
ChronoEntity m_timer_algs
std::list< IDODNodeMapper * > m_nodeMappers
MsgStream & stream() const
get the message stream
SmartIF< IIncidentSvc > m_incSvc
Incident service.
int outputLevel() const
get the Service's output level
Definition: Service.h:250
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
std::string m_trapType
Trap name.
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
ulonglong m_statNode
std::list< IDODAlgMapper * > m_algMappers
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
virtual Gaudi::StateMachine::State FSMState() const
Get the current state.
Definition: Service.h:56
std::string outputUserTime() const
print the chrono ;
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
bool m_dump
flag to force the printout
ChronoEntity m_timer_nodes
ChronoEntity m_total
list i
Definition: ana.py:128
void reset(TYPE *ptr=0)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:74
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
Definition: Service.cpp:199
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::handle ( const Incident incident)
virtual

IIncidentListener interfaces overrides: incident handling.

Implements IIncidentListener.

Definition at line 698 of file DataOnDemandSvc.cpp.

699 {
700 
702 
703  ++m_stat ;
704  // proper incident type?
705  if ( incident.type() != m_trapType ) { return ; } // RETURN
706  const DataIncident* inc = dynamic_cast<const DataIncident*>(&incident);
707  if ( 0 == inc ) { return ; } // RETURN
708  // update if needed!
709  if ( m_updateRequired ) { update() ; }
710 
711  if ( MSG::VERBOSE >= outputLevel() )
712  {
713  verbose()
714  << "Incident: [" << incident.type () << "] "
715  << " = " << incident.source ()
716  << " Location:" << inc->tag() << endmsg;
717  }
718  // ==========================================================================
719  // const std::string& tag = inc->tag();
720  Gaudi::StringKey tag ( inc->tag() ) ;
721  // ==========================================================================
722  NodeMap::iterator icl = m_nodes.find ( tag ) ;
723  if ( icl != m_nodes.end() )
724  {
725  StatusCode sc = execHandler ( tag , icl->second ) ;
726  if ( sc.isSuccess() ) { ++m_statNode ; }
727  return ; // RETURN
728  }
729  // ==========================================================================
730  AlgMap::iterator ialg = m_algs.find ( tag ) ;
731  if ( ialg != m_algs.end() )
732  {
733  StatusCode sc = execHandler ( tag , ialg->second ) ;
734  if ( sc.isSuccess() ) { ++m_statAlg ; }
735  return ; // RETURN
736  }
737  // ==========================================================================
738  // Fall back on the tools
739  if (m_toolSvc) {
740  if (MSG::VERBOSE >= outputLevel())
741  verbose() << "Try to find mapping with mapping tools" << endmsg;
742  Finder finder(no_prefix(inc->tag(), m_prefix), m_nodeMappers, m_algMappers);
743  // - try the node mappers
744  std::string node = finder.node();
745  if (isGood(node)) {
746  // if one is found update the internal node mapping and try again.
747  if (MSG::VERBOSE >= outputLevel())
748  verbose() << "Found Node handler: " << node << endmsg;
749  i_setNodeHandler(inc->tag(), node);
750  handle(incident);
751  --m_stat; // avoid double counting because of recursion
752  return;
753  }
754  // - try alg mappings
755  Gaudi::Utils::TypeNameString alg = finder.alg();
756  if (isGood(alg)) {
757  // we got an algorithm, update alg map and try to handle again
758  if (MSG::VERBOSE >= outputLevel())
759  verbose() << "Found Algorithm handler: " << alg << endmsg;
760  i_setAlgHandler(inc->tag(), alg).ignore();
761  handle(incident);
762  --m_stat; // avoid double counting because of recursion
763  return;
764  }
765  }
766 }
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
ChronoEntity m_timer_all
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
const std::string & type() const
Access to the incident type.
Definition: Incident.h:34
std::list< IDODNodeMapper * > m_nodeMappers
const std::string & source() const
Access to the source of the incident.
Definition: Incident.h:40
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
int outputLevel() const
get the Service's output level
Definition: Service.h:250
std::string m_trapType
Trap name.
The helper class to represent the efficient "key" for access.
Definition: StringKey.h:35
ulonglong m_statNode
std::list< IDODAlgMapper * > m_algMappers
iterator end()
Definition: Map.h:131
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
virtual void handle(const Incident &incident)
IIncidentListener interfaces overrides: incident handling.
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:30
iterator find(const key_type &key)
Definition: Map.h:148
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
std::string m_prefix
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
Definition: LockedChrono.h:54
AlgMap m_algs
Map of algorithms to handle incidents.
Data service incident class.
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode update()
update the handlers
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.

257  {
258  Leaf leaf(alg.type(), alg.name());
259  if (m_init)
260  {
262  if (sc.isFailure()) {
263  if (m_allowInitFailure) {
264  // re-store the content of the leaf object to try again to initialize
265  // the algorithm later (on demand)
266  leaf = Leaf(alg.type(), alg.name());
267  }
268  else
269  return sc;
270  }
271  }
272  m_algs[name] = leaf;
273  return StatusCode::SUCCESS;
274 }
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
bool m_allowInitFailure
flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithm...
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
AlgMap m_algs
Map of algorithms to handle incidents.
bool m_init
flag to warm up the configuration
const std::string & type() const
const std::string & name() const
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
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.

247  {
248  ClassH cl = TClass::GetClass(type.c_str()) ;
249  if (!cl) {
250  warning()
251  << "Failed to access dictionary class for "
252  << name << " of type:" << type << endmsg;
253  }
254  m_nodes[name] = Node(cl, false, type);
255 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
string type
Definition: gaudirun.py:126
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode DataOnDemandSvc::initialize ( )
virtual

Inherited Service overrides: Service initialization.

Reimplemented from Service.

Definition at line 346 of file DataOnDemandSvc.cpp.

347 {
348  // initialize the Service Base class
350  if ( sc.isFailure() ) { return sc; }
351  sc = setup();
352  if ( sc.isFailure() ) { return sc; }
353  //
354  if ( m_dump ) { dump ( MSG::INFO ) ; }
355  else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG ) ; }
356  //
357  if ( m_init ) { return update () ; }
358  //
359  return StatusCode::SUCCESS ;
360 }
int outputLevel() const
get the Service's output level
Definition: Service.h:250
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
StatusCode setup()
Setup routine (called by (re-) initialize.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: Service.cpp:74
bool m_dump
flag to force the printout
bool m_init
flag to warm up the configuration
StatusCode update()
update the handlers
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.

426 {
427  // reinitialize the Service Base class
428  if ( 0 != m_incSvc )
429  {
430  m_incSvc -> removeListener ( this , m_trapType );
431  m_incSvc.reset();
432  }
433  m_algMgr.reset();
434  m_dataSvc.reset();
435  for(std::list<IDODNodeMapper*>::iterator i = m_nodeMappers.begin(); i != m_nodeMappers.end(); ++i)
436  m_toolSvc->releaseTool(*i).ignore();
437  m_nodeMappers.clear();
438  for(std::list<IDODAlgMapper*>::iterator i = m_algMappers.begin(); i != m_algMappers.end(); ++i)
439  m_toolSvc->releaseTool(*i).ignore();
440  m_algMappers.clear();
441  m_toolSvc.reset();
442  if ( 0 != m_log ) { delete m_log ; m_log = 0 ; }
443  //
445  if ( sc.isFailure() ) { return sc; }
446  //
447  sc = setup() ;
448  if ( sc.isFailure() ) { return sc; }
449  //
450  if ( m_dump ) { dump ( MSG::INFO ) ; }
451  else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG ) ; }
452  //
453  return StatusCode::SUCCESS ;
454 }
std::list< IDODNodeMapper * > m_nodeMappers
MsgStream * m_log
SmartIF< IIncidentSvc > m_incSvc
Incident service.
int outputLevel() const
get the Service's output level
Definition: Service.h:250
std::string m_trapType
Trap name.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
std::list< IDODAlgMapper * > m_algMappers
StatusCode setup()
Setup routine (called by (re-) initialize.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
virtual StatusCode reinitialize()
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
Definition: Service.cpp:294
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
bool m_dump
flag to force the printout
list i
Definition: ana.py:128
void reset(TYPE *ptr=0)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:74
StatusCode DataOnDemandSvc::setup ( )
protected

Setup routine (called by (re-) initialize.

Definition at line 458 of file DataOnDemandSvc.cpp.

459 {
460  if ( !(m_algMgr = serviceLocator()) ) // assignment meant
461  {
462  error() << "Failed to retrieve the IAlgManager interface." << endmsg;
463  return StatusCode::FAILURE;
464  }
465 
466  if ( !(m_incSvc = serviceLocator()->service("IncidentSvc")) ) // assignment meant
467  {
468  error() << "Failed to retrieve Incident service." << endmsg;
469  return StatusCode::FAILURE;
470  }
471  m_incSvc->addListener(this, m_trapType);
472 
473  if ( !(m_dataSvc = serviceLocator()->service(m_dataSvcName)) ) // assignment meant
474  {
475  error()
476  << "Failed to retrieve the data provider interface of "
477  << m_dataSvcName << endmsg;
478  return StatusCode::FAILURE;
479  }
480 
481  // No need to get the ToolSvc if we are not using tools
482  if (!(m_nodeMapTools.empty() && m_algMapTools.empty())) {
483  if ( !(m_toolSvc = serviceLocator()->service("ToolSvc")) ) // assignment meant
484  {
485  error() << "Failed to retrieve ToolSvc" << endmsg;
486  return StatusCode::FAILURE;
487  }
488 
489  // load the node mapping tools
490  std::vector<std::string>::iterator i;
491  IDODNodeMapper *nodetool = 0;
492  for(i = m_nodeMapTools.begin(); i != m_nodeMapTools.end(); ++i) {
493  const StatusCode sc = m_toolSvc->retrieveTool(*i, nodetool);
494  if (sc.isFailure()) return sc;
495  m_nodeMappers.push_back(nodetool);
496  }
497  IDODAlgMapper *algtool = 0;
498  for(i = m_algMapTools.begin(); i != m_algMapTools.end(); ++i) {
499  const StatusCode sc = m_toolSvc->retrieveTool(*i, algtool);
500  if (sc.isFailure()) return sc;
501  m_algMappers.push_back(algtool);
502  }
503  }
504  return update();
505 }
std::list< IDODNodeMapper * > m_nodeMappers
SmartIF< IIncidentSvc > m_incSvc
Incident service.
std::vector< std::string > m_algMapTools
std::string m_trapType
Trap name.
std::string m_dataSvcName
Data service name.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
std::list< IDODAlgMapper * > m_algMappers
Interface of tools used by the DataOnDemandSvc to choose the type of node to be created at a path...
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
std::vector< std::string > m_nodeMapTools
Interface of tools used by the DataOnDemandSvc to choose the algorithm to be run to produce the data ...
Definition: IDODAlgMapper.h:17
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
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.
Definition: Service.h:142
list i
Definition: ana.py:128
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode update()
update the handlers
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Service.cpp:336
StatusCode DataOnDemandSvc::setupAlgHandlers ( )
protected

Initialize leaf handlers.

Definition at line 551 of file DataOnDemandSvc.cpp.

552 {
553  Setup::const_iterator j;
554  std::string typ, tag;
555 
556  for(j=m_algMapping.begin(); j != m_algMapping.end(); ++j)
557  {
558  Tokenizer tok(true);
559  tok.analyse(*j, " ", "", "", "=", "'", "'");
560  for(Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); i++ ) {
561  const std::string& t = (*i).tag();
562  const std::string& v = (*i).value();
563  switch( ::toupper(t[0]) ) {
564  case 'D':
565  tag = v;
566  break;
567  case 'T':
568  typ = v;
569  break;
570  }
571  }
573  if ( m_algMap .end () != m_algMap .find ( tag ) ||
574  m_nodeMap .end () != m_nodeMap .find ( tag ) )
575  {
576  stream()
577  << MSG::WARNING
578  << "The obsolete property 'Algorithms' redefines the action for '"
579  + tag + "' to be '" +item.type() +"/"+item.name()+"'"
580  << endmsg ;
581  }
582  m_algMap[tag] = item.type() + "/" + item.name() ;
583  }
584  m_updateRequired = true ;
585  return StatusCode::SUCCESS;
586 }
MsgStream & stream() const
get the message stream
Map m_algMap
the major configuration property { 'data' : 'algorithm' }
Setup m_algMapping
Mapping to algorithms.
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
STL Include files.
Definition: Tokenizer.h:24
tuple end
Definition: IOTest.py:101
tuple item
print s1,s2
Definition: ana.py:146
Map m_nodeMap
the major configuration property { 'data' : 'type' }
list i
Definition: ana.py:128
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode DataOnDemandSvc::setupNodeHandlers ( )
protected

Initialize node handlers.

Definition at line 509 of file DataOnDemandSvc.cpp.

510 {
511  Setup::const_iterator j;
512  std::string nam, typ, tag;
514  // Setup for node leafs, where simply a constructor is called...
515  for ( j=m_nodeMapping.begin(); j != m_nodeMapping.end(); ++j)
516  {
517  Tokenizer tok(true);
518  tok.analyse(*j, " ", "", "", "=", "'", "'");
519  for ( Tokenizer::Items::iterator i = tok.items().begin();
520  i != tok.items().end(); i++ ) {
521  const std::string& t = (*i).tag();
522  const std::string& v = (*i).value();
523  switch( ::toupper(t[0]) ) {
524  case 'D':
525  tag = v;
526  break;
527  case 'T':
528  nam = v;
529  break;
530  }
531  }
532  if ( m_algMap .end () != m_algMap .find ( tag ) ||
533  m_nodeMap .end () != m_nodeMap .find ( tag ) )
534  {
535  stream()
536  << MSG::WARNING
537  << "The obsolete property 'Nodes' redefines the action for '"
538  + tag + "' to be '" +nam+"'"
539  << endmsg ;
540  }
541  m_nodeMap[tag] = nam ;
542  }
543  //
544  m_updateRequired = true ;
545  //
546  return sc;
547 }
MsgStream & stream() const
get the message stream
Setup m_nodeMapping
Mapping to nodes.
Map m_algMap
the major configuration property { 'data' : 'algorithm' }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
STL Include files.
Definition: Tokenizer.h:24
tuple end
Definition: IOTest.py:101
Map m_nodeMap
the major configuration property { 'data' : 'type' }
list i
Definition: ana.py:128
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream& DataOnDemandSvc::stream ( ) const
inlineprotected

get the message stream

Definition at line 240 of file DataOnDemandSvc.h.

241  {
242  if ( 0 == m_log ) { m_log = new MsgStream( msgSvc() , name() ) ; }
243  return *m_log;
244  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream * m_log
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
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.

280 {
281  if ( !m_updateRequired ) { return StatusCode::SUCCESS ; }
282 
284  StatusCode sc = setupNodeHandlers() ; // convert "Nodes" new "NodeMap"
285  if ( sc.isFailure() )
286  {
287  stream() << MSG::ERROR << "Failed to setup old \"Nodes\"" << endmsg ;
288  return sc ;
289  }
291  sc = setupAlgHandlers() ; // convert "Algorithms" into "AlgMap"
292  if ( sc.isFailure() )
293  {
294  stream() << MSG::ERROR << "Failed to setup old \"Algorithms\"" << endmsg ;
295  return sc ;
296  }
298  add_prefix ( m_algMap , m_prefix ) ;
300  add_prefix ( m_nodeMap , m_prefix ) ;
302  typedef std::set<std::string> Set ;
303  Set dirs ;
304  if ( m_partialPath ){ get_dirs ( m_algMap , dirs ) ; }
305  if ( m_partialPath ){ get_dirs ( m_nodeMap , dirs ) ; }
306  //
307  Set::iterator _e = dirs.find("/Event") ;
308  if ( dirs.end() != _e ) { dirs.erase( _e ) ; }
309  // add all directories as nodes
310  for ( Set::const_iterator dir = dirs.begin() ; dirs.end() != dir ; ++dir )
311  {
312  if ( m_algMap .end () != m_algMap .find ( *dir ) ) { continue ; }
313  if ( m_nodeMap .end () != m_nodeMap .find ( *dir ) ) { continue ; }
314  m_nodeMap [*dir] = "DataObject" ;
315  }
316  //
317  m_algs .clear () ;
318  m_nodes .clear () ;
319  //
321  for ( Map::const_iterator ialg = m_algMap.begin() ;
322  m_algMap.end() != ialg ; ++ialg )
323  {
324  if (i_setAlgHandler(ialg->first, ialg->second).isFailure())
325  return StatusCode::FAILURE;
326  }
328  for ( Map::const_iterator inode = m_nodeMap.begin() ;
329  m_nodeMap.end() != inode ; ++inode )
330  {
331  i_setNodeHandler(inode->first, inode->second);
332  }
334  m_updateRequired = false ;
335  //
336  return StatusCode::SUCCESS ;
337 }
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
MsgStream & stream() const
get the message stream
Map m_algMap
the major configuration property { 'data' : 'algorithm' }
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
StatusCode setupNodeHandlers()
Initialize node handlers.
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
std::string m_prefix
tuple end
Definition: IOTest.py:101
bool m_partialPath
Flag to allow for the creation of partial leaves.
AlgMap m_algs
Map of algorithms to handle incidents.
void clear()
Definition: Map.h:176
Map m_nodeMap
the major configuration property { 'data' : 'type' }
StatusCode setupAlgHandlers()
Initialize leaf handlers.
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::update_1 ( Property p)

Definition at line 126 of file DataOnDemandSvc.cpp.

127 {
128  stream() << MSG::VERBOSE << " I am update handler for property " << p << endmsg ;
129  // force update
130  m_updateRequired = true ;
131 }
MsgStream & stream() const
get the message stream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::update_2 ( Property p)

Definition at line 147 of file DataOnDemandSvc.cpp.

148 {
149  stream() << MSG::WARNING
150  << "The property 'Algorithms' is obsolete, switch to map-like 'AlgMap' "
151  << " = { 'data' : 'algorithm' } "
152  << endmsg ;
153  // force update
154  m_updateRequired = true ;
155 }
MsgStream & stream() const
get the message stream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::update_3 ( Property p)

Definition at line 135 of file DataOnDemandSvc.cpp.

136 {
137  stream() << MSG::WARNING
138  << "The property 'Nodes' is obsolete, switch to map-like 'NodeMap' "
139  << " = { 'data' : 'type' } "
140  << endmsg ;
141  // force update
142  m_updateRequired = true ;
143 }
MsgStream & stream() const
get the message stream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::update_dump ( Property )

update handler for 'Dump' property

Definition at line 159 of file DataOnDemandSvc.cpp.

160 {
161  // no action if not yet initialized
162  if ( FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
163  // dump the configuration:
164  if ( m_dump ) { dump ( MSG::ALWAYS ) ; }
165 }
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
virtual Gaudi::StateMachine::State FSMState() const
Get the current state.
Definition: Service.h:56
bool m_dump
flag to force the printout

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
mutableprivate

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: