The Gaudi Framework  master (37c0b60a)
IoComponentMgr Class Reference

#include </builds/gaudi/Gaudi/GaudiMP/src/component/IoComponentMgr.h>

Inheritance diagram for IoComponentMgr:
Collaboration diagram for IoComponentMgr:

Classes

struct  IoComponentEntry
 

Public Member Functions

StatusCode initialize () override
 Gaudi Service Implementation. More...
 
StatusCode finalize () override
 
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...
 
std::vector< std::stringio_retrieve (IIoComponent *iocomponent) override
 : retrieve all registered filenames for a given IIoComponent 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...
 
- 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...
 
- 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...
 
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 >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
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
 
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, 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 std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view 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 (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream 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...
 
Gaudi::Property< std::vector< std::string > > m_directio_patterns
 search patterns for special file names (direct I/O protocols) 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
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- 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
std::vector< IAlgTool * > & tools ()
 
 ~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 > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
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" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
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()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service
More...
 

Detailed Description

Definition at line 39 of file IoComponentMgr.h.

Member Typedef Documentation

◆ IoDict_t

◆ iodITR

typedef IoDict_t::const_iterator IoComponentMgr::iodITR
private

Definition at line 172 of file IoComponentMgr.h.

◆ IoRegistry_t

Definition at line 162 of file IoComponentMgr.h.

◆ IoStack_t

Definition at line 166 of file IoComponentMgr.h.

Constructor & Destructor Documentation

◆ IoComponentMgr()

IoComponentMgr::IoComponentMgr ( )
privatedelete

Default constructor:

Member Function Documentation

◆ finalize()

StatusCode IoComponentMgr::finalize ( )
override

Definition at line 86 of file IoComponentMgr.cpp.

86  {
87  DEBMSG << "--> finalize()" << endmsg;
88 
89  for ( auto& io : m_iostack ) { io->release(); }
90 
91  return StatusCode::SUCCESS;
92 }

◆ findComp() [1/3]

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

Definition at line 422 of file IoComponentMgr.cpp.

422  {
423 
424  pit.first = m_cdict.end();
425  pit.second = m_cdict.end();
426 
427  auto itr = m_ioregistry.find( c );
428  return ( itr != m_ioregistry.end() ) && findComp( itr->second, pit );
429 }

◆ findComp() [2/3]

bool IoComponentMgr::findComp ( IIoComponent c,
const std::string f,
iodITR itr 
) const
private

Definition at line 402 of file IoComponentMgr.cpp.

402  {
403 
405  if ( !findComp( c, pit ) ) {
406  itr = pit.first;
407  return false;
408  }
409  return std::any_of( pit.first, pit.second, [&]( IoDict_t::const_reference i ) { return i.second.m_oldfname == f; } );
410 }

◆ findComp() [3/3]

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

Definition at line 414 of file IoComponentMgr.cpp.

414  {
415 
416  pit = m_cdict.equal_range( c );
417  return pit.first != pit.second;
418 }

◆ handle()

void IoComponentMgr::handle ( const Incident i)
override

Definition at line 445 of file IoComponentMgr.cpp.

445  {
446 
448 
449  if ( i.type() == IncidentType::BeginInputFile ) {
450 
451  const FileIncident* fi = dynamic_cast<const FileIncident*>( &i );
452  DEBMSG << "BeginInputFile: s: " << fi->source() << " t: " << fi->type() << " n: " << fi->fileName()
453  << " g: " << fi->fileGuid() << endmsg;
454 
455  if ( findComp( fi->source(), pit ) ) {
456  DEBMSG << " found component: " << endmsg;
457  while ( pit.first != pit.second ) {
458  IIoComponent* c = pit.first->first;
459  IoComponentEntry e = pit.first->second;
460  DEBMSG << " c: " << c->name() << " " << e << endmsg;
461 
462  ++pit.first;
463  }
464  } else {
465  DEBMSG << " could not find component \"" << fi->source() << "\"!" << endmsg;
466  }
467 
468  } else if ( i.type() == IncidentType::BeginOutputFile ) {
469 
470  const FileIncident* fi = dynamic_cast<const FileIncident*>( &i );
471  DEBMSG << "BeginOutputFile: s: " << fi->source() << " t: " << fi->type() << " n: " << fi->fileName()
472  << " g: " << fi->fileGuid() << endmsg;
473 
474  if ( findComp( fi->source(), pit ) ) {
475  DEBMSG << " found component: " << endmsg;
476  while ( pit.first != pit.second ) {
477  IIoComponent* c = pit.first->first;
478  IoComponentEntry e = pit.first->second;
479  DEBMSG << " c: " << c->name() << " " << e << endmsg;
480 
481  ++pit.first;
482  }
483  } else {
484  DEBMSG << " could not find component \"" << fi->source() << "\"!" << endmsg;
485  }
486  }
487 }

◆ initialize()

StatusCode IoComponentMgr::initialize ( )
override

Gaudi Service Implementation.

Definition at line 63 of file IoComponentMgr.cpp.

63  {
64  DEBMSG << "--> initialize()" << endmsg;
65 
66  if ( Service::initialize().isFailure() ) {
67  error() << "Unable to initialize Service base class" << endmsg;
68  return StatusCode::FAILURE;
69  }
70 
71  auto p_incSvc = service<IIncidentSvc>( "IncidentSvc", true );
72 
73  if ( !p_incSvc ) {
74  error() << "unable to get the IncidentSvc" << endmsg;
75  return StatusCode::FAILURE;
76  } else {
77  p_incSvc->addListener( this, IncidentType::BeginOutputFile, 100, true );
78  p_incSvc->addListener( this, IncidentType::BeginInputFile, 100, true );
79  }
80 
81  return StatusCode::SUCCESS;
82 }

◆ io_contains()

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 111 of file IoComponentMgr.cpp.

111  {
112  DEBMSG << "--> io_contains()" << endmsg;
113  if ( 0 == iocomponent ) { return false; }
114  const std::string& ioname = iocomponent->name();
115 
116  DEBMSG << "io_contains: c: " << ioname << " f: " << fname << endmsg;
117 
118  pair<iodITR, iodITR> fit = m_cdict.equal_range( iocomponent );
119  if ( fit.first == fit.second ) {
120  return false;
121  } else {
122  iodITR it;
123  for ( it = fit.first; it != fit.second; ++it ) {
124  IoComponentEntry ioe = it->second;
125  DEBMSG << " " << ioe << endmsg;
126  if ( ioe.m_oldfname == "" ) {
127  error() << "IIoComponent " << ioname << " has empty old filename" << endmsg;
128  return false;
129  } else if ( ioe.m_oldfname == fname ) {
130  return true;
131  }
132  }
133  }
134 
135  return false;
136 }

◆ io_finalize()

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 379 of file IoComponentMgr.cpp.

379  {
380  ON_DEBUG {
381  debug() << "--> io_finalize()" << endmsg;
382  debug() << "finalizing I/O subsystem..." << endmsg;
383  debug() << "Listing all monitored entries: " << std::endl;
384  debug() << list() << endmsg;
385  }
386 
387  bool allgood = true;
388  // reverse iteration to unwind component dependencies
389  for ( IoStack_t::reverse_iterator io = m_iostack.rbegin(), ioEnd = m_iostack.rend(); io != ioEnd; ++io ) {
390  DEBMSG << " [" << ( *io )->name() << "]->io_finalize()..." << endmsg;
391  if ( !( *io )->io_finalize().isSuccess() ) {
392  allgood = false;
393  error() << "problem in [" << ( *io )->name() << "]->io_finalize() !" << endmsg;
394  }
395  }
396 
397  return allgood ? StatusCode::SUCCESS : StatusCode::FAILURE;
398 }

◆ io_hasitem()

bool IoComponentMgr::io_hasitem ( IIoComponent iocomponent) const
override

: check if the registry contains a given IIoComponent

Definition at line 98 of file IoComponentMgr.cpp.

98  {
99  DEBMSG << "--> io_hasitem()" << endmsg;
100  if ( 0 == iocomponent ) { return false; }
101  const std::string& ioname = iocomponent->name();
102  IoRegistry_t::const_iterator io = m_ioregistry.find( ioname );
103  return io != m_ioregistry.end();
104 }

◆ io_register() [1/2]

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 146 of file IoComponentMgr.cpp.

146  {
147  if ( !iocomponent ) {
148  error() << "io_register (component) received a NULL pointer !" << endmsg;
149  return StatusCode::FAILURE;
150  }
151  const std::string& ioname = iocomponent->name();
152  DEBMSG << "--> io_register(" << ioname << ")" << endmsg;
153  auto itr = m_ioregistry.find( ioname );
154  if ( itr == m_ioregistry.end() ) {
155  DEBMSG << " registering IoComponent \"" << ioname << "\"" << endmsg;
156  iocomponent->addRef(); // ownership...
157  m_ioregistry[ioname] = iocomponent;
158  m_iostack.push_back( iocomponent );
159  } else {
160  info() << "IoComponent[" << iocomponent->name() << "] already registered @" << (void*)itr->second << endmsg;
161  }
162  return StatusCode::SUCCESS;
163 }

◆ io_register() [2/2]

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 173 of file IoComponentMgr.cpp.

174  {
175  if ( 0 == iocomponent ) { return StatusCode::FAILURE; }
176  const std::string& ioname = iocomponent->name();
177 
178  DEBMSG << "--> io_register(" << ioname << "," << ( ( iomode == IIoComponentMgr::IoMode::READ ) ? "R" : "W" ) << ","
179  << fname << ")" << endmsg;
180 
181  if ( !io_hasitem( iocomponent ) ) {
182  if ( !io_register( iocomponent ).isSuccess() ) {
183  error() << "could not register component [" << iocomponent->name() << "] "
184  << "with the I/O component manager !" << endmsg;
185  return StatusCode::FAILURE;
186  }
187  }
188 
189  pair<iodITR, iodITR> fit = m_cdict.equal_range( iocomponent );
190  if ( fit.first != fit.second ) {
191  for ( iodITR it = fit.first; it != fit.second; ++it ) {
192  IoComponentEntry ioe = it->second;
193  if ( ioe.m_oldfname == fname ) {
194  if ( ioe.m_iomode == iomode ) {
195  info() << "IoComponent " << ioname << " has already had file " << fname << " registered with i/o mode "
196  << iomode << endmsg;
197  return StatusCode::SUCCESS;
198  } else {
199  warning() << "IoComponent " << ioname << " has already had file " << fname
200  << " registered with a different i/o mode " << ioe.m_iomode << " - now trying " << iomode << endmsg;
201  }
202  }
203  }
204  }
205 
206  // We need to take into account that boost::filesystem::absolute() does not work with direct I/O inputs
207  const std::string& tmp_name = ( pfn.empty() ? fname : pfn );
208  bool special_case =
210  [&]( const std::string& pf ) { return boost::algorithm::contains( tmp_name, pf ); } );
211  IoComponentEntry ioc( fname, ( special_case ? tmp_name : boost::filesystem::absolute( tmp_name ).string() ), iomode );
213 
214  return StatusCode::SUCCESS;
215 }

◆ io_reinitialize()

StatusCode IoComponentMgr::io_reinitialize ( )
override

: reinitialize the I/O subsystem.

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

Definition at line 273 of file IoComponentMgr.cpp.

273  {
274  ON_DEBUG {
275  debug() << "--> io_reinitialize()" << endmsg;
276  debug() << "reinitializing I/O subsystem..." << endmsg;
277  debug() << "Listing all monitored entries: " << std::endl;
278  debug() << list() << endmsg;
279  }
280 
281  bool allgood = true;
282  for ( auto& io : m_iostack ) {
283  DEBMSG << " [" << io->name() << "]->io_reinit()..." << endmsg;
284  if ( !io->io_reinit().isSuccess() ) {
285  allgood = false;
286  error() << "problem in [" << io->name() << "]->io_reinit() !" << endmsg;
287  }
288  }
289 
290  return allgood ? StatusCode::SUCCESS : StatusCode::FAILURE;
291 }

◆ io_retrieve() [1/2]

std::vector< std::string > IoComponentMgr::io_retrieve ( IIoComponent iocomponent)
override

: retrieve all registered filenames for a given IIoComponent

Definition at line 219 of file IoComponentMgr.cpp.

219  {
222 
223  // Find component and copy all registered file names
224  if ( iocomponent != nullptr && findComp( iocomponent, pit ) ) {
225  std::transform( pit.first, pit.second, std::back_inserter( fnames ),
226  []( const auto& itr ) { return itr.second.m_oldfname; } );
227  }
228  return fnames;
229 }

◆ io_retrieve() [2/2]

StatusCode IoComponentMgr::io_retrieve ( IIoComponent iocomponent,
std::string fname 
)
override

: retrieve the new filename for a given IIoComponent and

Parameters
<tt>fname</tt>filename

Definition at line 236 of file IoComponentMgr.cpp.

236  {
237  if ( 0 == iocomponent ) { return StatusCode::FAILURE; }
238 
239  std::string ofname = fname;
240  const std::string& ioname = iocomponent->name();
241 
242  DEBMSG << "--> io_retrieve(" << ioname << "," << fname << ")" << endmsg;
243 
244  iodITR it;
245  if ( !findComp( iocomponent, ofname, it ) ) {
246  DEBMSG << "could not find c: " << ioname << " old_f: " << ofname << endmsg;
247  return StatusCode::FAILURE;
248  } else {
249 
250  IoDict_t::iterator it;
251  for ( it = m_cdict.equal_range( iocomponent ).first; it != m_cdict.equal_range( iocomponent ).second; ++it ) {
252 
253  if ( it->second.m_oldfname == ofname ) {
254  DEBMSG << "retrieving new name for the component " << iocomponent->name() << " old name: " << ofname
255  << ", new name: " << it->second.m_newfname << endmsg;
256  fname = it->second.m_newfname;
257  return StatusCode::SUCCESS;
258  }
259  }
260  }
261 
262  DEBMSG << "Unexpected error! Unable to find entry in the dictionary corresponding to old filename: " << ofname
263  << endmsg;
264  return StatusCode::FAILURE;
265 }

◆ io_update() [1/2]

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 295 of file IoComponentMgr.cpp.

295  {
296 
297  DEBMSG << "--> io_update(" << ioc->name() << "," << old_fname << "," << new_fname << ")" << endmsg;
298 
299  IoDict_t::iterator it;
300  for ( it = m_cdict.equal_range( ioc ).first; it != m_cdict.equal_range( ioc ).second; ++it ) {
301 
302  if ( it->second.m_oldfname == old_fname ) {
303  DEBMSG << "updating " << ioc->name() << " f: " << old_fname << " -> " << new_fname << endmsg;
304  it->second.m_newfname = new_fname;
305  return StatusCode::SUCCESS;
306  }
307  }
308 
309  return StatusCode::FAILURE;
310 }

◆ io_update() [2/2]

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 314 of file IoComponentMgr.cpp.

314  {
315 
316  DEBMSG << "--> io_update(" << ioc->name() << "," << work_dir << ")" << endmsg;
317 
318  IoDict_t::iterator it;
319  for ( it = m_cdict.equal_range( ioc ).first; it != m_cdict.equal_range( ioc ).second; ++it ) {
320 
321  switch ( it->second.m_iomode ) {
323  it->second.m_newfname = it->second.m_oldabspath;
324  break;
325  }
327  boost::filesystem::path oldPath( it->second.m_oldfname );
328  if ( oldPath.is_relative() && oldPath.filename() == oldPath.relative_path() ) {
329 
330  // Only file name was provided for writing. This is the usual mode of operation
331  // ***
332  // NB. In such cases it would make sense to set newfname=oldfname, however this will break
333  // existing client codes, which assume that newfname contains "/"
334  // Thus we set newfname=workdir/oldfname
335  // ***
336 
337  boost::filesystem::path newfname( work_dir );
338  newfname /= oldPath;
339  it->second.m_newfname = newfname.string();
340  } else {
341  // New name should be the old absolute path
342  it->second.m_newfname = it->second.m_oldabspath;
343  }
344 
345  break;
346  }
347  default: {
348  // Don't know how to deal with either RW or INVALID
349  error() << "Unable to update IoComponent for the mode " << it->second.m_iomode << endmsg;
350  return StatusCode::FAILURE;
351  }
352  }
353 
354  } // for
355 
356  return StatusCode::SUCCESS;
357 }

◆ io_update_all()

StatusCode IoComponentMgr::io_update_all ( const std::string work_dir)
override

: Update all IIoComponents with a new work directory

Definition at line 361 of file IoComponentMgr.cpp.

361  {
362  DEBMSG << "-->io_update_all for the directory " << work_dir << endmsg;
363  bool allgood = true;
364  for ( IoStack_t::iterator io = m_iostack.begin(), ioEnd = m_iostack.end(); io != ioEnd; ++io ) {
365  if ( !io_update( *io, work_dir ).isSuccess() ) {
366  allgood = false;
367  error() << "problem in [" << ( *io )->name() << "]->io_update() !" << endmsg;
368  }
369  }
370  return allgood ? StatusCode::SUCCESS : StatusCode::FAILURE;
371 }

◆ list()

std::string IoComponentMgr::list ( ) const
private

Definition at line 433 of file IoComponentMgr.cpp.

433  {
434 
435  ostringstream ost;
436 
437  ost << "Listing all IoComponents (" << m_cdict.size() << "): " << endl;
438  for ( const auto& i : m_cdict ) { ost << " " << i.first->name() << " " << i.second << endl; }
439 
440  return ost.str();
441 }

Member Data Documentation

◆ m_cdict

IoDict_t IoComponentMgr::m_cdict
private

Definition at line 174 of file IoComponentMgr.h.

◆ m_dict_location

std::string IoComponentMgr::m_dict_location
private

location of the python dictionary

Definition at line 177 of file IoComponentMgr.h.

◆ m_directio_patterns

Gaudi::Property<std::vector<std::string> > IoComponentMgr::m_directio_patterns
private
Initial value:
{ this,
"DirectIOPatterns",
{
"://",
},
"Search patterns for direct I/O input names" }

search patterns for special file names (direct I/O protocols)

Definition at line 180 of file IoComponentMgr.h.

◆ m_ioregistry

IoRegistry_t IoComponentMgr::m_ioregistry
private

Registry of IIoComponents.

Definition at line 164 of file IoComponentMgr.h.

◆ m_iostack

IoStack_t IoComponentMgr::m_iostack
private

Stack of IIoComponents to properly handle order of registration.

Definition at line 168 of file IoComponentMgr.h.


The documentation for this class was generated from the following files:
IIoComponentMgr::IoMode::READ
@ READ
Definition: IIoComponentMgr.h:41
IoComponentMgr::findComp
bool findComp(IIoComponent *, const std::string &, iodITR &) const
Definition: IoComponentMgr.cpp:402
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
Incident::source
const std::string & source() const
Access to the source of the incident.
Definition: Incident.h:54
std::string
STL class.
IoComponentMgr::iodITR
IoDict_t::const_iterator iodITR
Definition: IoComponentMgr.h:172
IIoComponent
Definition: IIoComponent.h:26
IoComponentMgr::m_cdict
IoDict_t m_cdict
Definition: IoComponentMgr.h:174
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
std::pair
std::vector< std::string >
std::map::find
T find(T... args)
std::multimap::size
T size(T... args)
std::back_inserter
T back_inserter(T... args)
DEBMSG
#define DEBMSG
Definition: IoComponentMgr.cpp:35
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
IoComponentMgr::io_hasitem
bool io_hasitem(IIoComponent *iocomponent) const override
: check if the registry contains a given IIoComponent
Definition: IoComponentMgr.cpp:98
gaudirun.c
c
Definition: gaudirun.py:525
std::any_of
T any_of(T... args)
FileIncident::fileGuid
const std::string & fileGuid() const
Definition: FileIncident.h:34
std::list::push_back
T push_back(T... args)
IoComponentMgr::io_register
StatusCode io_register(IIoComponent *iocomponent) override
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
Definition: IoComponentMgr.cpp:146
IoComponentMgr::m_ioregistry
IoRegistry_t m_ioregistry
Registry of IIoComponents.
Definition: IoComponentMgr.h:164
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:136
IoComponentMgr::io_update
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
Definition: IoComponentMgr.cpp:295
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:237
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
IoComponentMgr::list
std::string list() const
Definition: IoComponentMgr.cpp:433
std::transform
T transform(T... args)
FileIncident::fileName
const std::string & fileName() const
Definition: FileIncident.h:33
std::list::rend
T rend(T... args)
std::ostringstream
STL class.
std::multimap::equal_range
T equal_range(T... args)
FileIncident
This class is the FileIncident.
Definition: FileIncident.h:27
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
std::endl
T endl(T... args)
IoComponentMgr::m_iostack
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
Definition: IoComponentMgr.h:168
std::list::begin
T begin(T... args)
std::multimap::insert
T insert(T... args)
std::string::empty
T empty(T... args)
std::ostringstream::str
T str(T... args)
Incident::type
const std::string & type() const
Access to the incident type.
Definition: Incident.h:48
std::multimap::end
T end(T... args)
IOTest.end
end
Definition: IOTest.py:125
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
ON_DEBUG
#define ON_DEBUG
Definition: IoComponentMgr.cpp:32
IInterface::addRef
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
IoComponentMgr::m_directio_patterns
Gaudi::Property< std::vector< std::string > > m_directio_patterns
search patterns for special file names (direct I/O protocols)
Definition: IoComponentMgr.h:180
std::list::rbegin
T rbegin(T... args)
IIoComponentMgr::IoMode::WRITE
@ WRITE
Definition: IIoComponentMgr.h:41