14 #include <boost/filesystem.hpp>
21 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
22 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
24 #define DEBMSG ON_DEBUG debug()
25 #define VERMSG ON_VERBOSE verbose()
39 os <<
"INVALID";
break;
88 if (
service(
"IncidentSvc", p_incSvc,
true).isFailure()) {
92 p_incSvc->
addListener(
this, IncidentType::BeginOutputFile, 100,
true);
93 p_incSvc->
addListener(
this, IncidentType::BeginInputFile, 100,
true);
115 if ( 0 == iocomponent ) {
133 if ( 0 == iocomponent ) {
138 DEBMSG <<
"io_contains: c: " << ioname <<
" f: " << fname <<
endmsg;
141 if (fit.first == fit.second) {
145 for (it=fit.first; it != fit.second; ++it) {
150 <<
" has empty old filename" <<
endmsg;
172 if ( !iocomponent ) {
174 <<
"io_register (component) received a NULL pointer !" <<
endmsg;
178 DEBMSG <<
"--> io_register(" << ioname <<
")" <<
endmsg;
181 DEBMSG <<
" registering IoComponent \"" << ioname <<
"\"" <<
endmsg;
187 <<
"] already registered @" << (
void*)itr->second << endmsg;
206 if ( 0 == iocomponent ) {
211 DEBMSG <<
"--> io_register(" << ioname <<
","
213 <<
"," << fname <<
")" <<
endmsg;
218 <<
"could not register component [" << iocomponent->
name() <<
"] "
219 <<
"with the I/O component manager !"
226 if (fit.first != fit.second) {
227 for (
iodITR it=fit.first; it != fit.second; ++it) {
232 <<
" has already had file " << fname
233 <<
" registered with i/o mode " << iomode <<
endmsg;
237 <<
" has already had file " << fname
238 <<
" registered with a different i/o mode " << ioe.
m_iomode
239 <<
" - now trying " << iomode <<
endmsg;
248 bool from_eos = tmp_name.
find(
"root:")==0;
249 IoComponentEntry ioc(fname,(from_eos?tmp_name:boost::filesystem::absolute(tmp_name).
string()),iomode);
264 if ( 0 == iocomponent ) {
271 m_log <<
MSG::DEBUG <<
"--> io_retrieve(" << ioname <<
"," << fname <<
")"
275 if (!
findComp(iocomponent,ofname,it)) {
276 DEBMSG <<
"could not find c: " << ioname <<
" old_f: " << ofname <<
endmsg;
280 IoDict_t::iterator it;
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;
295 DEBMSG <<
"Unexpected error! Unable to find entry in the dictionary corresponding to old filename: " << ofname <<
endmsg;
319 if ( !io->io_reinit().isSuccess() ) {
322 <<
"]->io_reinit() !" <<
endmsg;
345 DEBMSG <<
"--> io_update(" << ioc->
name() <<
","
346 << old_fname <<
"," << new_fname <<
")" <<
endmsg;
348 IoDict_t::iterator it;
353 if (it->second.m_oldfname == old_fname) {
354 DEBMSG <<
"updating " << ioc->
name() <<
" f: " << old_fname <<
" -> "
356 it->second.m_newfname = new_fname;
370 DEBMSG <<
"--> io_update(" << ioc->
name() <<
","
371 << work_dir <<
")" <<
endmsg;
373 IoDict_t::iterator it;
378 switch(it->second.m_iomode) {
381 it->second.m_newfname = it->second.m_oldabspath;
387 if(oldPath.is_relative() &&
388 oldPath.filename()==oldPath.relative_path()) {
399 it->second.m_newfname = newfname.string();
403 it->second.m_newfname = it->second.m_oldabspath;
411 m_log <<
MSG::ERROR <<
"Unable to update IoComponent for the mode " << it->second.m_iomode <<
endmsg;
427 DEBMSG <<
"-->io_update_all for the directory " << work_dir <<
endmsg;
435 <<
"]->io_update() !" <<
endmsg;
465 if ( !(*io)->io_finalize().isSuccess() ) {
468 <<
"]->io_finalize() !" <<
endmsg;
489 [&](IoDict_t::const_reference
i)
490 { return i.second.m_oldfname == f; } );
500 return pit.first != pit.second;
524 ost <<
"Listing all IoComponents (" <<
m_cdict.
size() <<
"): " <<
endl;
526 ost <<
" " <<
i.first->name() <<
" " <<
i.second <<
endl;
540 if ( i.
type() == IncidentType::BeginInputFile ) {
549 while (pit.first != pit.second) {
557 DEBMSG <<
" could not find component \"" << fi->
source()
563 }
else if ( i.
type() == IncidentType::BeginOutputFile ) {
572 while (pit.first != pit.second) {
580 DEBMSG <<
" could not find component \"" << fi->
source()
StatusCode initialize() override
IntegerProperty m_outputLevel
Service output level.
virtual bool io_contains(IIoComponent *iocomponent, const std::string &fname) const
: check if the registry contains a given IIoComponent and that component had
This class is the FileIncident.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
const std::string & type() const
Access to the incident type.
MSG::Level level()
Retrieve output level.
This file contains the class definition for the FileIncident class.
const std::string & source() const
Access to the source of the incident.
bool isSuccess() const
Test for a status code of SUCCESS.
IoDict_t::const_iterator iodITR
IoRegistry_t m_ioregistry
Registry of IIoComponents.
void handle(const Incident &)
#define DECLARE_COMPONENT(type)
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 ...
virtual const std::string & name() const =0
Retrieve the name of the instance.
bool findComp(IIoComponent *, const std::string &, iodITR &) const
This class is used for returning status codes from appropriate routines.
virtual StatusCode io_reinitialize()
: reinitialize the I/O subsystem.
virtual StatusCode io_finalize()
: finalize the I/O subsystem.
IoComponentMgr()
Default constructor:
virtual StatusCode initialize()
Gaudi Service Implementation.
const TYPE & value() const
explicit conversion
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
IIoComponentMgr::IoMode::Type m_iomode
Base class for all Incidents (computing events).
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
void setLevel(int level)
Update outputlevel.
virtual bool io_hasitem(IIoComponent *iocomponent) const
: check if the registry contains a given IIoComponent
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
const std::string & fileGuid() const
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.
virtual ~IoComponentMgr()
Destructor:
virtual StatusCode io_retrieve(IIoComponent *iocomponent, std::string &fname)
: retrieve the new filename for a given IIoComponent and
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
virtual StatusCode io_register(IIoComponent *iocomponent)
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
virtual StatusCode finalize()
const std::string & fileName() const
Type
the list of available types for ntuples
virtual StatusCode io_update_all(const std::string &work_dir)
: Update all IIoComponents with a new work directory
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
The interface implemented by the IncidentSvc service.