| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
IoComponentMgr Class Reference

`#include <src/component/IoComponentMgr.h>`

Inheritance diagram for IoComponentMgr:
[legend]
Collaboration diagram for IoComponentMgr:
[legend]

## 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 &)
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 ()
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::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () 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...
StatusCode | setProperty (const Property &p) override
StatusCode | setProperty (const std::string &s) override
StatusCode | setProperty (const std::string &n, const std::string &v) override
StatusCode | getProperty (Property *p) const override
const Property & | getProperty (const std::string &name) const override
StatusCode | getProperty (const std::string &n, std::string &v) const override
const std::vector< Property * > & | getProperties () const override
bool | hasProperty (const std::string &name) const override
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value 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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties. 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 CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () 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 *, 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 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 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 CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
IntegerProperty | m_outputLevel = MSG::NIL
| Service output level. More...
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. 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 195 of file IoComponentMgr.h.

typedef IoDict_t::const_iterator IoComponentMgr::iodITR
| private

Definition at line 196 of file IoComponentMgr.h.

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

Definition at line 185 of file IoComponentMgr.h.

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

Definition at line 189 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 }
extends< Service, IIoComponentMgr, IIncidentListener >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
IoComponentMgr::m_log
MsgStream m_log
Definition: IoComponentMgr.h:183
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73

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

Definition at line 102 of file IoComponentMgr.cpp.

102 {
103 m_log << MSG::DEBUG << "--> finalize()" << endmsg;
104
105 return StatusCode::SUCCESS;
106 }
MSG::DEBUG
Definition: IMessageSvc.h:18
IoComponentMgr::m_log
MsgStream m_log
Definition: IoComponentMgr.h:183
StatusCode::SUCCESS
Definition: StatusCode.h:30
endmsg
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 480 of file IoComponentMgr.cpp.

481 {
482
483 pair<iodITR,iodITR> pit;
484 if (!findComp(c,pit)) {
485 itr = pit.first;
486 return false;
487 }
488 return std::any_of( pit.first, pit.second,
489 [&](IoDict_t::const_reference i)
490 { return i.second.m_oldfname == f; } );
491
492 }
IoComponentMgr::findComp
bool findComp(IIoComponent *, const std::string &, iodITR &) const
Definition: IoComponentMgr.cpp:480
std::pair
std::any_of
T any_of(T...args)
ana.i
list i
Definition: ana.py:128

bool IoComponentMgr::findComp | ( | IIoComponent * | c,
|  | std::pair< iodITR, iodITR > & | pit
| ) |  | const
| private

Definition at line 497 of file IoComponentMgr.cpp.

497 {
498
499 pit = m_cdict.equal_range(c);
500 return pit.first != pit.second;
501
502 }
std::multimap::equal_range
T equal_range(T...args)
IoComponentMgr::m_cdict
IoDict_t m_cdict
Definition: IoComponentMgr.h:198

bool IoComponentMgr::findComp | ( | const std::string & | c,
|  | std::pair< iodITR, iodITR > & | pit
| ) |  | const
| private

Definition at line 507 of file IoComponentMgr.cpp.

508 {
509
510 pit.first = m_cdict.end();
511 pit.second = m_cdict.end();
512
513 auto itr = m_ioregistry.find(c);
514 return ( itr != m_ioregistry.end() ) && findComp(itr->second, pit);
515 }
IoComponentMgr::m_ioregistry
IoRegistry_t m_ioregistry
Registry of IIoComponents.
Definition: IoComponentMgr.h:187
std::multimap::end
T end(T...args)
IoComponentMgr::findComp
bool findComp(IIoComponent *, const std::string &, iodITR &) const
Definition: IoComponentMgr.cpp:480
std::map::find
T find(T...args)
IoComponentMgr::m_cdict
IoDict_t m_cdict
Definition: IoComponentMgr.h:198

void IoComponentMgr::handle | ( | const Incident & | i | ) |

Definition at line 535 of file IoComponentMgr.cpp.

535 {
536
537 pair<iodITR,iodITR> pit;
538
539
540 if ( i.type() == IncidentType::BeginInputFile ) {
541
542 const FileIncident *fi = dynamic_cast<const FileIncident*> ( &i );
543 DEBMSG << "BeginInputFile: s: " << fi->source() << " t: " << fi->type()
544 << " n: " << fi->fileName() << " g: " << fi->fileGuid()
545 << endmsg;
546
547 if (findComp(fi->source(),pit)) {
548 DEBMSG << " found component: " << endmsg;
549 while (pit.first != pit.second) {
550 IIoComponent* c = pit.first->first;
551 IoComponentEntry e = pit.first->second;
552 DEBMSG << " c: " << c->name() << " " << e << endmsg;
553
554 ++pit.first;
555 }
556 } else {
557 DEBMSG << " could not find component \"" << fi->source()
558 << "\"!" << endmsg;
559 }
560
561
562
563 } else if ( i.type() == IncidentType::BeginOutputFile ) {
564
565 const FileIncident *fi = dynamic_cast<const FileIncident*> ( &i );
566 DEBMSG << "BeginOutputFile: s: " << fi->source() << " t: " << fi->type()
567 << " n: " << fi->fileName() << " g: " << fi->fileGuid()
568 << endmsg;
569
570 if (findComp(fi->source(),pit)) {
571 DEBMSG << " found component: " << endmsg;
572 while (pit.first != pit.second) {
573 IIoComponent* c = pit.first->first;
574 IoComponentEntry e = pit.first->second;
575 DEBMSG << " c: " << c->name() << " " << e << endmsg;
576
577 ++pit.first;
578 }
579 } else {
580 DEBMSG << " could not find component \"" << fi->source()
581 << "\"!" << endmsg;
582 }
583
584 }
585
586 }
IIoComponent
Definition: IIoComponent.h:16
FileIncident
This class is the FileIncident.
Definition: FileIncident.h:17
Incident::type
const std::string & type() const
Access to the incident type.
Definition: Incident.h:41
Incident::source
const std::string & source() const
Access to the source of the incident.
Definition: Incident.h:47
gaudirun.c
tuple c
Definition: gaudirun.py:391
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:24
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
IoComponentMgr::findComp
bool findComp(IIoComponent *, const std::string &, iodITR &) const
Definition: IoComponentMgr.cpp:480
std::pair
FileIncident::fileGuid
const std::string & fileGuid() const
Definition: FileIncident.h:65
FileIncident::fileName
const std::string & fileName() const
Definition: FileIncident.h:64
ana.i
list i
Definition: ana.py:128
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode IoComponentMgr::initialize | ( |  | ) |
| virtual

Gaudi Service Implementation.

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 }
84 m_log.setLevel( m_outputLevel.value() );
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 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:68
Service::m_outputLevel
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309
MSG::DEBUG
Definition: IMessageSvc.h:18
IoComponentMgr::m_log
MsgStream m_log
Definition: IoComponentMgr.h:183
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
MsgStream::setLevel
void setLevel(int level)
Update outputlevel.
Definition: MsgStream.h:106
MSG::ERROR
Definition: IMessageSvc.h:21
Service::service
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:144
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21

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

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 }
MSG::DEBUG
Definition: IMessageSvc.h:18
IoComponentMgr::iodITR
IoDict_t::const_iterator iodITR
Definition: IoComponentMgr.h:196
IoComponentMgr::m_log
MsgStream m_log
Definition: IoComponentMgr.h:183
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:24
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::string
STL class.
std::pair
MSG::ERROR
Definition: IMessageSvc.h:21
std::multimap::equal_range
T equal_range(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IoComponentMgr::m_cdict
IoDict_t m_cdict
Definition: IoComponentMgr.h:198

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

Definition at line 448 of file IoComponentMgr.cpp.

449 {
450
451 m_log << MSG::DEBUG << "--> io_finalize()" << endmsg;
452 m_log << MSG::DEBUG << "finalizing I/O subsystem..." << endmsg;
453
454 if (m_log.level() <= MSG::DEBUG) {
455 m_log << MSG::DEBUG << "Listing all monitored entries: " << std::endl;
456 DEBMSG << list() << endmsg;
457 }
458
459 bool allgood = true;
460 for ( IoStack_t::iterator io = m_iostack.begin(), ioEnd = m_iostack.end();
461 io != ioEnd;
462 ++io ) {
463 m_log << MSG::DEBUG << " [" << (*io)->name() << "]->io_finalize()..."
464 << endmsg;
465 if ( !(*io)->io_finalize().isSuccess() ) {
466 allgood = false;
467 m_log << MSG::ERROR << "problem in [" << (*io)->name()
468 << "]->io_finalize() !" << endmsg;
469 }
470 }
471
472 return allgood
473 ? StatusCode::SUCCESS
474 : StatusCode::FAILURE;
475 }
MsgStream::level
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
MSG::DEBUG
Definition: IMessageSvc.h:18
std::endl
T endl(T...args)
std::list::end
T end(T...args)
IoComponentMgr::m_log
MsgStream m_log
Definition: IoComponentMgr.h:183
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:24
IoComponentMgr::list
std::string list() const
Definition: IoComponentMgr.cpp:520
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::list::begin
T begin(T...args)
MSG::ERROR
Definition: IMessageSvc.h:21
IoComponentMgr::m_iostack
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
Definition: IoComponentMgr.h:191
endmsg
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
| virtual

: check if the registry contains a given `IIoComponent`

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 }
IoComponentMgr::m_ioregistry
IoRegistry_t m_ioregistry
Registry of IIoComponents.
Definition: IoComponentMgr.h:187
std::map::end
T end(T...args)
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:24
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::string
STL class.
std::map::find
T find(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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)

Definition at line 170 of file IoComponentMgr.cpp.

171 {
172 if ( !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 auto 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 }
IoComponentMgr::m_ioregistry
IoRegistry_t m_ioregistry
Registry of IIoComponents.
Definition: IoComponentMgr.h:187
std::map::end
T end(T...args)
IoComponentMgr::m_log
MsgStream m_log
Definition: IoComponentMgr.h:183
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:24
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::string
STL class.
std::list::push_back
T push_back(T...args)
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::map::find
T find(T...args)
MSG::ERROR
Definition: IMessageSvc.h:21
IInterface::addRef
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
MSG::INFO
Definition: IMessageSvc.h:19
IoComponentMgr::m_iostack
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
Definition: IoComponentMgr.h:191
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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)

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 }
std::string::empty
T empty(T...args)
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
IoComponentMgr::iodITR
IoDict_t::const_iterator iodITR
Definition: IoComponentMgr.h:196
IoComponentMgr::m_log
MsgStream m_log
Definition: IoComponentMgr.h:183
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:24
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::string
STL class.
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::pair
std::multimap::insert
T insert(T...args)
std::string::find
T find(T...args)
IoComponentMgr::io_hasitem
virtual bool io_hasitem(IIoComponent *iocomponent) const
: check if the registry contains a given IIoComponent
Definition: IoComponentMgr.cpp:113
MSG::ERROR
Definition: IMessageSvc.h:21
MSG::WARNING
Definition: IMessageSvc.h:20
MSG::INFO
Definition: IMessageSvc.h:19
IoComponentMgr::io_register
virtual StatusCode io_register(IIoComponent *iocomponent)
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
Definition: IoComponentMgr.cpp:170
IIoComponentMgr::IoMode::READ
Definition: IIoComponentMgr.h:33
std::multimap::equal_range
T equal_range(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IoComponentMgr::m_cdict
IoDict_t m_cdict
Definition: IoComponentMgr.h:198

StatusCode IoComponentMgr::io_reinitialize | ( |  | ) |
| virtual

: reinitialize the I/O subsystem.

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

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 ( auto& io : m_iostack ) {
318 m_log << MSG::DEBUG << " [" << io->name() << "]->io_reinit()..." << endmsg;
319 if ( !io->io_reinit().isSuccess() ) {
320 allgood = false;
321 m_log << MSG::ERROR << "problem in [" << io->name()
322 << "]->io_reinit() !" << endmsg;
323 }
324 // we are done with this guy... release it
325 io->release();
326 }
327
328 // we are done.
329 // FIXME: shall we allow for multiple io_reinitialize ?
330 // m_iostack.clear();
331 // m_ioregistry.clear();
332 // m_cdict.clear();
333
334 return allgood
335 ? StatusCode::SUCCESS
336 : StatusCode::FAILURE;
337 }
MsgStream::level
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
MSG::DEBUG
Definition: IMessageSvc.h:18
std::endl
T endl(T...args)
IoComponentMgr::m_log
MsgStream m_log
Definition: IoComponentMgr.h:183
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:24
IoComponentMgr::list
std::string list() const
Definition: IoComponentMgr.cpp:520
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
MSG::ERROR
Definition: IMessageSvc.h:21
IoComponentMgr::m_iostack
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
Definition: IoComponentMgr.h:191
endmsg
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
| ) |  |
| virtual

: retrieve the new filename for a given `IIoComponent` and

Parameters

  <tt>fname</tt> | filename
  <tt>oldfname</tt> | filename

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 }
MSG::DEBUG
Definition: IMessageSvc.h:18
IoComponentMgr::iodITR
IoDict_t::const_iterator iodITR
Definition: IoComponentMgr.h:196
IoComponentMgr::m_log
MsgStream m_log
Definition: IoComponentMgr.h:183
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:24
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::string
STL class.
IoComponentMgr::findComp
bool findComp(IIoComponent *, const std::string &, iodITR &) const
Definition: IoComponentMgr.cpp:480
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::multimap::equal_range
T equal_range(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IoComponentMgr::m_cdict
IoDict_t m_cdict
Definition: IoComponentMgr.h:198

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

Definition at line 342 of file IoComponentMgr.cpp.

343 {
344
345 DEBMSG << "--> io_update(" << ioc->name() << ","
346 << old_fname << "," << new_fname << ")" << endmsg;
347
348 IoDict_t::iterator it;
349 for (it = m_cdict.equal_range(ioc).first;
350 it != m_cdict.equal_range(ioc).second;
351 ++it) {
352
353 if (it->second.m_oldfname == old_fname) {
354 DEBMSG << "updating " << ioc->name() << " f: " << old_fname << " -> "
355 << new_fname << endmsg;
356 it->second.m_newfname = new_fname;
357 return StatusCode::SUCCESS;
358 }
359 }
360
361 return StatusCode::FAILURE;
362
363 }
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:24
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::multimap::equal_range
T equal_range(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IoComponentMgr::m_cdict
IoDict_t m_cdict
Definition: IoComponentMgr.h:198

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

Definition at line 368 of file IoComponentMgr.cpp.

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

StatusCode IoComponentMgr::io_update_all | ( | const std::string & | work_dir | ) |
| virtual

: Update all `IIoComponents` with a new work directory

Definition at line 425 of file IoComponentMgr.cpp.

426 {
427 DEBMSG << "-->io_update_all for the directory " << work_dir << endmsg;
428 bool allgood = true;
429 for ( IoStack_t::iterator io = m_iostack.begin(), ioEnd = m_iostack.end();
430 io != ioEnd;
431 ++io ) {
432 if ( !io_update(*io,work_dir).isSuccess() ) {
433 allgood = false;
434 m_log << MSG::ERROR << "problem in [" << (*io)->name()
435 << "]->io_update() !" << endmsg;
436 }
437 }
438 return allgood ? StatusCode::SUCCESS : StatusCode::FAILURE;
439 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
std::list::end
T end(T...args)
IoComponentMgr::m_log
MsgStream m_log
Definition: IoComponentMgr.h:183
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:24
IoComponentMgr::io_update
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 ...
Definition: IoComponentMgr.cpp:342
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::list::begin
T begin(T...args)
MSG::ERROR
Definition: IMessageSvc.h:21
IoComponentMgr::m_iostack
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
Definition: IoComponentMgr.h:191
endmsg
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 520 of file IoComponentMgr.cpp.

520 {
521
522 ostringstream ost;
523
524 ost << "Listing all IoComponents (" << m_cdict.size() << "): " << endl;
525 for (const auto& i : m_cdict ) {
526 ost << " " << i.first->name() << " " << i.second << endl;
527 }
528
529 return ost.str();
530 }
std::endl
T endl(T...args)
std::ostringstream
STL class.
std::ostringstream::str
T str(T...args)
std::multimap::size
T size(T...args)
ana.i
list i
Definition: ana.py:128
IoComponentMgr::m_cdict
IoDict_t m_cdict
Definition: IoComponentMgr.h:198

## Member Data Documentation

IoDict_t IoComponentMgr::m_cdict
| private

Definition at line 198 of file IoComponentMgr.h.

std::string IoComponentMgr::m_dict_location
| private

location of the python dictionary

Definition at line 201 of file IoComponentMgr.h.

IoRegistry_t IoComponentMgr::m_ioregistry
| private

Registry of `IIoComponents`.

Definition at line 187 of file IoComponentMgr.h.

IoStack_t IoComponentMgr::m_iostack
| private

Stack of `IIoComponents` to properly handle order of registration.

Definition at line 191 of file IoComponentMgr.h.

MsgStream IoComponentMgr::m_log
| mutable private

Definition at line 183 of file IoComponentMgr.h.

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

- GaudiMP/src/component/IoComponentMgr.h
- GaudiMP/src/component/IoComponentMgr.cpp