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