Gaudi Framework, version v23r2

Home   Generated: Thu Jun 28 2012
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes

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:
Inheritance graph
[legend]
Collaboration diagram for DataOnDemandSvc:
Collaboration graph
[legend]

List of all members.

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::stringSetup
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.
void i_setNodeHandler (const std::string &name, const std::string &type)
 Internal method to initialize a node handler.
StatusCode i_setAlgHandler (const std::string &name, const Gaudi::Utils::TypeNameString &alg)
 Internal method to initialize an algorithm handler.
StatusCode update ()
 update the handlers
MsgStreamstream () const
 get the message stream
void dump (const MSG::Level level, const bool mode=true) const
 dump the content of DataOnDemand service

Private Types

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

Private Attributes

SmartIF< IIncidentSvcm_incSvc
 Incident service.
SmartIF< IAlgManagerm_algMgr
 Algorithm manager.
SmartIF< IDataProviderSvcm_dataSvc
 Data provider reference.
SmartIF< IToolSvcm_toolSvc
 Data provider reference.
std::string m_trapType
 Trap name.
std::string m_dataSvcName
 Data service name.
bool m_partialPath
 Flag to allow for the creation of partial leaves.
bool m_dump
 flag to force the printout
bool m_init
 flag to warm up the configuration
bool m_allowInitFailure
 flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithms fails (m_init).
Setup m_algMapping
 Mapping to algorithms.
Setup m_nodeMapping
 Mapping to nodes.
AlgMap m_algs
 Map of algorithms to handle incidents.
NodeMap m_nodes
 Map of "empty" objects to be placed as intermediate nodes.
Map m_algMap
 the major configuration property { 'data' : 'algorithm' }
Map m_nodeMap
 the major configuration property { 'data' : 'type' }
bool m_updateRequired
std::string m_prefix
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::stringm_nodeMapTools
std::list< IDODNodeMapper * > m_nodeMappers
std::vector< std::stringm_algMapTools
std::list< IDODAlgMapper * > m_algMappers

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:

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

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

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

    DataOnDemandSvc.NodeMap +=
   { "Phys" : "DataObject" ,
     "MC"   : "DataObject" } ;

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

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

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

Author:
M.Frank
Version:
1.0

Definition at line 91 of file DataOnDemandSvc.h.


Member Typedef Documentation

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

Definition at line 173 of file DataOnDemandSvc.h.

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

Definition at line 97 of file DataOnDemandSvc.h.

Definition at line 284 of file DataOnDemandSvc.h.

Definition at line 172 of file DataOnDemandSvc.h.

Definition at line 96 of file DataOnDemandSvc.h.


Constructor & Destructor Documentation

DataOnDemandSvc::DataOnDemandSvc ( const std::string name,
ISvcLocator svc 
)

Standard initializing service constructor.

Parameters:
name[IN] Service instance name
svc[IN] Pointer to service locator
Returns:
Reference to DataOnDemandSvc object.

Definition at line 46 of file DataOnDemandSvc.cpp.

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

  declareProperty ( "Prefix"             , m_prefix      ) ;

  declareProperty("NodeMappingTools", m_nodeMapTools,
                  "List of tools of type IDODNodeMapper");
  declareProperty("AlgMappingTools", m_algMapTools,
                  "List of tools of type IDODAlgMapper");
  // ==========================================================================
}
DataOnDemandSvc::~DataOnDemandSvc (  ) [virtual]

Standard destructor.

Definition at line 341 of file DataOnDemandSvc.cpp.

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

Member Function Documentation

StatusCode DataOnDemandSvc::configureHandler ( Leaf leaf ) [protected]

Configure handler for leaf.

Parameters:
leaf[IN] Reference to leaf handler
Returns:
StatusCode indicating success or failure

Definition at line 590 of file DataOnDemandSvc.cpp.

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

dump the content of DataOnDemand service

Parameters:
levelthe printout level
modethe printout mode

Definition at line 870 of file DataOnDemandSvc.cpp.

{
  if ( m_algs.empty()  &&  m_nodes.empty() ) { return ; }

  typedef std::pair<std::string,std::string> Pair ;
  typedef std::map<std::string,Pair>         PMap ;

  PMap _m ;
  for ( AlgMap::const_iterator alg = m_algs.begin() ;
        m_algs.end() != alg ; ++alg )
  {
    PMap::const_iterator check = _m.find(alg->first) ;
    if ( _m.end() != check )
    {
      stream()
        << MSG::WARNING
        << " The data item is activated for '"
        << check->first << "' as '" << check->second.first << "'" << endmsg ;
    }
    const Leaf& l = alg->second ;
    std::string nam = ( l.name == l.type ? l.type  : (l.type+"/"+l.name) ) ;
    //
    if ( !mode && 0 == l.num ) { continue ; }
    //
    std::string val ;
    if ( mode ) { val = ( 0 == l.algorithm ) ? "F" : "T" ; }
    else { val = boost::lexical_cast<std::string>( l.num ) ; }
    //
    _m[ no_prefix ( alg->first , m_prefix ) ] = std::make_pair ( nam , val ) ;
  }
  // nodes:
  for ( NodeMap::const_iterator node = m_nodes.begin() ;
        m_nodes.end() != node ; ++node )
  {
    PMap::const_iterator check = _m.find(node->first) ;
    if ( _m.end() != check )
    {
      stream()
        << MSG::WARNING
        << " The data item is already activated for '"
        << check->first << "' as '" << check->second.first << "'" << endmsg ;
    }
    const Node& n = node->second ;
    std::string nam = "'" + n.name + "'"  ;
    //
    std::string val ;

    if ( !mode && 0 == n.num ) { continue ; }

    if ( mode ) { val = ( 0 == n.clazz ) ? "F" : "T" ; }
    else { val = boost::lexical_cast<std::string>( n.num ) ; }
    //
    _m[ no_prefix ( node->first , m_prefix ) ] = std::make_pair ( nam , val ) ;
  }
  //
  if ( _m.empty() ) { return ; }

  // find the correct formats
  size_t n1 = 0 ;
  size_t n2 = 0 ;
  size_t n3 = 0 ;
  for  ( PMap::const_iterator it = _m.begin() ; _m.end() != it ; ++it )
  {
    n1 = std::max ( n1 , it->first.size()         ) ;
    n2 = std::max ( n2 , it->second.first.size()  ) ;
    n3 = std::max ( n3 , it->second.second.size() ) ;
  }
  if ( 10 > n1 ) { n1 = 10 ; }
  if ( 10 > n2 ) { n2 = 10 ; }
  if ( 60 < n1 ) { n1 = 60 ; }
  if ( 60 < n2 ) { n2 = 60 ; }
  //

  const std::string _f = " | %%1$-%1%.%1%s | %%2$-%2%.%2%s | %%3$%3%.%3%s |" ;
  boost::format _ff ( _f ) ;
  _ff % n1 % n2 % n3 ;

  const std::string _format  = _ff.str() ;

  MsgStream& msg = stream() << level ;

  if ( mode ) { msg << "Data-On-Demand Actions enabled for:"       ; }
  else        { msg << "Data-On-Demand Actions has been used for:" ; }

  boost::format fmt1( _format)  ;
  fmt1 % "Address" % "Creator" % ( mode ? "S" : "#" ) ;
  //
  const std::string header = fmt1.str() ;
  std::string line = std::string( header.size() , '-' ) ;
  line[0] = ' ' ;

  msg << std::endl << line
      << std::endl << header
      << std::endl << line ;

  // make the actual printout:
  for ( PMap::const_iterator item = _m.begin() ;
        _m.end() != item ; ++item )
  {
    boost::format fmt( _format)  ;
    msg << std::endl <<
      ( fmt % item->first % item->second.first % item->second.second ) ;
  }

  msg << std::endl << line << endmsg ;

}
StatusCode DataOnDemandSvc::execHandler ( const std::string tag,
Leaf leaf 
) [protected]

Execute leaf handler (algorithm)

Parameters:
tag[IN] Path to requested leaf
leaf[IN] Reference to leaf handler
Returns:
StatusCode indicating success or failure

Definition at line 829 of file DataOnDemandSvc.cpp.

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

Execute node handler (simple object creation using seal reflection)

Parameters:
tag[IN] Path to requested leaf
node[IN] Reference to node handler
Returns:
StatusCode indicating success or failure

Definition at line 771 of file DataOnDemandSvc.cpp.

{

  Gaudi::Utils::LockedChrono timer ( m_timer_nodes ,  m_locked_nodes ) ;

  if ( n.executing ) { return StatusCode::FAILURE ; }            // RETURN

  Protection p(n.executing);

  DataObject* object= 0 ;

  if ( n.dataObject )  { object = new DataObject() ; }
  else
  {
    // try to recover the handler
    if ( !n.clazz  ) { n.clazz = ROOT::Reflex::Type::ByName(n.name) ; }
    if ( !n.clazz  )
    {
      stream()
        << MSG::ERROR
        << "Failed to get dictionary for class '"
        << n.name
        << "' for location:" << tag << endmsg;
      return StatusCode::FAILURE ;                               // RETURN
    }
    //
    ROOT::Reflex::Object obj = n.clazz.Construct();

    object = (DataObject*) obj.Address();

    if ( !object )
    {
      stream()
        << MSG::ERROR
        << "Failed to create an object of type:"
        << n.clazz.Name(ROOT::Reflex::SCOPED) << " for location:" << tag
        << endmsg;
      return StatusCode::FAILURE  ;                               // RETURN
    }
  }
  //
  StatusCode sc = m_dataSvc->registerObject(tag, object );
  if ( sc.isFailure() )
  {
    stream()
      << MSG::ERROR << "Failed to register an object of type:"
      << n.name << " at location:" << tag
      << endmsg;
    return sc ;                                                  // RETURN
  }
  ++n.num ;
  //
  return StatusCode::SUCCESS ;
}
StatusCode DataOnDemandSvc::finalize (  ) [virtual]

Inherited Service overrides: Service finalization.

Reimplemented from Service.

Definition at line 364 of file DataOnDemandSvc.cpp.

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

IIncidentListener interfaces overrides: incident handling.

Implements IIncidentListener.

Definition at line 698 of file DataOnDemandSvc.cpp.

{

  Gaudi::Utils::LockedChrono timer ( m_timer_all , m_locked_all ) ;

  ++m_stat ;
  // proper incident type?
  if ( incident.type() != m_trapType ) { return ; }             // RETURN
  const DataIncident* inc = dynamic_cast<const DataIncident*>(&incident);
  if ( 0 == inc                      ) { return ; }             // RETURN
  // update if needed!
  if ( m_updateRequired ) { update() ; }

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

Internal method to initialize an algorithm handler.

Definition at line 257 of file DataOnDemandSvc.cpp.

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

Internal method to initialize a node handler.

Definition at line 247 of file DataOnDemandSvc.cpp.

                                                                                  {
  ClassH cl = ROOT::Reflex::Type::ByName(type) ;
  if (!cl) {
    warning()
        << "Failed to access dictionary class for "
        << name << " of type:" << type << endmsg;
  }
  m_nodes[name] = Node(cl, false, type);
}
StatusCode DataOnDemandSvc::initialize (  ) [virtual]

Inherited Service overrides: Service initialization.

Reimplemented from Service.

Definition at line 346 of file DataOnDemandSvc.cpp.

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

Inherited Service overrides: Service reinitialization.

re-initialization of the service

Reimplemented from Service.

Definition at line 425 of file DataOnDemandSvc.cpp.

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

Setup routine (called by (re-) initialize.

Definition at line 458 of file DataOnDemandSvc.cpp.

{
  if ( !(m_algMgr = serviceLocator()) ) // assignment meant
  {
    error() << "Failed to retrieve the IAlgManager interface." << endmsg;
    return StatusCode::FAILURE;
  }

  if ( !(m_incSvc = serviceLocator()->service("IncidentSvc")) ) // assignment meant
  {
    error() << "Failed to retrieve Incident service." << endmsg;
    return StatusCode::FAILURE;
  }
  m_incSvc->addListener(this, m_trapType);

  if ( !(m_dataSvc = serviceLocator()->service(m_dataSvcName)) ) // assignment meant
  {
    error()
      << "Failed to retrieve the data provider interface of "
      << m_dataSvcName << endmsg;
    return StatusCode::FAILURE;
  }

  // No need to get the ToolSvc if we are not using tools
  if (!(m_nodeMapTools.empty() && m_algMapTools.empty())) {
    if ( !(m_toolSvc = serviceLocator()->service("ToolSvc")) ) // assignment meant
    {
      error() << "Failed to retrieve ToolSvc" << endmsg;
      return StatusCode::FAILURE;
    }

    // load the node mapping tools
    std::vector<std::string>::iterator i;
    IDODNodeMapper *nodetool = 0;
    for(i = m_nodeMapTools.begin(); i != m_nodeMapTools.end(); ++i) {
      const StatusCode sc = m_toolSvc->retrieveTool(*i, nodetool);
      if (sc.isFailure()) return sc;
      m_nodeMappers.push_back(nodetool);
    }
    IDODAlgMapper *algtool = 0;
    for(i = m_algMapTools.begin(); i != m_algMapTools.end(); ++i) {
      const StatusCode sc = m_toolSvc->retrieveTool(*i, algtool);
      if (sc.isFailure()) return sc;
      m_algMappers.push_back(algtool);
    }
  }
  return update();
}
StatusCode DataOnDemandSvc::setupAlgHandlers (  ) [protected]

Initialize leaf handlers.

Definition at line 551 of file DataOnDemandSvc.cpp.

{
  Setup::const_iterator j;
  std::string typ, tag;

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

Initialize node handlers.

Definition at line 509 of file DataOnDemandSvc.cpp.

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

get the message stream

Definition at line 241 of file DataOnDemandSvc.h.

  {
    if ( 0 == m_log ) { m_log = new MsgStream( msgSvc() , name() ) ; }
    return *m_log;
  }
StatusCode DataOnDemandSvc::update (  ) [protected]

update the handlers

convert obsolete "Nodes" into new "NodeMap"

convert obsolete "Algorithms" into new "AlgMap"

add the default prefix

add the default prefix

get all directories

setup algorithms

setup nodes

Definition at line 279 of file DataOnDemandSvc.cpp.

{
  if ( !m_updateRequired ) { return StatusCode::SUCCESS  ; }

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

Definition at line 126 of file DataOnDemandSvc.cpp.

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

Definition at line 147 of file DataOnDemandSvc.cpp.

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

Definition at line 135 of file DataOnDemandSvc.cpp.

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

update handler for 'Dump' property

Definition at line 159 of file DataOnDemandSvc.cpp.

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

Member Data Documentation

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

Definition at line 286 of file DataOnDemandSvc.h.

Definition at line 308 of file DataOnDemandSvc.h.

Mapping to algorithms.

Definition at line 276 of file DataOnDemandSvc.h.

Definition at line 307 of file DataOnDemandSvc.h.

Algorithm manager.

Definition at line 257 of file DataOnDemandSvc.h.

Map of algorithms to handle incidents.

Definition at line 280 of file DataOnDemandSvc.h.

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

Definition at line 274 of file DataOnDemandSvc.h.

Data provider reference.

Definition at line 259 of file DataOnDemandSvc.h.

Data service name.

Definition at line 265 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_dump [private]

flag to force the printout

Definition at line 269 of file DataOnDemandSvc.h.

Incident service.

Definition at line 255 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_init [private]

flag to warm up the configuration

Definition at line 271 of file DataOnDemandSvc.h.

Definition at line 302 of file DataOnDemandSvc.h.

Definition at line 303 of file DataOnDemandSvc.h.

Definition at line 301 of file DataOnDemandSvc.h.

MsgStream* DataOnDemandSvc::m_log [mutable, private]

Definition at line 291 of file DataOnDemandSvc.h.

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

Definition at line 288 of file DataOnDemandSvc.h.

Definition at line 306 of file DataOnDemandSvc.h.

Mapping to nodes.

Definition at line 278 of file DataOnDemandSvc.h.

Definition at line 305 of file DataOnDemandSvc.h.

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

Definition at line 282 of file DataOnDemandSvc.h.

Flag to allow for the creation of partial leaves.

Definition at line 267 of file DataOnDemandSvc.h.

Definition at line 290 of file DataOnDemandSvc.h.

Definition at line 296 of file DataOnDemandSvc.h.

Definition at line 294 of file DataOnDemandSvc.h.

Definition at line 295 of file DataOnDemandSvc.h.

Definition at line 299 of file DataOnDemandSvc.h.

Definition at line 300 of file DataOnDemandSvc.h.

Definition at line 298 of file DataOnDemandSvc.h.

Data provider reference.

Definition at line 261 of file DataOnDemandSvc.h.

Definition at line 293 of file DataOnDemandSvc.h.

Trap name.

Definition at line 263 of file DataOnDemandSvc.h.

Definition at line 289 of file DataOnDemandSvc.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Thu Jun 28 2012 23:27:35 for Gaudi Framework, version v23r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004