Gaudi Framework, version v22r2

Home   Generated: Tue May 10 2011
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.
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

IIncidentSvcm_incSvc
 Incident service.
IAlgManagerm_algMgr
 Algorithm manager.
IDataProviderSvcm_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
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

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 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 GaudiUtils::HashMap<Gaudi::StringKey, Leaf> DataOnDemandSvc::AlgMap

Definition at line 172 of file DataOnDemandSvc.h.

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

Definition at line 96 of file DataOnDemandSvc.h.

Definition at line 277 of file DataOnDemandSvc.h.

Definition at line 171 of file DataOnDemandSvc.h.

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 47 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      ) ;
  // ==========================================================================
}
DataOnDemandSvc::~DataOnDemandSvc (  ) [virtual]

Standard destructor.

Definition at line 328 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 542 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 733 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 692 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 634 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 ( void   ) [virtual]

Inherited Service overrides: Service finalization.

Reimplemented from Service.

Definition at line 351 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->release();
    m_incSvc = 0;
  }
  if ( 0 != m_algMgr  ) { m_algMgr   -> release () ; m_algMgr  = 0 ; }
  if ( 0 != m_dataSvc ) { m_dataSvc  -> release () ; m_dataSvc = 0 ; }
  //
  return Service::finalize();
}
void DataOnDemandSvc::handle ( const Incident incident ) [virtual]

IIncidentListener interfaces overrides: incident handling.

Implements IIncidentListener.

Definition at line 589 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() )
  {
    stream()
      << MSG::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
  }
}
StatusCode DataOnDemandSvc::initialize (  ) [virtual]

Inherited Service overrides: Service initialization.

Reimplemented from Service.

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

{
  // reinitialize the Service Base class
  if ( 0 != m_incSvc )
  {
    m_incSvc -> removeListener ( this , m_trapType );
    m_incSvc -> release ();
    m_incSvc = 0;
  }
  if ( 0 != m_algMgr  ) { m_algMgr   -> release() ; m_algMgr  = 0 ; }
  if ( 0 != m_dataSvc ) { m_dataSvc  -> release() ; m_dataSvc = 0 ; }
  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 427 of file DataOnDemandSvc.cpp.

{
  m_algMgr = 0;
  StatusCode sc =
    serviceLocator()->queryInterface(IAlgManager::interfaceID(), pp_cast<void>(&m_algMgr));
  if ( sc.isFailure () )
  {
    stream()
      << MSG::ERROR
      << "Failed to retrieve the IAlgManager interface." << endmsg;
    return sc;
  }
  sc = service("IncidentSvc", m_incSvc, true);
  if ( sc.isFailure () )
  {
    stream()
      << MSG::ERROR << "Failed to retrieve Incident service." << endmsg;
    return sc;
  }
  m_incSvc->addListener(this, m_trapType);
  sc = service(m_dataSvcName, m_dataSvc, true);
  if ( sc.isFailure () )
  {
    stream()
      << MSG::ERROR
      << "Failed to retrieve the data provider interface of "
      << m_dataSvcName << endmsg;
    return sc;
  }
  return update() ;
}
StatusCode DataOnDemandSvc::setupAlgHandlers (  ) [protected]

Initialize leaf handlers.

Definition at line 503 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 461 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 236 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 245 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 )
  {
    Gaudi::Utils::TypeNameString alg ( ialg->second ) ;
    Leaf leaf ( alg.type() , alg.name() ) ;
    if  ( m_init )
    {
      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[ialg->first] =  leaf ;
  }
  for ( Map::const_iterator inode = m_nodeMap.begin() ;
        m_nodeMap.end() != inode ; ++inode )
  {
    ClassH cl = ROOT::Reflex::Type::ByName( inode->second ) ;
    if ( !cl )
    {
      stream() << MSG::WARNING
               << "Failed to access dictionary class for "
               << inode->first << " of type:" << inode->second << endmsg;
    }
    m_nodes[inode->first] = Node ( cl , false , inode->second ) ;
  }
  m_updateRequired = false ;
  //
  return StatusCode::SUCCESS ;
}
void DataOnDemandSvc::update_1 ( Property p )

Definition at line 122 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 143 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 131 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 155 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 279 of file DataOnDemandSvc.h.

Mapping to algorithms.

Definition at line 269 of file DataOnDemandSvc.h.

Algorithm manager.

Definition at line 252 of file DataOnDemandSvc.h.

Map of algorithms to handle incidents.

Definition at line 273 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 267 of file DataOnDemandSvc.h.

Data provider reference.

Definition at line 254 of file DataOnDemandSvc.h.

Data service name.

Definition at line 258 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_dump [private]

flag to force the printout

Definition at line 262 of file DataOnDemandSvc.h.

Incident service.

Definition at line 250 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_init [private]

flag to warm up the configuration

Definition at line 264 of file DataOnDemandSvc.h.

Definition at line 295 of file DataOnDemandSvc.h.

Definition at line 296 of file DataOnDemandSvc.h.

Definition at line 294 of file DataOnDemandSvc.h.

MsgStream* DataOnDemandSvc::m_log [mutable, private]

Definition at line 284 of file DataOnDemandSvc.h.

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

Definition at line 281 of file DataOnDemandSvc.h.

Mapping to nodes.

Definition at line 271 of file DataOnDemandSvc.h.

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

Definition at line 275 of file DataOnDemandSvc.h.

Flag to allow for the creation of partial leaves.

Definition at line 260 of file DataOnDemandSvc.h.

Definition at line 283 of file DataOnDemandSvc.h.

Definition at line 289 of file DataOnDemandSvc.h.

Definition at line 287 of file DataOnDemandSvc.h.

Definition at line 288 of file DataOnDemandSvc.h.

Definition at line 292 of file DataOnDemandSvc.h.

Definition at line 293 of file DataOnDemandSvc.h.

Definition at line 291 of file DataOnDemandSvc.h.

Definition at line 286 of file DataOnDemandSvc.h.

Trap name.

Definition at line 256 of file DataOnDemandSvc.h.

Definition at line 282 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 Tue May 10 2011 18:54:38 for Gaudi Framework, version v22r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004