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

#include <src/component/IoComponentMgr.h>

Inheritance diagram for IoComponentMgr:
Collaboration diagram for IoComponentMgr:

Classes

struct  IoComponentEntry
 

Public Member Functions

 IoComponentMgr (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters: More...
 
virtual ~IoComponentMgr ()
 Destructor: More...
 
void handle (const Incident &)
 Inform that a new incident has occurred. More...
 
virtual bool io_hasitem (IIoComponent *iocomponent) const
 : check if the registry contains a given IIoComponent More...
 
virtual bool io_contains (IIoComponent *iocomponent, const std::string &fname) const
 : check if the registry contains a given IIoComponent and that component had More...
 
virtual StatusCode io_register (IIoComponent *iocomponent)
 : allow a IIoComponent to register itself with this manager so appropriate actions can be taken when e.g. More...
 
virtual StatusCode io_register (IIoComponent *iocomponent, IIoComponentMgr::IoMode::Type iomode, const std::string &fname, const std::string &pfn)
 : allow a IIoComponent to register itself with this manager so appropriate actions can be taken when e.g. More...
 
virtual StatusCode io_update (IIoComponent *iocomponent, const std::string &old_fname, const std::string &new_fname)
 : allow a IIoComponent to update the contents of the registry with a new file name More...
 
virtual StatusCode io_update (IIoComponent *iocomponent, const std::string &work_dir)
 : allow a IIoComponent to update the contents of the registry with a new work directory More...
 
virtual StatusCode io_update_all (const std::string &work_dir)
 : Update all IIoComponents with a new work directory More...
 
virtual StatusCode io_retrieve (IIoComponent *iocomponent, std::string &fname)
 : retrieve the new filename for a given IIoComponent and More...
 
virtual StatusCode io_reinitialize ()
 : reinitialize the I/O subsystem. More...
 
virtual StatusCode io_finalize ()
 : finalize the I/O subsystem. More...
 
virtual StatusCode initialize ()
 Gaudi Service Implementation. More...
 
virtual StatusCode finalize ()
 Finalize (from INITIALIZED to CONFIGURED). More...
 
- Public Member Functions inherited from extends2< Service, IIoComponentMgr, IIncidentListener >
 extends2 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends2 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends2 ()
 Default constructor. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual ~extends2 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector
< Property * > & 
getProperties () const
 Get list of properties. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces3< IService, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
- Public Member Functions inherited from extend_interfaces2< IIoComponentMgr, IIncidentListener >
virtual ~extend_interfaces2 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IIoComponentMgr
 DeclareInterfaceID (IIoComponentMgr, 1, 0)
 
virtual ~IIoComponentMgr ()
 Destructor: More...
 
- Public Member Functions inherited from IIncidentListener
 DeclareInterfaceID (IIncidentListener, 2, 0)
 InterfaceID. More...
 

Private Types

typedef std::map< std::string,
IIoComponent * > 
IoRegistry_t
 
typedef std::list< IIoComponent * > IoStack_t
 
typedef std::multimap
< IIoComponent
*, IoComponentEntry
IoDict_t
 
typedef IoDict_t::const_iterator iodITR
 

Private Member Functions

 IoComponentMgr ()
 Default constructor: More...
 
bool findComp (IIoComponent *, const std::string &, iodITR &) const
 
bool findComp (IIoComponent *, std::pair< iodITR, iodITR > &) const
 
bool findComp (const std::string &, std::pair< iodITR, iodITR > &) const
 
std::string list () const
 

Private Attributes

MsgStream m_log
 
IoRegistry_t m_ioregistry
 Registry of IIoComponents. More...
 
IoStack_t m_iostack
 Stack of IIoComponents to properly handle order of registration. More...
 
IoDict_t m_cdict
 
std::string m_dict_location
 location of the python dictionary More...
 

Additional Inherited Members

- Public Types inherited from extends2< Service, IIoComponentMgr, IIncidentListener >
typedef extends2 base_class
 Typedef to this class. More...
 
typedef extend_interfaces2
< IIoComponentMgr,
IIncidentListener
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from Service
typedef
Gaudi::PluginService::Factory2
< IService *, const
std::string &, ISvcLocator * > 
Factory
 
- Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging base_class
 
- Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class. More...
 
typedef extend_interfaces3
< IService, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IService, IProperty, IStateful >
typedef mpl::fold< typename
IService::iid::iids::type,
typename mpl::fold< typename
IProperty::iid::iids::type,
typename
IStateful::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type, mpl::insert< mpl::_1,
mpl::_2 > >::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Public Types inherited from extend_interfaces2< IIoComponentMgr, IIncidentListener >
typedef mpl::fold< typename
IIoComponentMgr::iid::iids::type,
typename
IIncidentListener::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level. More...
 
Gaudi::StateMachine::State m_state
 Service state. More...
 
Gaudi::StateMachine::State m_targetState
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::auto_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

Detailed Description

Definition at line 28 of file IoComponentMgr.h.

Member Typedef Documentation

typedef std::multimap<IIoComponent*, IoComponentEntry > IoComponentMgr::IoDict_t
private

Definition at line 194 of file IoComponentMgr.h.

typedef IoDict_t::const_iterator IoComponentMgr::iodITR
private

Definition at line 195 of file IoComponentMgr.h.

typedef std::map<std::string, IIoComponent*> IoComponentMgr::IoRegistry_t
private

Definition at line 184 of file IoComponentMgr.h.

typedef std::list<IIoComponent*> IoComponentMgr::IoStack_t
private

Definition at line 188 of file IoComponentMgr.h.

Constructor & Destructor Documentation

IoComponentMgr::IoComponentMgr ( const std::string &  name,
ISvcLocator pSvcLocator 
)

Constructor with parameters:

Definition at line 49 of file IoComponentMgr.cpp.

51 : base_class(name,svc), m_log(msgSvc(), name )
52 {
53  //
54  // Property declaration
55  //
56  //declareProperty( "Property", m_nProperty );
57 
58 // declareProperty ("Registry",
59 // m_dict_location = "GaudiMP.IoRegistry.registry",
60 // "Location of the python dictionary holding the "
61 // "associations: \n"
62 // " {component-name:{ 'old-fname' : ['io','new-fname'] }}\n"
63 // "\nSyntax: <python-module>.<python-module>.<fct-name> \n"
64 // " where fct-name is a function returning the wanted "
65 // " dictionary.");
66 }
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
extends2 base_class
Typedef to this class.
Definition: extends.h:77
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
IoComponentMgr::~IoComponentMgr ( )
virtual

Destructor:

Definition at line 70 of file IoComponentMgr.cpp.

71 {
72 }
IoComponentMgr::IoComponentMgr ( )
private

Default constructor:

Member Function Documentation

StatusCode IoComponentMgr::finalize ( )
virtual

Finalize (from INITIALIZED to CONFIGURED).

Reimplemented from Service.

Definition at line 102 of file IoComponentMgr.cpp.

102  {
103  m_log << MSG::DEBUG << "--> finalize()" << endmsg;
104 
105  return StatusCode::SUCCESS;
106 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
bool IoComponentMgr::findComp ( IIoComponent c,
const std::string &  f,
iodITR itr 
) const
private

Definition at line 483 of file IoComponentMgr.cpp.

484  {
485 
486  pair<iodITR,iodITR> pit;
487  if (!findComp(c,pit)) {
488  itr = pit.first;
489  return false;
490  }
491 
492  for (itr = pit.first; itr != pit.second; ++itr) {
493  if (itr->second.m_oldfname == f) {
494  return true;
495  }
496  }
497 
498  return false;
499 
500 }
bool findComp(IIoComponent *, const std::string &, iodITR &) const
bool IoComponentMgr::findComp ( IIoComponent c,
std::pair< iodITR, iodITR > &  pit 
) const
private

Definition at line 505 of file IoComponentMgr.cpp.

505  {
506 
507  pit = m_cdict.equal_range(c);
508 
509  if (pit.first == pit.second) {
510  return false;
511  } else {
512  return true;
513  }
514 
515 }
bool IoComponentMgr::findComp ( const std::string &  c,
std::pair< iodITR, iodITR > &  pit 
) const
private

Definition at line 520 of file IoComponentMgr.cpp.

521  {
522 
523  pit.first = m_cdict.end();
524  pit.second = m_cdict.end();
525 
526  IoRegistry_t::const_iterator itr = m_ioregistry.find(c);
527  if (itr == m_ioregistry.end()) {
528  return false;
529  }
530 
531  return findComp(itr->second, pit);
532 }
tuple c
Definition: gaudirun.py:341
IoRegistry_t m_ioregistry
Registry of IIoComponents.
bool findComp(IIoComponent *, const std::string &, iodITR &) const
void IoComponentMgr::handle ( const Incident )
virtual

Inform that a new incident has occurred.

Implements IIncidentListener.

Definition at line 553 of file IoComponentMgr.cpp.

553  {
554 
555  pair<iodITR,iodITR> pit;
556 
557 
558  if ( i.type() == IncidentType::BeginInputFile ) {
559 
560  const FileIncident *fi = dynamic_cast<const FileIncident*> ( &i );
561  DEBMSG << "BeginInputFile: s: " << fi->source() << " t: " << fi->type()
562  << " n: " << fi->fileName() << " g: " << fi->fileGuid()
563  << endmsg;
564 
565  if (findComp(fi->source(),pit)) {
566  DEBMSG << " found component: " << endmsg;
567  while (pit.first != pit.second) {
568  IIoComponent* c = pit.first->first;
569  IoComponentEntry e = pit.first->second;
570  DEBMSG << " c: " << c->name() << " " << e << endmsg;
571 
572  ++pit.first;
573  }
574  } else {
575  DEBMSG << " could not find component \"" << fi->source()
576  << "\"!" << endmsg;
577  }
578 
579 
580 
581  } else if ( i.type() == IncidentType::BeginOutputFile ) {
582 
583  const FileIncident *fi = dynamic_cast<const FileIncident*> ( &i );
584  DEBMSG << "BeginOutputFile: s: " << fi->source() << " t: " << fi->type()
585  << " n: " << fi->fileName() << " g: " << fi->fileGuid()
586  << endmsg;
587 
588  if (findComp(fi->source(),pit)) {
589  DEBMSG << " found component: " << endmsg;
590  while (pit.first != pit.second) {
591  IIoComponent* c = pit.first->first;
592  IoComponentEntry e = pit.first->second;
593  DEBMSG << " c: " << c->name() << " " << e << endmsg;
594 
595  ++pit.first;
596  }
597  } else {
598  DEBMSG << " could not find component \"" << fi->source()
599  << "\"!" << endmsg;
600  }
601 
602  }
603 
604 }
This class is the FileIncident.
Definition: FileIncident.h:18
const std::string & type() const
Access to the incident type.
Definition: Incident.h:34
const std::string & source() const
Access to the source of the incident.
Definition: Incident.h:40
tuple c
Definition: gaudirun.py:341
#define DEBMSG
virtual const std::string & name() const =0
Retrieve the name of the instance.
bool findComp(IIoComponent *, const std::string &, iodITR &) const
const std::string BeginOutputFile
a new output file has been created
Definition: Incident.h:72
const std::string & fileGuid() const
Definition: FileIncident.h:62
const std::string & fileName() const
Definition: FileIncident.h:61
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
const std::string BeginInputFile
a new input file has been started
Definition: Incident.h:77
StatusCode IoComponentMgr::initialize ( )
virtual

Gaudi Service Implementation.

Reimplemented from Service.

Definition at line 77 of file IoComponentMgr.cpp.

77  {
78  m_log << MSG::DEBUG << "--> initialize()" << endmsg;
79 
80  if ( Service::initialize().isFailure() ) {
81  m_log << MSG::ERROR << "Unable to initialize Service base class" << endmsg;
82  return StatusCode::FAILURE;
83  }
85 
86  IIncidentSvc* p_incSvc(0);
87 
88  if (service("IncidentSvc", p_incSvc, true).isFailure()) {
89  m_log << MSG::ERROR << "unable to get the IncidentSvc" << endmsg;
90  return StatusCode::FAILURE;
91  } else {
92  p_incSvc->addListener( this, IncidentType::BeginOutputFile, 100, true);
93  p_incSvc->addListener( this, IncidentType::BeginInputFile, 100, true);
94  }
95 
96  return StatusCode::SUCCESS;
97 }
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:241
const std::string BeginOutputFile
a new output file has been created
Definition: Incident.h:72
const TYPE & value() const
explicit conversion
Definition: Property.h:355
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: Service.cpp:74
void setLevel(int level)
Update outputlevel.
Definition: MsgStream.h:105
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Service.h:140
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:22
const std::string BeginInputFile
a new input file has been started
Definition: Incident.h:77
bool IoComponentMgr::io_contains ( IIoComponent iocomponent,
const std::string &  fname 
) const
virtual

: check if the registry contains a given IIoComponent and that component had

Parameters
<tt>fname</tt>as a filename

Implements IIoComponentMgr.

Definition at line 129 of file IoComponentMgr.cpp.

131 {
132  m_log << MSG::DEBUG << "--> io_contains()" << endmsg;
133  if ( 0 == iocomponent ) {
134  return false;
135  }
136  const std::string& ioname = iocomponent->name();
137 
138  DEBMSG << "io_contains: c: " << ioname << " f: " << fname << endmsg;
139 
140  pair<iodITR,iodITR> fit = m_cdict.equal_range(iocomponent);
141  if (fit.first == fit.second) {
142  return false;
143  } else {
144  iodITR it;
145  for (it=fit.first; it != fit.second; ++it) {
146  IoComponentEntry ioe = it->second;
147  DEBMSG << " " << ioe << endmsg;
148  if (ioe.m_oldfname == "") {
149  m_log << MSG::ERROR << "IIoComponent " << ioname
150  << " has empty old filename" << endmsg;
151  return false;
152  } else if (ioe.m_oldfname == fname) {
153  return true;
154  }
155  }
156  }
157 
158  return false;
159 }
IoDict_t::const_iterator iodITR
#define DEBMSG
virtual const std::string & name() const =0
Retrieve the name of the instance.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
StatusCode IoComponentMgr::io_finalize ( )
virtual

: finalize the I/O subsystem.

Hook to allow to e.g. give a chance to I/O subsystems to merge output files. Not sure how to do this correctly though...

Implements IIoComponentMgr.

Definition at line 451 of file IoComponentMgr.cpp.

452 {
453 
454  m_log << MSG::DEBUG << "--> io_finalize()" << endmsg;
455  m_log << MSG::DEBUG << "finalizing I/O subsystem..." << endmsg;
456 
457  if (m_log.level() <= MSG::DEBUG) {
458  m_log << MSG::DEBUG << "Listing all monitored entries: " << std::endl;
459  DEBMSG << list() << endmsg;
460  }
461 
462  bool allgood = true;
463  for ( IoStack_t::iterator io = m_iostack.begin(), ioEnd = m_iostack.end();
464  io != ioEnd;
465  ++io ) {
466  m_log << MSG::DEBUG << " [" << (*io)->name() << "]->io_finalize()..."
467  << endmsg;
468  if ( !(*io)->io_finalize().isSuccess() ) {
469  allgood = false;
470  m_log << MSG::ERROR << "problem in [" << (*io)->name()
471  << "]->io_finalize() !" << endmsg;
472  }
473  }
474 
475  return allgood
478 }
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:111
#define DEBMSG
std::string list() const
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
bool IoComponentMgr::io_hasitem ( IIoComponent iocomponent) const
virtual

: check if the registry contains a given IIoComponent

Implements IIoComponentMgr.

Definition at line 113 of file IoComponentMgr.cpp.

113  {
114  DEBMSG << "--> io_hasitem()" << endmsg;
115  if ( 0 == iocomponent ) {
116  return false;
117  }
118  const std::string& ioname = iocomponent->name();
119  IoRegistry_t::const_iterator io = m_ioregistry.find (ioname);
120  return io != m_ioregistry.end();
121 }
IoRegistry_t m_ioregistry
Registry of IIoComponents.
#define DEBMSG
virtual const std::string & name() const =0
Retrieve the name of the instance.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
StatusCode IoComponentMgr::io_register ( IIoComponent iocomponent)
virtual

: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when e.g.

a fork(2) has been issued (this is usually handled by calling IIoComponent::io_reinit on every registered component)

Implements IIoComponentMgr.

Definition at line 170 of file IoComponentMgr.cpp.

171 {
172  if ( 0 == iocomponent ) {
173  m_log << MSG::ERROR
174  << "io_register (component) received a NULL pointer !" << endmsg;
175  return StatusCode::FAILURE;
176  }
177  const std::string& ioname = iocomponent->name();
178  DEBMSG << "--> io_register(" << ioname << ")" << endmsg;
179  IoRegistry_t::iterator itr = m_ioregistry.find (ioname);
180  if ( itr == m_ioregistry.end() ) {
181  DEBMSG << " registering IoComponent \"" << ioname << "\"" << endmsg;
182  iocomponent->addRef(); // ownership...
183  m_ioregistry[ioname] = iocomponent;
184  m_iostack.push_back (iocomponent);
185  } else {
186  m_log << MSG::INFO << "IoComponent[" << iocomponent->name()
187  <<"] already registered @" << (void*)itr->second << endmsg;
188  }
189  return StatusCode::SUCCESS;
190 }
IoRegistry_t m_ioregistry
Registry of IIoComponents.
#define DEBMSG
virtual const std::string & name() const =0
Retrieve the name of the instance.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
StatusCode IoComponentMgr::io_register ( IIoComponent iocomponent,
IIoComponentMgr::IoMode::Type  iomode,
const std::string &  fname,
const std::string &  pfn 
)
virtual

: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when e.g.

a fork(2) has been issued (this is usually handled by calling IIoComponent::io_reinit on every registered component)

Implements IIoComponentMgr.

Definition at line 201 of file IoComponentMgr.cpp.

205 {
206  if ( 0 == iocomponent ) {
207  return StatusCode::FAILURE;
208  }
209  const std::string& ioname = iocomponent->name();
210 
211  DEBMSG << "--> io_register(" << ioname << ","
212  << ( (iomode== IIoComponentMgr::IoMode::READ) ? "R" : "W" )
213  << "," << fname << ")" << endmsg;
214 
215  if ( !io_hasitem (iocomponent) ) {
216  if ( !io_register (iocomponent).isSuccess() ) {
217  m_log << MSG::ERROR
218  << "could not register component [" << iocomponent->name() << "] "
219  << "with the I/O component manager !"
220  << endmsg;
221  return StatusCode::FAILURE;
222  }
223  }
224 
225  pair<iodITR,iodITR> fit = m_cdict.equal_range(iocomponent);
226  if (fit.first != fit.second) {
227  for (iodITR it=fit.first; it != fit.second; ++it) {
228  IoComponentEntry ioe = it->second;
229  if (ioe.m_oldfname == fname) {
230  if (ioe.m_iomode == iomode) {
231  m_log << MSG::INFO << "IoComponent " << ioname
232  << " has already had file " << fname
233  << " registered with i/o mode " << iomode << endmsg;
234  return StatusCode::SUCCESS;
235  } else {
236  m_log << MSG::WARNING << "IoComponent " << ioname
237  << " has already had file " << fname
238  << " registered with a different i/o mode " << ioe.m_iomode
239  << " - now trying " << iomode << endmsg;
240  }
241  }
242  }
243  }
244 
245  // We need to take into account that boost::filesystem::absolute() does not
246  // work for files read from eos, i.e. starting with "root:"
247  std::string tmp_name = pfn.empty()?fname:pfn;
248  bool from_eos = tmp_name.find("root:")==0;
249  IoComponentEntry ioc(fname,(from_eos?tmp_name:boost::filesystem::absolute(tmp_name).string()),iomode);
250  m_cdict.insert( pair<IIoComponent*, IoComponentEntry>(iocomponent, ioc) );
251 
252  return StatusCode::SUCCESS;
253 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
IoDict_t::const_iterator iodITR
#define DEBMSG
virtual const std::string & name() const =0
Retrieve the name of the instance.
virtual bool io_hasitem(IIoComponent *iocomponent) const
: check if the registry contains a given IIoComponent
virtual StatusCode io_register(IIoComponent *iocomponent)
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
StatusCode IoComponentMgr::io_reinitialize ( )
virtual

: reinitialize the I/O subsystem.

This effectively calls IIoComponent::io_reinit on all the registered IIoComponent.

Implements IIoComponentMgr.

Definition at line 306 of file IoComponentMgr.cpp.

307 {
308  m_log << MSG::DEBUG << "--> io_reinitialize()" << endmsg;
309  m_log << MSG::DEBUG << "reinitializing I/O subsystem..." << endmsg;
310 
311  if (m_log.level() <= MSG::DEBUG) {
312  m_log << MSG::DEBUG << "Listing all monitored entries: " << std::endl;
313  DEBMSG << list() << endmsg;
314  }
315 
316  bool allgood = true;
317  for ( IoStack_t::iterator io = m_iostack.begin(), ioEnd = m_iostack.end();
318  io != ioEnd;
319  ++io ) {
320  m_log << MSG::DEBUG << " [" << (*io)->name() << "]->io_reinit()..."
321  << endmsg;
322  if ( !(*io)->io_reinit().isSuccess() ) {
323  allgood = false;
324  m_log << MSG::ERROR << "problem in [" << (*io)->name()
325  << "]->io_reinit() !" << endmsg;
326  }
327  // we are done with this guy... release it
328  (*io)->release();
329  }
330 
331  // we are done.
332  // FIXME: shall we allow for multiple io_reinitialize ?
333  // m_iostack.clear();
334  // m_ioregistry.clear();
335  // m_cdict.clear();
336 
337  return allgood
340 }
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:111
#define DEBMSG
std::string list() const
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
StatusCode IoComponentMgr::io_retrieve ( IIoComponent iocomponent,
std::string &  fname 
)
virtual

: retrieve the new filename for a given IIoComponent and

Parameters
<tt>fname</tt>filename
<tt>oldfname</tt>filename

Implements IIoComponentMgr.

Definition at line 261 of file IoComponentMgr.cpp.

263 {
264  if ( 0 == iocomponent ) {
265  return StatusCode::FAILURE;
266  }
267 
268  std::string ofname = fname;
269  const std::string& ioname = iocomponent->name();
270 
271  m_log << MSG::DEBUG << "--> io_retrieve(" << ioname << "," << fname << ")"
272  << endmsg;
273 
274  iodITR it;
275  if (!findComp(iocomponent,ofname,it)) {
276  DEBMSG << "could not find c: " << ioname << " old_f: " << ofname << endmsg;
277  return StatusCode::FAILURE;
278  } else {
279 
280  IoDict_t::iterator it;
281  for (it = m_cdict.equal_range(iocomponent).first;
282  it != m_cdict.equal_range(iocomponent).second;
283  ++it) {
284 
285  if (it->second.m_oldfname == ofname) {
286  DEBMSG << "retrieving new name for the component " << iocomponent->name()
287  << " old name: " << ofname
288  << ", new name: " << it->second.m_newfname << endmsg;
289  fname = it->second.m_newfname;
290  return StatusCode::SUCCESS;
291  }
292  }
293  }
294 
295  DEBMSG << "Unexpected error! Unable to find entry in the dictionary corresponding to old filename: " << ofname << endmsg;
296  return StatusCode::FAILURE;
297 }
IoDict_t::const_iterator iodITR
#define DEBMSG
virtual const std::string & name() const =0
Retrieve the name of the instance.
bool findComp(IIoComponent *, const std::string &, iodITR &) const
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
StatusCode IoComponentMgr::io_update ( IIoComponent iocomponent,
const std::string &  old_fname,
const std::string &  new_fname 
)
virtual

: allow a IIoComponent to update the contents of the registry with a new file name

Implements IIoComponentMgr.

Definition at line 345 of file IoComponentMgr.cpp.

346  {
347 
348  DEBMSG << "--> io_update(" << ioc->name() << ","
349  << old_fname << "," << new_fname << ")" << endmsg;
350 
351  IoDict_t::iterator it;
352  for (it = m_cdict.equal_range(ioc).first;
353  it != m_cdict.equal_range(ioc).second;
354  ++it) {
355 
356  if (it->second.m_oldfname == old_fname) {
357  DEBMSG << "updating " << ioc->name() << " f: " << old_fname << " -> "
358  << new_fname << endmsg;
359  it->second.m_newfname = new_fname;
360  return StatusCode::SUCCESS;
361  }
362  }
363 
364  return StatusCode::FAILURE;
365 
366 }
#define DEBMSG
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
StatusCode IoComponentMgr::io_update ( IIoComponent iocomponent,
const std::string &  work_dir 
)
virtual

: allow a IIoComponent to update the contents of the registry with a new work directory

Implements IIoComponentMgr.

Definition at line 371 of file IoComponentMgr.cpp.

371  {
372 
373  DEBMSG << "--> io_update(" << ioc->name() << ","
374  << work_dir << ")" << endmsg;
375 
376  IoDict_t::iterator it;
377  for (it = m_cdict.equal_range(ioc).first;
378  it != m_cdict.equal_range(ioc).second;
379  ++it) {
380 
381  switch(it->second.m_iomode) {
383  {
384  it->second.m_newfname = it->second.m_oldabspath;
385  break;
386  }
388  {
389  boost::filesystem::path oldPath(it->second.m_oldfname);
390  if(oldPath.is_relative() &&
391  oldPath.filename()==oldPath.relative_path()) {
392 
393  // Only file name was provided for writing. This is the usual mode of operation
394  // ***
395  // NB. In such cases it would make sense to set newfname=oldfname, however this will break
396  // existing client codes, which assume that newfname contains "/"
397  // Thus we set newfname=workdir/oldfname
398  // ***
399 
400  boost::filesystem::path newfname(work_dir);
401  newfname /= oldPath;
402  it->second.m_newfname = newfname.string();
403  }
404  else {
405  // New name should be the old absolute path
406  it->second.m_newfname = it->second.m_oldabspath;
407  }
408 
409  break;
410  }
411  default:
412  {
413  // Don't know how to deal with either RW or INVALID
414  m_log << MSG::ERROR << "Unable to update IoComponent for the mode " << it->second.m_iomode << endmsg;
415  return StatusCode::FAILURE;
416  }
417  }
418 
419  } // for
420 
421  return StatusCode::SUCCESS;
422 
423 }
#define DEBMSG
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
StatusCode IoComponentMgr::io_update_all ( const std::string &  work_dir)
virtual

: Update all IIoComponents with a new work directory

Implements IIoComponentMgr.

Definition at line 428 of file IoComponentMgr.cpp.

429 {
430  DEBMSG << "-->io_update_all for the directory " << work_dir << endmsg;
431  bool allgood = true;
432  for ( IoStack_t::iterator io = m_iostack.begin(), ioEnd = m_iostack.end();
433  io != ioEnd;
434  ++io ) {
435  if ( !io_update(*io,work_dir).isSuccess() ) {
436  allgood = false;
437  m_log << MSG::ERROR << "problem in [" << (*io)->name()
438  << "]->io_update() !" << endmsg;
439  }
440  }
441  return allgood ? StatusCode::SUCCESS : StatusCode::FAILURE;
442 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
#define DEBMSG
virtual StatusCode io_update(IIoComponent *iocomponent, const std::string &old_fname, const std::string &new_fname)
: allow a IIoComponent to update the contents of the registry with a new file name ...
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
std::string IoComponentMgr::list ( ) const
private

Definition at line 537 of file IoComponentMgr.cpp.

537  {
538 
539  ostringstream ost;
540 
541  ost << "Listing all IoComponents (" << m_cdict.size() << "): " << endl;
542  for (iodITR it = m_cdict.begin(); it != m_cdict.end(); ++it) {
543  ost << " " << it->first->name() << " " << it->second
544  << endl;
545  }
546 
547  return ost.str();
548 }
IoDict_t::const_iterator iodITR

Member Data Documentation

IoDict_t IoComponentMgr::m_cdict
private

Definition at line 197 of file IoComponentMgr.h.

std::string IoComponentMgr::m_dict_location
private

location of the python dictionary

Definition at line 200 of file IoComponentMgr.h.

IoRegistry_t IoComponentMgr::m_ioregistry
private

Registry of IIoComponents.

Definition at line 186 of file IoComponentMgr.h.

IoStack_t IoComponentMgr::m_iostack
private

Stack of IIoComponents to properly handle order of registration.

Definition at line 190 of file IoComponentMgr.h.

MsgStream IoComponentMgr::m_log
mutableprivate

Definition at line 182 of file IoComponentMgr.h.


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