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()) {
115 if ( 0 == iocomponent ) {
118 const std::string& ioname = iocomponent->
name();
119 IoRegistry_t::const_iterator io =
m_ioregistry.find (ioname);
130 const std::string& fname)
const
133 if ( 0 == iocomponent ) {
136 const std::string& ioname = iocomponent->
name();
138 DEBMSG <<
"io_contains: c: " << ioname <<
" f: " << fname <<
endmsg;
140 pair<iodITR,iodITR> fit =
m_cdict.equal_range(iocomponent);
141 if (fit.first == fit.second) {
145 for (it=fit.first; it != fit.second; ++it) {
150 <<
" has empty old filename" <<
endmsg;
172 if ( 0 == iocomponent ) {
174 <<
"io_register (component) received a NULL pointer !" <<
endmsg;
177 const std::string& ioname = iocomponent->
name();
178 DEBMSG <<
"--> io_register(" << ioname <<
")" <<
endmsg;
179 IoRegistry_t::iterator itr =
m_ioregistry.find (ioname);
181 DEBMSG <<
" registering IoComponent \"" << ioname <<
"\"" <<
endmsg;
187 <<
"] already registered @" << (
void*)itr->second << endmsg;
203 const std::string& fname,
204 const std::string& pfn)
206 if ( 0 == iocomponent ) {
209 const std::string& ioname = iocomponent->
name();
211 DEBMSG <<
"--> io_register(" << ioname <<
","
213 <<
"," << fname <<
")" <<
endmsg;
218 <<
"could not register component [" << iocomponent->
name() <<
"] "
219 <<
"with the I/O component manager !"
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) {
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;
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) );
264 if ( 0 == iocomponent ) {
268 std::string ofname = fname;
269 const std::string& ioname = iocomponent->
name();
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;
281 for (it =
m_cdict.equal_range(iocomponent).first;
282 it !=
m_cdict.equal_range(iocomponent).second;
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;
322 if ( !(*io)->io_reinit().isSuccess() ) {
325 <<
"]->io_reinit() !" <<
endmsg;
346 const std::string& new_fname) {
348 DEBMSG <<
"--> io_update(" << ioc->
name() <<
","
349 << old_fname <<
"," << new_fname <<
")" <<
endmsg;
351 IoDict_t::iterator it;
352 for (it =
m_cdict.equal_range(ioc).first;
353 it !=
m_cdict.equal_range(ioc).second;
356 if (it->second.m_oldfname == old_fname) {
357 DEBMSG <<
"updating " << ioc->
name() <<
" f: " << old_fname <<
" -> "
359 it->second.m_newfname = new_fname;
373 DEBMSG <<
"--> io_update(" << ioc->
name() <<
","
374 << work_dir <<
")" <<
endmsg;
376 IoDict_t::iterator it;
377 for (it =
m_cdict.equal_range(ioc).first;
378 it !=
m_cdict.equal_range(ioc).second;
381 switch(it->second.m_iomode) {
384 it->second.m_newfname = it->second.m_oldabspath;
390 if(oldPath.is_relative() &&
391 oldPath.filename()==oldPath.relative_path()) {
402 it->second.m_newfname = newfname.string();
406 it->second.m_newfname = it->second.m_oldabspath;
414 m_log <<
MSG::ERROR <<
"Unable to update IoComponent for the mode " << it->second.m_iomode <<
endmsg;
430 DEBMSG <<
"-->io_update_all for the directory " << work_dir <<
endmsg;
438 <<
"]->io_update() !" <<
endmsg;
468 if ( !(*io)->io_finalize().isSuccess() ) {
471 <<
"]->io_finalize() !" <<
endmsg;
486 pair<iodITR,iodITR> pit;
492 for (itr = pit.first; itr != pit.second; ++itr) {
493 if (itr->second.m_oldfname == f) {
509 if (pit.first == pit.second) {
521 std::pair<iodITR,iodITR>& pit)
const {
526 IoRegistry_t::const_iterator itr =
m_ioregistry.find(c);
541 ost <<
"Listing all IoComponents (" <<
m_cdict.size() <<
"): " << endl;
543 ost <<
" " << it->first->name() <<
" " << it->second
555 pair<iodITR,iodITR> pit;
567 while (pit.first != pit.second) {
575 DEBMSG <<
" could not find component \"" << fi->
source()
590 while (pit.first != pit.second) {
598 DEBMSG <<
" could not find component \"" << fi->
source()
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 &)
Inform that a new incident has occurred.
#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:
const std::string BeginOutputFile
a new output file has been created
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
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
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.
Templated class to add the standard messaging functionalities.
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()
Finalize (from INITIALIZED to CONFIGURED).
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.
const std::string BeginInputFile
a new input file has been started