The Gaudi Framework  v28r2p1 (f1a77ff4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IoComponentMgr Class Reference

#include <src/component/IoComponentMgr.h>

Inheritance diagram for IoComponentMgr:
Collaboration diagram for IoComponentMgr:

Classes

struct  IoComponentEntry
 

Public Member Functions

 ~IoComponentMgr () override=default
 Destructor: More...
 
void handle (const Incident &) override
 
bool io_hasitem (IIoComponent *iocomponent) const override
 : check if the registry contains a given IIoComponent More...
 
bool io_contains (IIoComponent *iocomponent, const std::string &fname) const override
 : check if the registry contains a given IIoComponent and that component had More...
 
StatusCode io_register (IIoComponent *iocomponent) override
 : allow a IIoComponent to register itself with this manager so appropriate actions can be taken when e.g. More...
 
StatusCode io_register (IIoComponent *iocomponent, IIoComponentMgr::IoMode::Type iomode, const std::string &fname, const std::string &pfn) override
 : allow a IIoComponent to register itself with this manager so appropriate actions can be taken when e.g. More...
 
StatusCode io_update (IIoComponent *iocomponent, const std::string &old_fname, const std::string &new_fname) override
 : allow a IIoComponent to update the contents of the registry with a new file name More...
 
StatusCode io_update (IIoComponent *iocomponent, const std::string &work_dir) override
 : allow a IIoComponent to update the contents of the registry with a new work directory More...
 
StatusCode io_update_all (const std::string &work_dir) override
 : Update all IIoComponents with a new work directory More...
 
StatusCode io_retrieve (IIoComponent *iocomponent, std::string &fname) override
 : retrieve the new filename for a given IIoComponent and More...
 
StatusCode io_reinitialize () override
 : reinitialize the I/O subsystem. More...
 
StatusCode io_finalize () override
 : finalize the I/O subsystem. More...
 
StatusCode initialize () override
 Gaudi Service Implementation. More...
 
StatusCode finalize () override
 
- Public Member Functions inherited from extends< Service, IIoComponentMgr, IIncidentListener >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 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<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, 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 >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
 ~PropertyHolder () override=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 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...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces... >
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Private Types

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

Private Member Functions

 IoComponentMgr ()=delete
 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

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 extends< Service, IIoComponentMgr, IIncidentListener >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Detailed Description

Definition at line 28 of file IoComponentMgr.h.

Member Typedef Documentation

typedef IoDict_t::const_iterator IoComponentMgr::iodITR
private

Definition at line 177 of file IoComponentMgr.h.

Definition at line 166 of file IoComponentMgr.h.

Definition at line 170 of file IoComponentMgr.h.

Constructor & Destructor Documentation

IoComponentMgr::~IoComponentMgr ( )
overridedefault

Destructor:

IoComponentMgr::IoComponentMgr ( )
privatedelete

Default constructor:

Member Function Documentation

StatusCode IoComponentMgr::finalize ( )
override

Definition at line 73 of file IoComponentMgr.cpp.

73  {
74  DEBMSG << "--> finalize()" << endmsg;
75 
76  return StatusCode::SUCCESS;
77 }
#define DEBMSG
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool IoComponentMgr::findComp ( IIoComponent c,
const std::string f,
iodITR itr 
) const
private

Definition at line 448 of file IoComponentMgr.cpp.

449  {
450 
452  if (!findComp(c,pit)) {
453  itr = pit.first;
454  return false;
455  }
456  return std::any_of( pit.first, pit.second,
457  [&](IoDict_t::const_reference i)
458  { return i.second.m_oldfname == f; } );
459 
460 }
bool findComp(IIoComponent *, const std::string &, iodITR &) const
T any_of(T...args)
bool IoComponentMgr::findComp ( IIoComponent c,
std::pair< iodITR, iodITR > &  pit 
) const
private

Definition at line 465 of file IoComponentMgr.cpp.

465  {
466 
467  pit = m_cdict.equal_range(c);
468  return pit.first != pit.second;
469 
470 }
T equal_range(T...args)
bool IoComponentMgr::findComp ( const std::string c,
std::pair< iodITR, iodITR > &  pit 
) const
private

Definition at line 475 of file IoComponentMgr.cpp.

476  {
477 
478  pit.first = m_cdict.end();
479  pit.second = m_cdict.end();
480 
481  auto itr = m_ioregistry.find(c);
482  return ( itr != m_ioregistry.end() ) && findComp(itr->second, pit);
483 }
IoRegistry_t m_ioregistry
Registry of IIoComponents.
T end(T...args)
bool findComp(IIoComponent *, const std::string &, iodITR &) const
T find(T...args)
void IoComponentMgr::handle ( const Incident i)
override

Definition at line 503 of file IoComponentMgr.cpp.

503  {
504 
506 
507 
508  if ( i.type() == IncidentType::BeginInputFile ) {
509 
510  const FileIncident *fi = dynamic_cast<const FileIncident*> ( &i );
511  DEBMSG << "BeginInputFile: s: " << fi->source() << " t: " << fi->type()
512  << " n: " << fi->fileName() << " g: " << fi->fileGuid()
513  << endmsg;
514 
515  if (findComp(fi->source(),pit)) {
516  DEBMSG << " found component: " << endmsg;
517  while (pit.first != pit.second) {
518  IIoComponent* c = pit.first->first;
519  IoComponentEntry e = pit.first->second;
520  DEBMSG << " c: " << c->name() << " " << e << endmsg;
521 
522  ++pit.first;
523  }
524  } else {
525  DEBMSG << " could not find component \"" << fi->source()
526  << "\"!" << endmsg;
527  }
528 
529 
530 
531  } else if ( i.type() == IncidentType::BeginOutputFile ) {
532 
533  const FileIncident *fi = dynamic_cast<const FileIncident*> ( &i );
534  DEBMSG << "BeginOutputFile: s: " << fi->source() << " t: " << fi->type()
535  << " n: " << fi->fileName() << " g: " << fi->fileGuid()
536  << endmsg;
537 
538  if (findComp(fi->source(),pit)) {
539  DEBMSG << " found component: " << endmsg;
540  while (pit.first != pit.second) {
541  IIoComponent* c = pit.first->first;
542  IoComponentEntry e = pit.first->second;
543  DEBMSG << " c: " << c->name() << " " << e << endmsg;
544 
545  ++pit.first;
546  }
547  } else {
548  DEBMSG << " could not find component \"" << fi->source()
549  << "\"!" << endmsg;
550  }
551 
552  }
553 
554 }
This class is the FileIncident.
Definition: FileIncident.h:17
const std::string & type() const
Access to the incident type.
Definition: Incident.h:41
const std::string & source() const
Access to the source of the incident.
Definition: Incident.h:47
#define DEBMSG
bool findComp(IIoComponent *, const std::string &, iodITR &) const
const std::string & fileGuid() const
Definition: FileIncident.h:65
const std::string & fileName() const
Definition: FileIncident.h:64
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode IoComponentMgr::initialize ( )
override

Gaudi Service Implementation.

Definition at line 49 of file IoComponentMgr.cpp.

49  {
50  DEBMSG << "--> initialize()" << endmsg;
51 
52  if ( Service::initialize().isFailure() ) {
53  error() << "Unable to initialize Service base class" << endmsg;
54  return StatusCode::FAILURE;
55  }
56 
57  IIncidentSvc* p_incSvc(0);
58 
59  if (service("IncidentSvc", p_incSvc, true).isFailure()) {
60  error() << "unable to get the IncidentSvc" << endmsg;
61  return StatusCode::FAILURE;
62  } else {
63  p_incSvc->addListener( this, IncidentType::BeginOutputFile, 100, true);
64  p_incSvc->addListener( this, IncidentType::BeginInputFile, 100, true);
65  }
66 
67  return StatusCode::SUCCESS;
68 }
StatusCode initialize() override
Definition: Service.cpp:64
#define DEBMSG
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
bool IoComponentMgr::io_contains ( IIoComponent iocomponent,
const std::string fname 
) const
override

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

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

Definition at line 100 of file IoComponentMgr.cpp.

102 {
103  DEBMSG << "--> io_contains()" << endmsg;
104  if ( 0 == iocomponent ) {
105  return false;
106  }
107  const std::string& ioname = iocomponent->name();
108 
109  DEBMSG << "io_contains: c: " << ioname << " f: " << fname << endmsg;
110 
111  pair<iodITR,iodITR> fit = m_cdict.equal_range(iocomponent);
112  if (fit.first == fit.second) {
113  return false;
114  } else {
115  iodITR it;
116  for (it=fit.first; it != fit.second; ++it) {
117  IoComponentEntry ioe = it->second;
118  DEBMSG << " " << ioe << endmsg;
119  if (ioe.m_oldfname == "") {
120  error() << "IIoComponent " << ioname
121  << " has empty old filename" << endmsg;
122  return false;
123  } else if (ioe.m_oldfname == fname) {
124  return true;
125  }
126  }
127  }
128 
129  return false;
130 }
IoDict_t::const_iterator iodITR
#define DEBMSG
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T equal_range(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode IoComponentMgr::io_finalize ( )
override

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

Definition at line 418 of file IoComponentMgr.cpp.

419 {
420  ON_DEBUG {
421  debug() << "--> io_finalize()" << endmsg;
422  debug() << "finalizing I/O subsystem..." << endmsg;
423  debug() << "Listing all monitored entries: " << std::endl;
424  debug() << list() << endmsg;
425  }
426 
427  bool allgood = true;
428  for ( IoStack_t::iterator io = m_iostack.begin(), ioEnd = m_iostack.end();
429  io != ioEnd;
430  ++io ) {
431  DEBMSG << " [" << (*io)->name() << "]->io_finalize()..."
432  << endmsg;
433  if ( !(*io)->io_finalize().isSuccess() ) {
434  allgood = false;
435  error() << "problem in [" << (*io)->name()
436  << "]->io_finalize() !" << endmsg;
437  }
438  }
439 
440  return allgood
443 }
T endl(T...args)
T end(T...args)
#define DEBMSG
std::string list() const
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
#define ON_DEBUG
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
T begin(T...args)
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:244
bool IoComponentMgr::io_hasitem ( IIoComponent iocomponent) const
override

: check if the registry contains a given IIoComponent

Definition at line 84 of file IoComponentMgr.cpp.

84  {
85  DEBMSG << "--> io_hasitem()" << endmsg;
86  if ( 0 == iocomponent ) {
87  return false;
88  }
89  const std::string& ioname = iocomponent->name();
90  IoRegistry_t::const_iterator io = m_ioregistry.find (ioname);
91  return io != m_ioregistry.end();
92 }
IoRegistry_t m_ioregistry
Registry of IIoComponents.
T end(T...args)
#define DEBMSG
STL class.
T find(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode IoComponentMgr::io_register ( IIoComponent iocomponent)
override

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

Definition at line 141 of file IoComponentMgr.cpp.

142 {
143  if ( !iocomponent ) {
144  error()
145  << "io_register (component) received a NULL pointer !" << endmsg;
146  return StatusCode::FAILURE;
147  }
148  const std::string& ioname = iocomponent->name();
149  DEBMSG << "--> io_register(" << ioname << ")" << endmsg;
150  auto itr = m_ioregistry.find (ioname);
151  if ( itr == m_ioregistry.end() ) {
152  DEBMSG << " registering IoComponent \"" << ioname << "\"" << endmsg;
153  iocomponent->addRef(); // ownership...
154  m_ioregistry[ioname] = iocomponent;
155  m_iostack.push_back (iocomponent);
156  } else {
157  info() << "IoComponent[" << iocomponent->name()
158  <<"] already registered @" << (void*)itr->second << endmsg;
159  }
160  return StatusCode::SUCCESS;
161 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
IoRegistry_t m_ioregistry
Registry of IIoComponents.
T end(T...args)
#define DEBMSG
STL class.
T push_back(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T find(T...args)
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:244
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode IoComponentMgr::io_register ( IIoComponent iocomponent,
IIoComponentMgr::IoMode::Type  iomode,
const std::string fname,
const std::string pfn 
)
override

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

Definition at line 172 of file IoComponentMgr.cpp.

176 {
177  if ( 0 == iocomponent ) {
178  return StatusCode::FAILURE;
179  }
180  const std::string& ioname = iocomponent->name();
181 
182  DEBMSG << "--> io_register(" << ioname << ","
183  << ( (iomode== IIoComponentMgr::IoMode::READ) ? "R" : "W" )
184  << "," << fname << ")" << endmsg;
185 
186  if ( !io_hasitem (iocomponent) ) {
187  if ( !io_register (iocomponent).isSuccess() ) {
188  error()
189  << "could not register component [" << iocomponent->name() << "] "
190  << "with the I/O component manager !"
191  << endmsg;
192  return StatusCode::FAILURE;
193  }
194  }
195 
196  pair<iodITR,iodITR> fit = m_cdict.equal_range(iocomponent);
197  if (fit.first != fit.second) {
198  for (iodITR it=fit.first; it != fit.second; ++it) {
199  IoComponentEntry ioe = it->second;
200  if (ioe.m_oldfname == fname) {
201  if (ioe.m_iomode == iomode) {
202  info() << "IoComponent " << ioname
203  << " has already had file " << fname
204  << " registered with i/o mode " << iomode << endmsg;
205  return StatusCode::SUCCESS;
206  } else {
207  warning() << "IoComponent " << ioname
208  << " has already had file " << fname
209  << " registered with a different i/o mode " << ioe.m_iomode
210  << " - now trying " << iomode << endmsg;
211  }
212  }
213  }
214  }
215 
216  // We need to take into account that boost::filesystem::absolute() does not
217  // work for files read from eos, i.e. starting with "root:"
218  std::string tmp_name = pfn.empty()?fname:pfn;
219  bool from_eos = tmp_name.find("root:")==0;
220  IoComponentEntry ioc(fname,(from_eos?tmp_name:boost::filesystem::absolute(tmp_name).string()),iomode);
222 
223  return StatusCode::SUCCESS;
224 }
T empty(T...args)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
IoDict_t::const_iterator iodITR
#define DEBMSG
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
StatusCode io_register(IIoComponent *iocomponent) override
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
T insert(T...args)
T find(T...args)
T equal_range(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual const std::string & name() const =0
Retrieve the name of the instance.
bool io_hasitem(IIoComponent *iocomponent) const override
: check if the registry contains a given IIoComponent
StatusCode IoComponentMgr::io_reinitialize ( )
override

: reinitialize the I/O subsystem.

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

Definition at line 277 of file IoComponentMgr.cpp.

278 {
279  ON_DEBUG {
280  debug() << "--> io_reinitialize()" << endmsg;
281  debug() << "reinitializing I/O subsystem..." << endmsg;
282  debug() << "Listing all monitored entries: " << std::endl;
283  debug() << list() << endmsg;
284  }
285 
286  bool allgood = true;
287  for ( auto& io : m_iostack ) {
288  DEBMSG << " [" << io->name() << "]->io_reinit()..." << endmsg;
289  if ( !io->io_reinit().isSuccess() ) {
290  allgood = false;
291  error() << "problem in [" << io->name()
292  << "]->io_reinit() !" << endmsg;
293  }
294  // we are done with this guy... release it
295  io->release();
296  }
297 
298  // we are done.
299  // FIXME: shall we allow for multiple io_reinitialize ?
300  // m_iostack.clear();
301  // m_ioregistry.clear();
302  // m_cdict.clear();
303 
304  return allgood
307 }
T endl(T...args)
#define DEBMSG
std::string list() const
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
#define ON_DEBUG
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
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:244
StatusCode IoComponentMgr::io_retrieve ( IIoComponent iocomponent,
std::string fname 
)
override

: retrieve the new filename for a given IIoComponent and

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

Definition at line 232 of file IoComponentMgr.cpp.

234 {
235  if ( 0 == iocomponent ) {
236  return StatusCode::FAILURE;
237  }
238 
239  std::string ofname = fname;
240  const std::string& ioname = iocomponent->name();
241 
242  DEBMSG << "--> io_retrieve(" << ioname << "," << fname << ")"
243  << endmsg;
244 
245  iodITR it;
246  if (!findComp(iocomponent,ofname,it)) {
247  DEBMSG << "could not find c: " << ioname << " old_f: " << ofname << endmsg;
248  return StatusCode::FAILURE;
249  } else {
250 
251  IoDict_t::iterator it;
252  for (it = m_cdict.equal_range(iocomponent).first;
253  it != m_cdict.equal_range(iocomponent).second;
254  ++it) {
255 
256  if (it->second.m_oldfname == ofname) {
257  DEBMSG << "retrieving new name for the component " << iocomponent->name()
258  << " old name: " << ofname
259  << ", new name: " << it->second.m_newfname << endmsg;
260  fname = it->second.m_newfname;
261  return StatusCode::SUCCESS;
262  }
263  }
264  }
265 
266  DEBMSG << "Unexpected error! Unable to find entry in the dictionary corresponding to old filename: " << ofname << endmsg;
267  return StatusCode::FAILURE;
268 }
IoDict_t::const_iterator iodITR
#define DEBMSG
STL class.
bool findComp(IIoComponent *, const std::string &, iodITR &) const
T equal_range(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode IoComponentMgr::io_update ( IIoComponent iocomponent,
const std::string old_fname,
const std::string new_fname 
)
override

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

Definition at line 312 of file IoComponentMgr.cpp.

313  {
314 
315  DEBMSG << "--> io_update(" << ioc->name() << ","
316  << old_fname << "," << new_fname << ")" << endmsg;
317 
318  IoDict_t::iterator it;
319  for (it = m_cdict.equal_range(ioc).first;
320  it != m_cdict.equal_range(ioc).second;
321  ++it) {
322 
323  if (it->second.m_oldfname == old_fname) {
324  DEBMSG << "updating " << ioc->name() << " f: " << old_fname << " -> "
325  << new_fname << endmsg;
326  it->second.m_newfname = new_fname;
327  return StatusCode::SUCCESS;
328  }
329  }
330 
331  return StatusCode::FAILURE;
332 
333 }
#define DEBMSG
T equal_range(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode IoComponentMgr::io_update ( IIoComponent iocomponent,
const std::string work_dir 
)
override

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

Definition at line 338 of file IoComponentMgr.cpp.

338  {
339 
340  DEBMSG << "--> io_update(" << ioc->name() << ","
341  << work_dir << ")" << endmsg;
342 
343  IoDict_t::iterator it;
344  for (it = m_cdict.equal_range(ioc).first;
345  it != m_cdict.equal_range(ioc).second;
346  ++it) {
347 
348  switch(it->second.m_iomode) {
350  {
351  it->second.m_newfname = it->second.m_oldabspath;
352  break;
353  }
355  {
356  boost::filesystem::path oldPath(it->second.m_oldfname);
357  if(oldPath.is_relative() &&
358  oldPath.filename()==oldPath.relative_path()) {
359 
360  // Only file name was provided for writing. This is the usual mode of operation
361  // ***
362  // NB. In such cases it would make sense to set newfname=oldfname, however this will break
363  // existing client codes, which assume that newfname contains "/"
364  // Thus we set newfname=workdir/oldfname
365  // ***
366 
367  boost::filesystem::path newfname(work_dir);
368  newfname /= oldPath;
369  it->second.m_newfname = newfname.string();
370  }
371  else {
372  // New name should be the old absolute path
373  it->second.m_newfname = it->second.m_oldabspath;
374  }
375 
376  break;
377  }
378  default:
379  {
380  // Don't know how to deal with either RW or INVALID
381  error() << "Unable to update IoComponent for the mode " << it->second.m_iomode << endmsg;
382  return StatusCode::FAILURE;
383  }
384  }
385 
386  } // for
387 
388  return StatusCode::SUCCESS;
389 
390 }
#define DEBMSG
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T equal_range(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode IoComponentMgr::io_update_all ( const std::string work_dir)
override

: Update all IIoComponents with a new work directory

Definition at line 395 of file IoComponentMgr.cpp.

396 {
397  DEBMSG << "-->io_update_all for the directory " << work_dir << endmsg;
398  bool allgood = true;
399  for ( IoStack_t::iterator io = m_iostack.begin(), ioEnd = m_iostack.end();
400  io != ioEnd;
401  ++io ) {
402  if ( !io_update(*io,work_dir).isSuccess() ) {
403  allgood = false;
404  error() << "problem in [" << (*io)->name()
405  << "]->io_update() !" << endmsg;
406  }
407  }
408  return allgood ? StatusCode::SUCCESS : StatusCode::FAILURE;
409 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
T end(T...args)
#define DEBMSG
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode io_update(IIoComponent *iocomponent, const std::string &old_fname, const std::string &new_fname) override
: allow a IIoComponent to update the contents of the registry with a new file name ...
T begin(T...args)
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:244
std::string IoComponentMgr::list ( ) const
private

Definition at line 488 of file IoComponentMgr.cpp.

488  {
489 
490  ostringstream ost;
491 
492  ost << "Listing all IoComponents (" << m_cdict.size() << "): " << endl;
493  for (const auto& i : m_cdict ) {
494  ost << " " << i.first->name() << " " << i.second << endl;
495  }
496 
497  return ost.str();
498 }
T endl(T...args)
T size(T...args)

Member Data Documentation

IoDict_t IoComponentMgr::m_cdict
private

Definition at line 179 of file IoComponentMgr.h.

std::string IoComponentMgr::m_dict_location
private

location of the python dictionary

Definition at line 182 of file IoComponentMgr.h.

IoRegistry_t IoComponentMgr::m_ioregistry
private

Registry of IIoComponents.

Definition at line 168 of file IoComponentMgr.h.

IoStack_t IoComponentMgr::m_iostack
private

Stack of IIoComponents to properly handle order of registration.

Definition at line 172 of file IoComponentMgr.h.


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