| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# 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]

List of all members.

## Public Types
typedef std::vector< std::string > | Setup
typedef ROOT::Reflex::Type | ClassH
typedef GaudiUtils::HashMap < Gaudi::StringKey, Node > | NodeMap
typedef GaudiUtils::HashMap < Gaudi::StringKey, Leaf > | AlgMap
## 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
## 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.
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
IIncidentSvc * | m_incSvc
| Incident service.
IAlgManager * | m_algMgr
| Algorithm manager.
IDataProviderSvc * | m_dataSvc
| 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
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
## Classes
struct | Leaf
struct | Node
| Helper class of the DataOnDemandSvc. More...
struct | Protection
| Helper class of the DataOnDemandSvc. 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 mathes. In the event already the partial path to any handler is missing a leaf handler may be triggered, which includes the partal pathes ( 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 preceeding 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/" ) coudl 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 std::vector<std::string> DataOnDemandSvc::Setup

Definition at line 95 of file DataOnDemandSvc.h.

typedef ROOT::Reflex::Type DataOnDemandSvc::ClassH

Definition at line 96 of file DataOnDemandSvc.h.

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

Definition at line 171 of file DataOnDemandSvc.h.

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

Definition at line 172 of file DataOnDemandSvc.h.

typedef std::map<std::string,std::string> DataOnDemandSvc::Map`[private]`

Definition at line 274 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 42 of file DataOnDemandSvc.cpp.

    00043   : base_class(name, svc)
    00044   , m_incSvc   ( 0 )
    00045   , m_algMgr   ( 0 )
    00046   , m_dataSvc  ( 0 )
    00047   //
    00048   , m_trapType    ( "DataFault")
    00049   , m_dataSvcName ( "EventDataSvc" )
    00050   , m_partialPath ( true  )
    00051   , m_dump        ( false )
    00052   , m_init        ( false )
    00053   //
    00054   , m_algMapping  ()
    00055   , m_nodeMapping ()
    00056   //
    00057   , m_algMap   (   )
    00058   , m_nodeMap  (   )
    00059   //
    00060   , m_updateRequired ( true )
    00061   , m_prefix         ( "/Event/" )
    00062   , m_log      ( 0 )
    00063   , m_total    (   )
    00064   , m_statAlg  ( 0 )
    00065   , m_statNode ( 0 )
    00066   , m_stat     ( 0 )
    00067   //
    00068   , m_timer_nodes  ()
    00069   , m_timer_algs   ()
    00070   , m_timer_all    ()
    00071   , m_locked_nodes ( false )
    00072   , m_locked_algs  ( false )
    00073   , m_locked_all   ( false )
    00074   //
    00075 {
    00076   // ==========================================================================
    00077   declareProperty
    00078     ( "IncidentName"       ,
    00079       m_trapType           ,
    00080       "The type of handled Incident" ) ;
    00081   //
    00082   declareProperty ( "DataSvc"            , m_dataSvcName ) ;
    00083   //
    00084   declareProperty ( "UsePreceedingPath"  , m_partialPath ) ;
    00085   declareProperty
    00086     ( "Dump"        ,
    00087       m_dump        ,
    00088       "Dump the configuration and stastics" )  ->
    00089     declareUpdateHandler ( &DataOnDemandSvc::update_dump , this ) ;
    00090   //
    00091   declareProperty
    00092     ( "PreInitialize" ,
    00093       m_init          ,
    00094       "Flag to (pre)initialize all algorithms" ) ;
    00095   //
    00096   declareProperty ( "Algorithms"         , m_algMapping  )  ->
    00097     declareUpdateHandler ( &DataOnDemandSvc::update_2 , this ) ;
    00098   declareProperty ( "Nodes"              , m_nodeMapping ) ->
    00099     declareUpdateHandler ( &DataOnDemandSvc::update_3 , this ) ;
    00100   //
    00101   declareProperty ( "AlgMap"  , m_algMap  ) ->
    00102     declareUpdateHandler ( &DataOnDemandSvc::update_1 , this ) ;
    00103   declareProperty ( "NodeMap" , m_nodeMap ) ->
    00104     declareUpdateHandler ( &DataOnDemandSvc::update_1 , this ) ;
    00105   //
    00106   declareProperty ( "Prefix"             , m_prefix      ) ;
    00107   // ==========================================================================
    00108 }

DataOnDemandSvc::~DataOnDemandSvc | ( |  | ) | `[virtual]`

Standard destructor.

Definition at line 311 of file DataOnDemandSvc.cpp.

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

## Member Function Documentation

StatusCode DataOnDemandSvc::initialize | ( |  | ) | `[virtual]`

Inherited Service overrides: Service initialization.

Reimplemented from Service.

Definition at line 316 of file DataOnDemandSvc.cpp.

    00317 {
    00318   // initialize the Service Base class
    00319   StatusCode sc = Service::initialize();
    00320   if ( sc.isFailure() )  { return sc; }
    00321   sc = setup();
    00322   if ( sc.isFailure() )  { return sc; }
    00323   //
    00324   if      ( m_dump )                      { dump ( MSG::INFO  ) ; }
    00325   else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG ) ; }
    00326   //
    00327   if ( m_init ) { return update () ; }
    00328   //
    00329   return StatusCode::SUCCESS ;
    00330 }

StatusCode DataOnDemandSvc::finalize | ( | void |  | ) | `[virtual]`

Inherited Service overrides: Service finalization.

Reimplemented from Service.

Definition at line 334 of file DataOnDemandSvc.cpp.

    00335 {
    00336   //
    00337   stream ()
    00338     << MSG::INFO
    00339     << "Handled \"" << m_trapType << "\" incidents: "
    00340     << m_statAlg  << "/" << m_statNode << "/" << m_stat << "(Alg/Node/Total)."
    00341     << endmsg ;
    00342   if ( m_dump || MSG::DEBUG >= outputLevel() )
    00343   {
    00344     stream ()
    00345       << MSG::INFO
    00346       << m_total.outputUserTime
    00347       ( "Algorithm timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
    00348       << m_total.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
    00349     stream ()
    00350       << MSG::INFO
    00351       << m_timer_nodes.outputUserTime
    00352       ( "Nodes     timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
    00353       << m_timer_nodes.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
    00354     stream ()
    00355       << MSG::INFO
    00356       << m_timer_algs .outputUserTime
    00357       ( "Algs      timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
    00358       << m_timer_algs .outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
    00359     stream ()
    00360       << MSG::INFO
    00361       << m_timer_all  .outputUserTime
    00362       ( "All       timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
    00363       << m_timer_all  .outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
    00364   }
    00365   // dump it!
    00366   if      ( m_dump )                      { dump ( MSG::INFO  , false ) ; }
    00367   else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG , false ) ; }
    00368   //
    00369   if ( m_incSvc )
    00370   {
    00371     m_incSvc->removeListener(this, m_trapType);
    00372     m_incSvc->release();
    00373     m_incSvc = 0;
    00374   }
    00375   if ( 0 != m_algMgr  ) { m_algMgr   -> release () ; m_algMgr  = 0 ; }
    00376   if ( 0 != m_dataSvc ) { m_dataSvc  -> release () ; m_dataSvc = 0 ; }
    00377   //
    00378   return Service::finalize();
    00379 }

StatusCode DataOnDemandSvc::reinitialize | ( |  | ) | `[virtual]`

Inherited Service overrides: Service reinitialization.

re-initialization of the service

Reimplemented from Service.

Definition at line 383 of file DataOnDemandSvc.cpp.

    00384 {
    00385   // reinitialize the Service Base class
    00386   if ( 0 != m_incSvc )
    00387   {
    00388     m_incSvc -> removeListener ( this , m_trapType );
    00389     m_incSvc -> release ();
    00390     m_incSvc = 0;
    00391   }
    00392   if ( 0 != m_algMgr  ) { m_algMgr   -> release() ; m_algMgr  = 0 ; }
    00393   if ( 0 != m_dataSvc ) { m_dataSvc  -> release() ; m_dataSvc = 0 ; }
    00394   if ( 0 != m_log     ) { delete m_log ; m_log = 0 ; }
    00395   //
    00396   StatusCode sc = Service::reinitialize();
    00397   if ( sc.isFailure() )  { return sc; }
    00398   //
    00399   sc = setup() ;
    00400   if ( sc.isFailure() )  { return sc; }
    00401   //
    00402   if ( m_dump ) { dump ( MSG::INFO ) ; }
    00403   else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG  ) ; }
    00404   //
    00405   return StatusCode::SUCCESS ;
    00406 }

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

IIncidentListener interfaces overrides: incident handling.

Implements IIncidentListener.

Definition at line 572 of file DataOnDemandSvc.cpp.

    00573 {
    00574
    00575   Gaudi::Utils::LockedChrono timer ( m_timer_all , m_locked_all ) ;
    00576
    00577   ++m_stat ;
    00578   // proper incident type?
    00579   if ( incident.type() != m_trapType ) { return ; }             // RETURN
    00580   const DataIncident* inc = dynamic_cast<const DataIncident*>(&incident);
    00581   if ( 0 == inc                      ) { return ; }             // RETURN
    00582   // update if needed!
    00583   if ( m_updateRequired ) { update() ; }
    00584
    00585   if ( MSG::VERBOSE >= outputLevel() )
    00586   {
    00587     stream()
    00588       << MSG::VERBOSE
    00589       << "Incident: [" << incident.type   () << "] "
    00590       << " = "         << incident.source ()
    00591       << " Location:"  << inc->tag()         << endmsg;
    00592   }
    00593   // ==========================================================================
    00594   // const std::string& tag = inc->tag();
    00595   Gaudi::StringKey tag ( inc->tag() ) ;
    00596   // ==========================================================================
    00597   NodeMap::iterator icl = m_nodes.find ( tag ) ;
    00598   if ( icl != m_nodes.end() )
    00599   {
    00600     StatusCode sc = execHandler ( tag , icl->second ) ;
    00601     if ( sc.isSuccess() ) { ++m_statNode ; }
    00602     return ;                                                        // RETURN
    00603   }
    00604   // ==========================================================================
    00605   AlgMap::iterator ialg = m_algs.find ( tag ) ;
    00606   if ( ialg != m_algs.end() )
    00607   {
    00608     StatusCode sc = execHandler ( tag , ialg->second ) ;
    00609     if ( sc.isSuccess() ) { ++m_statAlg ; }
    00610     return ;                                                        // RETURN
    00611   }
    00612 }

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 525 of file DataOnDemandSvc.cpp.

    00526 {
    00527   if ( 0 != l.algorithm ) { return StatusCode::SUCCESS ; }
    00528   if ( 0 == m_algMgr  ) { return StatusCode::FAILURE ; }
    00529   l.algorithm = m_algMgr->algorithm(l.name, false);
    00530   if ( 0 != l.algorithm ) { return StatusCode::SUCCESS ; }
    00531   // create it!
    00532   StatusCode sc = m_algMgr->createAlgorithm ( l.type , l.name , l.algorithm , true ) ;
    00533   if ( sc.isFailure() )
    00534   {
    00535     stream()
    00536       << MSG::ERROR
    00537       << "Failed to create algorithm "
    00538       << l.type << "('" << l.name<< "')" << endmsg;
    00539     l.algorithm = 0 ;
    00540     return sc ;                                                    // RETURN
    00541   }
    00542   if ( l.algorithm->isInitialized() ) { return StatusCode:: SUCCESS ;}
    00543   // initialize it!
    00544   sc = l.algorithm -> sysInitialize () ;
    00545   if ( sc.isFailure() )
    00546   {
    00547     stream()
    00548       << MSG::ERROR
    00549       << "Failed to initialize algorithm "
    00550       << l.type << "('" << l.name<< "')" << endmsg;
    00551     l.algorithm = 0 ;
    00552     return sc ;                                                    // RETURN
    00553   }
    00554   if ( Gaudi::StateMachine::RUNNING == l.algorithm->FSMState() )
    00555   { return StatusCode::SUCCESS ; }
    00556   // run it!
    00557   sc = l.algorithm->sysStart() ;
    00558   if ( sc.isFailure() )
    00559   {
    00560     stream()
    00561       << MSG::ERROR
    00562       << "Failed to 'run'      algorithm "
    00563       << l.type << "('" << l.name<< "')" << endmsg;
    00564     l.algorithm = 0 ;
    00565     return sc ;                                                    // RETURN
    00566   }
    00567   return StatusCode::SUCCESS  ;
    00568 }

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 675 of file DataOnDemandSvc.cpp.

    00676 {
    00677   Gaudi::Utils::LockedChrono timer ( m_timer_algs ,  m_locked_algs ) ;
    00678   //
    00679   if ( l.executing ) { return StatusCode::FAILURE ; }             // RETURN
    00680   //
    00681   if ( 0 == l.algorithm )
    00682   {
    00683     StatusCode sc = configureHandler ( l ) ;
    00684     if ( sc.isFailure() )
    00685     {
    00686       stream()
    00687         << MSG::ERROR
    00688         << "Failed to configure handler for: "
    00689         << l.name << "[" << l.type << "] " << tag << endmsg;
    00690       return sc ;                                                 // RETURN
    00691     }
    00692   }
    00693   //
    00694   Chrono atimer ( m_total ) ;
    00695   //
    00696   Protection p(l.executing);
    00697   StatusCode sc = l.algorithm->sysExecute();
    00698   if ( sc.isFailure() )
    00699   {
    00700     stream() << MSG::ERROR
    00701              << "Failed to execute the algorithm:"
    00702              << l.algorithm->name() << " for location:" << tag << endmsg;
    00703     return sc ;                                                       // RETURN
    00704   }
    00705   ++l.num ;
    00706   //
    00707   return StatusCode::SUCCESS ;
    00708 }

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 617 of file DataOnDemandSvc.cpp.

    00618 {
    00619
    00620   Gaudi::Utils::LockedChrono timer ( m_timer_nodes ,  m_locked_nodes ) ;
    00621
    00622   if ( n.executing ) { return StatusCode::FAILURE ; }            // RETURN
    00623
    00624   Protection p(n.executing);
    00625
    00626   DataObject* object= 0 ;
    00627
    00628   if ( n.dataObject )  { object = new DataObject() ; }
    00629   else
    00630   {
    00631     // try to recover the handler
    00632     if ( !n.clazz  ) { n.clazz = ROOT::Reflex::Type::ByName(n.name) ; }
    00633     if ( !n.clazz  )
    00634     {
    00635       stream()
    00636         << MSG::ERROR
    00637         << "Failed to get dictionary for class '"
    00638         << n.name
    00639         << "' for location:" << tag << endmsg;
    00640       return StatusCode::FAILURE ;                               // RETURN
    00641     }
    00642     //
    00643     ROOT::Reflex::Object obj = n.clazz.Construct();
    00644
    00645     object = (DataObject*) obj.Address();
    00646
    00647     if ( !object )
    00648     {
    00649       stream()
    00650         << MSG::ERROR
    00651         << "Failed to create an object of type:"
    00652         << n.clazz.Name(ROOT::Reflex::SCOPED) << " for location:" << tag
    00653         << endmsg;
    00654       return StatusCode::FAILURE  ;                               // RETURN
    00655     }
    00656   }
    00657   //
    00658   StatusCode sc = m_dataSvc->registerObject(tag, object );
    00659   if ( sc.isFailure() )
    00660   {
    00661     stream()
    00662       << MSG::ERROR << "Failed to register an object of type:"
    00663       << n.name << " at location:" << tag
    00664       << endmsg;
    00665     return sc ;                                                  // RETURN
    00666   }
    00667   ++n.num ;
    00668   //
    00669   return StatusCode::SUCCESS ;
    00670 }

StatusCode DataOnDemandSvc::setupNodeHandlers | ( |  | ) | `[protected]`

Initialize node handlers.

Definition at line 444 of file DataOnDemandSvc.cpp.

    00445 {
    00446   Setup::const_iterator j;
    00447   std::string nam, typ, tag;
    00448   StatusCode sc = StatusCode::SUCCESS;
    00449   // Setup for node leafs, where simply a constructor is called...
    00450   for ( j=m_nodeMapping.begin(); j != m_nodeMapping.end(); ++j)
    00451   {
    00452     Tokenizer tok(true);
    00453     tok.analyse(*j, " ", "", "", "=", "'", "'");
    00454     for ( Tokenizer::Items::iterator i = tok.items().begin();
    00455           i != tok.items().end(); i++ )   {
    00456       const std::string& t = (*i).tag();
    00457       const std::string& v = (*i).value();
    00458       switch( ::toupper(t[0]) )    {
    00459       case 'D':
    00460         tag = v;
    00461         break;
    00462       case 'T':
    00463         nam = v;
    00464         break;
    00465       }
    00466     }
    00467     if ( m_algMap  .end () != m_algMap  .find ( tag ) ||
    00468          m_nodeMap .end () != m_nodeMap .find ( tag ) )
    00469     {
    00470       stream()
    00471         << MSG::WARNING
    00472         << "The obsolete property 'Nodes' redefines the action for '"
    00473         + tag + "' to be '" +nam+"'"
    00474         << endmsg ;
    00475     }
    00476     m_nodeMap[tag] = nam ;
    00477   }
    00478   //
    00479   m_updateRequired = true ;
    00480   //
    00481   return sc;
    00482 }

StatusCode DataOnDemandSvc::setupAlgHandlers | ( |  | ) | `[protected]`

Initialize leaf handlers.

Definition at line 486 of file DataOnDemandSvc.cpp.

    00487 {
    00488   Setup::const_iterator j;
    00489   std::string typ, tag;
    00490
    00491   for(j=m_algMapping.begin(); j != m_algMapping.end(); ++j)
    00492   {
    00493     Tokenizer tok(true);
    00494     tok.analyse(*j, " ", "", "", "=", "'", "'");
    00495     for(Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); i++ )   {
    00496       const std::string& t = (*i).tag();
    00497       const std::string& v = (*i).value();
    00498       switch( ::toupper(t[0]) )    {
    00499       case 'D':
    00500         tag = v;
    00501         break;
    00502       case 'T':
    00503         typ = v;
    00504         break;
    00505       }
    00506     }
    00507     Gaudi::Utils::TypeNameString item(typ);
    00508     if ( m_algMap  .end () != m_algMap  .find ( tag ) ||
    00509          m_nodeMap .end () != m_nodeMap .find ( tag ) )
    00510     {
    00511       stream()
    00512         << MSG::WARNING
    00513         << "The obsolete property 'Algorithms' redefines the action for '"
    00514         + tag + "' to be '" +item.type() +"/"+item.name()+"'"
    00515         << endmsg ;
    00516     }
    00517     m_algMap[tag] = item.type() + "/" + item.name() ;
    00518   }
    00519   m_updateRequired = true ;
    00520   return StatusCode::SUCCESS;
    00521 }

StatusCode DataOnDemandSvc::setup | ( |  | ) | `[protected]`

Setup routine (called by (re-) initialize.

Definition at line 410 of file DataOnDemandSvc.cpp.

    00411 {
    00412   m_algMgr = 0;
    00413   StatusCode sc =
    00414     serviceLocator()->queryInterface(IAlgManager::interfaceID(), pp_cast<void>(&m_algMgr));
    00415   if ( sc.isFailure () )
    00416   {
    00417     stream()
    00418       << MSG::ERROR
    00419       << "Failed to retrieve the IAlgManager interface." << endmsg;
    00420     return sc;
    00421   }
    00422   sc = service("IncidentSvc", m_incSvc, true);
    00423   if ( sc.isFailure () )
    00424   {
    00425     stream()
    00426       << MSG::ERROR << "Failed to retrieve Incident service." << endmsg;
    00427     return sc;
    00428   }
    00429   m_incSvc->addListener(this, m_trapType);
    00430   sc = service(m_dataSvcName, m_dataSvc, true);
    00431   if ( sc.isFailure () )
    00432   {
    00433     stream()
    00434       << MSG::ERROR
    00435       << "Failed to retrieve the data provider interface of "
    00436       << m_dataSvcName << endmsg;
    00437     return sc;
    00438   }
    00439   return update() ;
    00440 }

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

Definition at line 112 of file DataOnDemandSvc.cpp.

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

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

Definition at line 133 of file DataOnDemandSvc.cpp.

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

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

Definition at line 121 of file DataOnDemandSvc.cpp.

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

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

update handler for 'Dump' property

Definition at line 145 of file DataOnDemandSvc.cpp.

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

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 235 of file DataOnDemandSvc.cpp.

    00236 {
    00237   if ( !m_updateRequired ) { return StatusCode::SUCCESS  ; }
    00238
    00240   StatusCode sc = setupNodeHandlers() ; // convert "Nodes"      new "NodeMap"
    00241   if ( sc.isFailure() )
    00242   {
    00243     stream() << MSG::ERROR << "Failed to setup old \"Nodes\""      << endmsg ;
    00244     return sc ;
    00245   }
    00247   sc = setupAlgHandlers()   ; // convert "Algorithms" into "AlgMap"
    00248   if ( sc.isFailure() )
    00249   {
    00250     stream() << MSG::ERROR << "Failed to setup old \"Algorithms\"" << endmsg ;
    00251     return sc ;
    00252   }
    00254   add_prefix ( m_algMap  , m_prefix ) ;
    00256   add_prefix ( m_nodeMap , m_prefix ) ;
    00258   typedef std::set<std::string> Set ;
    00259   Set dirs ;
    00260   if ( m_partialPath ){ get_dirs ( m_algMap  , dirs ) ; }
    00261   if ( m_partialPath ){ get_dirs ( m_nodeMap , dirs ) ; }
    00262   //
    00263   Set::iterator _e = dirs.find("/Event") ;
    00264   if ( dirs.end() != _e ) { dirs.erase( _e ) ; }
    00265   // add all directories as nodes
    00266   for ( Set::const_iterator dir = dirs.begin() ; dirs.end() != dir ; ++dir )
    00267   {
    00268     if ( m_algMap  .end () != m_algMap  .find ( *dir ) ) { continue ; }
    00269     if ( m_nodeMap .end () != m_nodeMap .find ( *dir ) ) { continue ; }
    00270     m_nodeMap [*dir] = "DataObject" ;
    00271   }
    00272   //
    00273   m_algs  .clear  () ;
    00274   m_nodes .clear  () ;
    00275   //
    00277   for ( Map::const_iterator ialg = m_algMap.begin() ;
    00278         m_algMap.end() != ialg ; ++ialg )
    00279   {
    00280     Gaudi::Utils::TypeNameString alg ( ialg->second ) ;
    00281     Leaf leaf ( alg.type() , alg.name() ) ;
    00282     if  ( m_init )
    00283     {
    00284       if (configureHandler(leaf).isFailure()) {
    00285         leaf = Leaf(alg.type(), alg.name());
    00286       }
    00287     }
    00288     m_algs[ialg->first] =  leaf ;
    00289   }
    00291   for ( Map::const_iterator inode = m_nodeMap.begin() ;
    00292         m_nodeMap.end() != inode ; ++inode )
    00293   {
    00294     ClassH cl = ROOT::Reflex::Type::ByName( inode->second ) ;
    00295     if ( !cl )
    00296     {
    00297       stream() << MSG::WARNING
    00298                << "Failed to access dictionary class for "
    00299                << inode->first << " of type:" << inode->second << endmsg;
    00300     }
    00301     m_nodes[inode->first] = Node ( cl , false , inode->second ) ;
    00302   }
    00304   m_updateRequired = false ;
    00305   //
    00306   return StatusCode::SUCCESS ;
    00307 }

MsgStream& DataOnDemandSvc::stream | ( |  | ) | const`[inline, protected]`

get the message stream

Definition at line 236 of file DataOnDemandSvc.h.

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

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 716 of file DataOnDemandSvc.cpp.

    00718 {
    00719   if ( m_algs.empty()  &&  m_nodes.empty() ) { return ; }
    00720
    00721   typedef std::pair<std::string,std::string> Pair ;
    00722   typedef std::map<std::string,Pair>         PMap ;
    00723
    00724   PMap _m ;
    00725   for ( AlgMap::const_iterator alg = m_algs.begin() ;
    00726         m_algs.end() != alg ; ++alg )
    00727   {
    00728     PMap::const_iterator check = _m.find(alg->first) ;
    00729     if ( _m.end() != check )
    00730     {
    00731       stream()
    00732         << MSG::WARNING
    00733         << " The data item is activated for '"
    00734         << check->first << "' as '" << check->second.first << "'" << endmsg ;
    00735     }
    00736     const Leaf& l = alg->second ;
    00737     std::string nam = ( l.name == l.type ? l.type  : (l.type+"/"+l.name) ) ;
    00738     //
    00739     if ( !mode && 0 == l.num ) { continue ; }
    00740     //
    00741     std::string val ;
    00742     if ( mode ) { val = ( 0 == l.algorithm ) ? "F" : "T" ; }
    00743     else { val = boost::lexical_cast<std::string>( l.num ) ; }
    00744     //
    00745     _m[ no_prefix ( alg->first , m_prefix ) ] = std::make_pair ( nam , val ) ;
    00746   }
    00747   // nodes:
    00748   for ( NodeMap::const_iterator node = m_nodes.begin() ;
    00749         m_nodes.end() != node ; ++node )
    00750   {
    00751     PMap::const_iterator check = _m.find(node->first) ;
    00752     if ( _m.end() != check )
    00753     {
    00754       stream()
    00755         << MSG::WARNING
    00756         << " The data item is already activated for '"
    00757         << check->first << "' as '" << check->second.first << "'" << endmsg ;
    00758     }
    00759     const Node& n = node->second ;
    00760     std::string nam = "'" + n.name + "'"  ;
    00761     //
    00762     std::string val ;
    00763
    00764     if ( !mode && 0 == n.num ) { continue ; }
    00765
    00766     if ( mode ) { val = ( 0 == n.clazz ) ? "F" : "T" ; }
    00767     else { val = boost::lexical_cast<std::string>( n.num ) ; }
    00768     //
    00769     _m[ no_prefix ( node->first , m_prefix ) ] = std::make_pair ( nam , val ) ;
    00770   }
    00771   //
    00772   if ( _m.empty() ) { return ; }
    00773
    00774   // find the correct formats
    00775   size_t n1 = 0 ;
    00776   size_t n2 = 0 ;
    00777   size_t n3 = 0 ;
    00778   for  ( PMap::const_iterator it = _m.begin() ; _m.end() != it ; ++it )
    00779   {
    00780     n1 = std::max ( n1 , it->first.size()         ) ;
    00781     n2 = std::max ( n2 , it->second.first.size()  ) ;
    00782     n3 = std::max ( n3 , it->second.second.size() ) ;
    00783   }
    00784   if ( 10 > n1 ) { n1 = 10 ; }
    00785   if ( 10 > n2 ) { n2 = 10 ; }
    00786   if ( 60 < n1 ) { n1 = 60 ; }
    00787   if ( 60 < n2 ) { n2 = 60 ; }
    00788   //
    00789
    00790   const std::string _f = " | %%1$-%1%.%1%s | %%2$-%2%.%2%s | %%3$%3%.%3%s |" ;
    00791   boost::format _ff ( _f ) ;
    00792   _ff % n1 % n2 % n3 ;
    00793
    00794   const std::string _format  = _ff.str() ;
    00795
    00796   MsgStream& msg = stream() << level ;
    00797
    00798   if ( mode ) { msg << "Data-On-Demand Actions enabled for:"       ; }
    00799   else        { msg << "Data-On-Demand Actions has been used for:" ; }
    00800
    00801   boost::format fmt1( _format)  ;
    00802   fmt1 % "Address" % "Creator" % ( mode ? "S" : "#" ) ;
    00803   //
    00804   const std::string header = fmt1.str() ;
    00805   std::string line = std::string( header.size() , '-' ) ;
    00806   line[0] = ' ' ;
    00807
    00808   msg << std::endl << line
    00809       << std::endl << header
    00810       << std::endl << line ;
    00811
    00812   // make the actual printout:
    00813   for ( PMap::const_iterator item = _m.begin() ;
    00814         _m.end() != item ; ++item )
    00815   {
    00816     boost::format fmt( _format)  ;
    00817     msg << std::endl <<
    00818       ( fmt % item->first % item->second.first % item->second.second ) ;
    00819   }
    00820
    00821   msg << std::endl << line << endmsg ;
    00822
    00823 }

## Member Data Documentation

IIncidentSvc* DataOnDemandSvc::m_incSvc`[private]`

Incident service.

Definition at line 250 of file DataOnDemandSvc.h.

IAlgManager* DataOnDemandSvc::m_algMgr`[private]`

Algorithm manager.

Definition at line 252 of file DataOnDemandSvc.h.

IDataProviderSvc* DataOnDemandSvc::m_dataSvc`[private]`

Data provider reference.

Definition at line 254 of file DataOnDemandSvc.h.

std::string DataOnDemandSvc::m_trapType`[private]`

Trap name.

Definition at line 256 of file DataOnDemandSvc.h.

std::string DataOnDemandSvc::m_dataSvcName`[private]`

Data service name.

Definition at line 258 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_partialPath`[private]`

Flag to allow for the creation of partial leaves.

Definition at line 260 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_dump`[private]`

flag to force the printout

Definition at line 262 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_init`[private]`

flag to warm up the configuration

Definition at line 264 of file DataOnDemandSvc.h.

Setup DataOnDemandSvc::m_algMapping`[private]`

Mapping to algorithms.

Definition at line 266 of file DataOnDemandSvc.h.

Setup DataOnDemandSvc::m_nodeMapping`[private]`

Mapping to nodes.

Definition at line 268 of file DataOnDemandSvc.h.

AlgMap DataOnDemandSvc::m_algs`[private]`

Map of algorithms to handle incidents.

Definition at line 270 of file DataOnDemandSvc.h.

NodeMap DataOnDemandSvc::m_nodes`[private]`

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

Definition at line 272 of file DataOnDemandSvc.h.

Map DataOnDemandSvc::m_algMap`[private]`

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

Definition at line 276 of file DataOnDemandSvc.h.

Map DataOnDemandSvc::m_nodeMap`[private]`

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

Definition at line 278 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_updateRequired`[private]`

Definition at line 279 of file DataOnDemandSvc.h.

std::string DataOnDemandSvc::m_prefix`[private]`

Definition at line 280 of file DataOnDemandSvc.h.

MsgStream* DataOnDemandSvc::m_log`[mutable, private]`

Definition at line 281 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_total`[private]`

Definition at line 283 of file DataOnDemandSvc.h.

ulonglong DataOnDemandSvc::m_statAlg`[private]`

Definition at line 284 of file DataOnDemandSvc.h.

ulonglong DataOnDemandSvc::m_statNode`[private]`

Definition at line 285 of file DataOnDemandSvc.h.

ulonglong DataOnDemandSvc::m_stat`[private]`

Definition at line 286 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_timer_nodes`[private]`

Definition at line 288 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_timer_algs`[private]`

Definition at line 289 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_timer_all`[private]`

Definition at line 290 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_locked_nodes`[private]`

Definition at line 291 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_locked_algs`[private]`

Definition at line 292 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_locked_all`[private]`

Definition at line 293 of file DataOnDemandSvc.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiSvc/src/IncidentSvc/DataOnDemandSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiSvc/src/IncidentSvc/DataOnDemandSvc.cpp