| The Gaudi Framework v28r2p1 (f1a77ff4)

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

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

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

`#include <src/FileMgr/FileMgr.h>`

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

## Public Member Functions
| ~FileMgr () override
StatusCode | initialize () override
StatusCode | finalize () override
void | handle (const Incident &) override
StatusCode | regHandler (FileHdlr) override
StatusCode | hasHandler (const IoTech &) const override
StatusCode | deregHandler (const IoTech &) override
StatusCode | getHandler (const IoTech &, FileHdlr &) const override
StatusCode | getHandler (const std::string &, FileHdlr &) const override
int | getFileAttr (const std::string &, std::vector< const FileAttr * > &) const override
StatusCode | getFileAttr (const Fd, const FileAttr *&) const override
StatusCode | getFileAttr (void *, const FileAttr *&) const override
void | listHandlers () const override
void | listFiles () const override
virtual void | listActions () const
virtual void | listSuppression () const
int | getFiles (std::vector< std::string > &, bool onlyOpen=true) const override
int | getFiles (std::vector< const Io::FileAttr * > &, bool onlyOpen=true) const override
int | getFiles (const Io::IoTech &, std::vector< std::string > &, bool onlyOpen=true) const override
int | getFiles (const Io::IoTech &, std::vector< const Io::FileAttr * > &, bool onlyOpen=true) const override
int | getFiles (const Io::IoTech &, const Io::IoFlags &, std::vector< std::string > &, bool onlyOpen=true) const override
int | getFiles (const Io::IoTech &, const Io::IoFlags &, std::vector< const Io::FileAttr * > &, bool onlyOpen=true) const override
int | getFd (std::vector< Fd > &) const override
int | getFd (const Io::IoTech &, std::vector< Io::Fd > &) const override
int | getFd (const Io::IoTech &, const Io::IoFlags &, std::vector< Io::Fd > &) const override
const std::string & | fname (const Io::Fd &) const override
const std::string & | fname (void *) const override
Io::Fd | fd (const std::string &) const override
Io::Fd | fd (void *) const override
void * | fptr (const std::string &) const override
void * | fptr (const Io::Fd &) const override
int | getLastError (std::string &) const override
Io::open_t | open (const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &fd, void *&ptr, const std::string &desc="", const bool shared=false) override
Io::open_t | open (const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &, const std::string &desc="", const bool shared=false) override
Io::open_t | open (const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, void *&, const std::string &desc="", const bool shared=false) override
Io::close_t | close (const Fd, const std::string &caller) override
Io::close_t | close (void *, const std::string &caller) override
Io::reopen_t | reopen (const Fd, const IoFlags &, const std::string &caller) override
Io::reopen_t | reopen (void *, const IoFlags &, const std::string &caller) override
StatusCode | regAction (Io::bfcn_action_t, const Io::Action &, const std::string &desc="") override
StatusCode | regAction (Io::bfcn_action_t, const Io::Action &, const Io::IoTech &, const std::string &desc="") override
void | suppressAction (const std::string &) override
void | suppressAction (const std::string &, const Io::Action &) override
Public Member Functions inherited from extends< Service, IFileMgr, 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...
| 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 >
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 PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| PropertyHolder ()=default
| ~PropertyHolder () override=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (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::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
Gaudi::Details::PropertyBase * | declareProperty (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::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &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 (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
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::pair< Io::bfcn_action_t, std::string > | bfcn_desc_t
typedef std::map< Io::Action, std::list< bfcn_desc_t > > | actionMap
typedef std::multimap< std::string, FileAttr * > | fileMap
typedef std::map< std::string, int > | supMap

## Private Member Functions
virtual Io::open_t | open (const IoTech &, const std::string &caller, const std::string &fname, const std::string &desc, const IoFlags &, Fd &, void *&, const bool shared)
StatusCode | execAction (Io::FileAttr *, const std::string &, const Io::Action &) const
StatusCode | execActs (Io::FileAttr *, const std::string &, const Io::Action &, const actionMap &m) const
bool | accessMatch (const Io::IoFlags &, const Io::IoFlags &, bool strict=false) const
bool | isShareable (const std::string &filename, const Io::IoFlags &) const

## Private Attributes
Gaudi::Property< std::string > | m_logfile {this, "LogFile"}
Gaudi::Property< bool > | m_printSummary {this, "PrintSummary", false}
Gaudi::Property< bool > | m_loadRootHandler {this, "LoadROOTHandler", true}
Gaudi::Property< bool > | m_loadPosixHandler {this, "LoadPOSIXHandler", true}
Gaudi::Property< std::string > | m_ssl_proxy {this, "TSSL_UserProxy", "X509"}
Gaudi::Property< std::string > | m_ssl_cert {this, "TSSL_CertDir", "X509"}
fileMap | m_files
std::map< IoTech, FileHdlr > | m_handlers
std::map< Fd, FileAttr * > | m_descriptors
std::vector< std::unique_ptr< FileAttr > > | m_attr
std::vector< FileAttr * > | m_oldFiles
std::map< IoTech, actionMap > | m_actions
supMap | m_supMap
std::string | m_lastErrS
int | m_lastErr
std::unique_ptr< RootFileHandler > | m_rfh
std::unique_ptr< POSIXFileHandler > | m_pfh

## Additional Inherited Members
Public Types inherited from extends< Service, IFileMgr, 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 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
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
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
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"}
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()"}
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service. More...

## Detailed Description

Definition at line 31 of file FileMgr.h.

## Member Typedef Documentation

typedef std::map<Io::Action, std::list<bfcn_desc_t> > FileMgr::actionMap
| private

Definition at line 123 of file FileMgr.h.

typedef std::pair<Io::bfcn_action_t, std::string> FileMgr::bfcn_desc_t
| private

Definition at line 122 of file FileMgr.h.

typedef std::multimap<std::string, FileAttr*> FileMgr::fileMap
| private

Definition at line 130 of file FileMgr.h.

typedef std::map<std::string, int> FileMgr::supMap
| private

Definition at line 141 of file FileMgr.h.

## Constructor & Destructor Documentation

FileMgr::~FileMgr | ( |  | ) |
| override

Definition at line 78 of file FileMgr.cpp.

78 {
79 // Where do the new-ed FileAttr get deleted?
80 // they get pushed into m_descriptors, but m_attr is presumably
81 // where they _also_ should be pushed in order to track ownership...
82 }

## Member Function Documentation

bool FileMgr::accessMatch | ( | const Io::IoFlags & | fold,
|  | const Io::IoFlags & | fnew,
|  | bool | strict = `false`
| ) |  | const
| private

Definition at line 1462 of file FileMgr.cpp.

1463 {
1464
1465 ON_VERBOSE
1466 verbose() << "accessMatch old: " << fold
1467 << " new: " << fnew
1468 << endmsg;
1469
1470 return ( ((fold == Io::READ) && (fnew == Io::READ)) ||
1471 ( (fold & Io::WRITE) != 0 && (fnew & Io::WRITE) != 0) ||
1472 ( (fold & Io::RDWR) != 0 && (fnew & Io::RDWR) != 0) ) ;
1473
1474 }
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:129
Io::RDWR
Definition: IFileMgr.h:28
Io::WRITE
Definition: IFileMgr.h:27
Io::READ
Definition: IFileMgr.h:26
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:12
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Io::close_t FileMgr::close | ( | const Fd | ,
|  | const std::string & | caller
| ) |  |
| override

close_t FileMgr::close | ( | void * | vp,
|  | const std::string & | caller
| ) |  |
| override

Definition at line 648 of file FileMgr.cpp.

648 {
649
650 // return codes:
651 // < 0 : error condition
652 // 0 : actual close of one file
653 // > 0 : shared file, removed from list, no actual close, returns
654 // number of shared files still open.
655
656 ON_VERBOSE
657 verbose() << "close(" << vp << ")"
658 << endmsg;
659
660 close_t r = -1;
661
662 auto itr = std::find_if( std::begin(m_files), std::end(m_files),
663 [&](fileMap::const_reference i ) { return i.second->fptr()==vp; } );
664
665 if (itr == m_files.end()) {
666 error() << "unknown file ptr \"" << vp
667 << "\" when calling close()"
668 << endmsg;
669 return r;
670 }
671
672 IoTech tech = itr->second->tech();
673
674 FileHdlr fh;
675
676 if (getHandler(tech,fh).isFailure()) {
677 return r;
678 }
679 if (! fh.b_closeP_fcn) {
680 error() << "no close(" << tech << ",void*) function registered"
681 << endmsg;
682 return -1;
683 }
684
685 FileAttr *fa = itr->second;
686
687 // find how many times this file is open
688 pair<fileMap::const_iterator, fileMap::const_iterator> fitr =
689 m_files.equal_range(fa->name());
690
691 int i = std::count_if( fitr.first, fitr.second, [&](fileMap::const_reference f)
692 { return f.second->fptr()==vp; } );
693
694 ON_VERBOSE
695 verbose() << " ref count: " << i
696 << endmsg;
697
698 if (i > 1 && fa->isShared()) {
699 // file open multiple times in shared access. don't do the actual close
700 ON_DEBUG
701 debug() << "closing file " << fa->name() << " opened "
702 << i << " times with fptr " << vp << endmsg;
703 m_files.erase(itr);
704
705 r = i-1;
706
707 } else if (i == 1 || (i>1 && !fa->isShared()) ) {
708 ON_DEBUG
709 debug() << "closing: " << *fa << endmsg;
710
711 try {
712 r = fh.b_closeP_fcn(vp);
713 } catch (const std::bad_function_call& err) {
714 error() << "when calling close handler for " << tech
715 << " on file " << fa->name()
716 << " caught " << err.what() << endmsg;
717 execAction(fa, caller, CLOSE_ERR ).ignore();
718 return -1;
719 } catch (...) {
720 error() << "when calling close handler for " << tech
721 << " on file " << fa->name()
722 << " caught an unknown exception." << endmsg;
723 execAction(fa, caller, CLOSE_ERR ).ignore();
724 return -1;
725 }
726
727 if (r < 0) {
728 warning()
729 << "close of file with ptr \"" << vp
730 << "\", name: \"" << fa->name()
731 << "\", tech: \"" << tech << "\" failed"
732 << endmsg;
733
734 return r;
735 }
736
737 m_files.erase(itr);
738
739 } else {
740 // this should never happen!
741 error()
742 << "ref count: " << i << " < 0 when closing " << fa
743 << ". This should never happen"
744 << endmsg;
745 return -1;
746
747 }
748
749 fa->fd(-1);
750 fa->flags(INVALID);
751 fa->isOpen(false);
752 fa->fptr(0);
753 m_oldFiles.push_back( fa );
754
755
756 // exec all callbacks
757 if (execAction(fa, caller, CLOSE).isFailure()) {
758 warning()
759 << "at least one close callback action failed"
760 << endmsg;
761 }
762
763 return r;
764
765 }
Io::IoTech
IoTech
Definition: IFileMgr.h:150
Io::INVALID
Definition: IFileMgr.h:36
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:190
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:129
Io::FileAttr::isOpen
bool isOpen() const
Definition: IFileMgr.h:191
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1383
std::end
T end(T...args)
Io::FileAttr::fd
Fd fd() const
Definition: IFileMgr.h:184
CommonMessagingBase::err
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:114
Io::CLOSE
Definition: IFileMgr.h:292
Io::CLOSE_ERR
Definition: IFileMgr.h:295
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
std::vector::push_back
T push_back(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
std::bad_function_call
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:120
Io::FileAttr::isShared
bool isShared() const
Definition: IFileMgr.h:192
std::bad_function_call::what
T what(T...args)
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
std::multimap::erase
T erase(T...args)
Io::FileHdlr
Definition: IFileMgr.h:263
Io::FileHdlr::b_closeP_fcn
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:268
std::count_if
T count_if(T...args)
std::pair
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::find_if
T find_if(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
std::begin
T begin(T...args)
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:106
Io::FileAttr::flags
IoFlags flags() const
Definition: IFileMgr.h:188
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:12
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
Io::close_t
int close_t
Definition: IFileMgr.h:253
Io::FileAttr
Definition: IFileMgr.h:174

StatusCode FileMgr::deregHandler | ( | const IoTech & |  | ) |
| override

Definition at line 288 of file FileMgr.cpp.

288 {
289 FileHdlr hdlr;
290
291 auto itr = m_handlers.find(tech);
292 if (itr == m_handlers.end()) {
293 error() << "Can't de-register tech " << tech
294 << " as it hasn't been registered!"
295 << endmsg;
296 return StatusCode::FAILURE;
297 }
298
299 m_handlers.erase(itr);
300 return StatusCode::SUCCESS;
301
302 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode::FAILURE
Definition: StatusCode.h:29
std::map::end
T end(T...args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:133
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
std::map::erase
T erase(T...args)
Io::FileHdlr
Definition: IFileMgr.h:263
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 FileMgr::execAction | ( | Io::FileAttr * | fa,
|  | const std::string & | caller,
|  | const Io::Action & | a
| ) |  | const
| private

Definition at line 1383 of file FileMgr.cpp.

1384 {
1385
1386 Io::IoTech tech = fa->tech();
1387
1388 StatusCode s1,s2;
1389
1390 auto itr = m_actions.find(Io::UNKNOWN);
1391
1392 if (itr != m_actions.end() && !itr->second.empty() ) {
1393 s1 = execActs(fa, caller, a, itr->second);
1394 }
1395
1396 itr = m_actions.find(tech);
1397 if (itr != m_actions.end() && !itr->second.empty() ) {
1398 s2 = execActs(fa, caller, a, itr->second);
1399 }
1400
1401 return (s1.isFailure() || s2.isFailure()) ? StatusCode::FAILURE
1402 : StatusCode::SUCCESS;
1403 }
Io::IoTech
IoTech
Definition: IFileMgr.h:150
StatusCode::SUCCESS
Definition: StatusCode.h:30
HiveAlgSequencer.s1
s1
Definition: HiveAlgSequencer.py:27
StatusCode::FAILURE
Definition: StatusCode.h:29
HiveAlgSequencer.s2
s2
Definition: HiveAlgSequencer.py:28
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
FileMgr::execActs
StatusCode execActs(Io::FileAttr *, const std::string &, const Io::Action &, const actionMap &m) const
Definition: FileMgr.cpp:1408
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:187
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:139
Io::UNKNOWN
Definition: IFileMgr.h:151

StatusCode FileMgr::execActs | ( | Io::FileAttr * | fa,
|  | const std::string & | caller,
|  | const Io::Action & | a,
|  | const actionMap & | m
| ) |  | const
| private

Definition at line 1408 of file FileMgr.cpp.

1409 {
1410
1411 auto mitr = m.find(a);
1412
1413 if (mitr == m.end() || mitr->second.empty()) {
1414 return StatusCode::SUCCESS;
1415 }
1416
1417 ON_DEBUG
1418 debug()
1419 << "executing " << mitr->second.size() << " " << a
1420 << " actions on "
1421 << *fa << " from "
1422 << caller
1423 << endmsg;
1424
1425
1426 bool fail(false);
1427
1428 auto it2 = m_supMap.find(fa->name());
1429 if (it2 != m_supMap.end()) {
1430 if (get_bit(it2->second,a) || get_bit(it2->second,Io::INVALID_ACTION)) {
1431 ON_DEBUG
1432 debug() << " --> suppressing callback action for "
1433 << a
1434 << endmsg;
1435 return StatusCode::SUCCESS;
1436 }
1437 }
1438
1439 for (const auto& itr : mitr->second ) {
1440
1441 ON_DEBUG
1442 debug() << "executing "
1443 << itr.second << endmsg;
1444
1445 if ( (((itr.first))(fa,caller)).isFailure() ) {
1446 warning() << "execution of "
1447 << itr.second << " on " << *fa
1448 << " failed during " << a << " action"
1449 << endmsg;
1450 fail = true;
1451 }
1452
1453 }
1454
1455 return fail ? StatusCode::FAILURE : StatusCode::SUCCESS;
1456
1457 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode::FAILURE
Definition: StatusCode.h:29
FileMgr::m_supMap
supMap m_supMap
Definition: FileMgr.h:142
std::map::end
T end(T...args)
Io::INVALID_ACTION
Definition: IFileMgr.h:297
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:120
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:93
std::map::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Io::Fd FileMgr::fd | ( | const std::string & | fname | ) | const
| override

Definition at line 1198 of file FileMgr.cpp.

1198 {
1199
1200 auto fitr = m_files.equal_range(fname);
1201 auto itr = std::find_if( fitr.first, fitr.second, [](fileMap::const_reference f) {
1202 return f.second->fd() != -1;
1203 } );
1204 return itr!=fitr.second ? itr->second->fd() : -1 ;
1205 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::find_if
T find_if(T...args)
std::multimap::equal_range
T equal_range(T...args)

Io::Fd FileMgr::fd | ( | void * | fptr | ) | const
| override

Definition at line 1210 of file FileMgr.cpp.

1210 {
1211
1212 auto itr = std::find_if(m_files.begin(),m_files.end(),[&](fileMap::const_reference f) {
1213 return f.second->fptr() == fptr;
1214 } );
1215 return itr!=m_files.end() ? itr->second->fd() : -1 ;
1216 }
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:190
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::multimap::end
T end(T...args)
Io::FileAttr::fd
Fd fd() const
Definition: IFileMgr.h:184
std::find_if
T find_if(T...args)
std::multimap::begin
T begin(T...args)
FileMgr::fptr
void * fptr(const std::string &) const override
Definition: FileMgr.cpp:1221

StatusCode FileMgr::finalize | ( |  | ) |
| override

Definition at line 166 of file FileMgr.cpp.

166 {
167 ON_VERBOSE
168 verbose() << "FileMgr::finalize()" << endmsg;
169
170
171 if (m_printSummary || msgLevel(MSG::DEBUG)) {
172 listHandlers();
173 listFiles();
174 listActions();
175 listSuppression();
176 }
177
178
179 if (!m_files.empty()) {
180 auto& log = warning();
181 log << "At finalize, the following files remained open:" << endl;
182 for (const auto& itr : m_files) log << *(itr.second) << endl;
183 log << endmsg;
184 }
185
186 if (m_logfile.value() != "") {
187 std::ofstream ofs;
188 ofs.open(m_logfile.value().c_str());
189 if (!ofs) {
190 error() << "Unable to open output file \"" << m_logfile.value()
191 << "\" for writing"
192 << endmsg;
193 } else {
194 ON_DEBUG
195 debug() << "Saving log to \"" << m_logfile.value() << "\""
196 << endmsg;
197 for (const auto& itr : m_files) {
198 ofs << itr.second->name() << " " << itr.second->tech() << " "
199 << itr.second->desc() << " " << itr.second->iflags() << endl;
200 }
201
202 set<FileAttr> fs;
203 for (const auto& it2 : m_oldFiles) fs.insert(*it2);
204 for (const auto& it3 : fs ) {
205 ofs << it3.name() << " " << it3.tech() << " " << it3.desc()
206 << " " << it3.iflags()
207 << ( it3.isShared() ? " SHARED" : "" )
208 << endl;
209 }
210 ofs.close();
211 }
212 }
213
214 // cleanup FileAttrs
215 m_attr.clear();
216
217 m_rfh.reset();
218 m_pfh.reset();
219
220
221 StatusCode status = Service::finalize();
222
223 ON_DEBUG
224 if ( status.isSuccess() )
225 debug() << "Service finalised successfully" << endmsg;
226
227 return status;
228
229 }
FileMgr::m_attr
std::vector< std::unique_ptr< FileAttr > > m_attr
Definition: FileMgr.h:135
FileMgr::listHandlers
void listHandlers() const override
Definition: FileMgr.cpp:1315
FileMgr::listFiles
void listFiles() const override
Definition: FileMgr.cpp:1243
std::multimap::empty
T empty(T...args)
std::ofstream::open
T open(T...args)
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:174
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:129
MSG::DEBUG
Definition: IMessageSvc.h:18
std::endl
T endl(T...args)
FileMgr::m_rfh
std::unique_ptr< RootFileHandler > m_rfh
Definition: FileMgr.h:147
FileMgr::listActions
virtual void listActions() const
Definition: FileMgr.cpp:1354
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
std::ofstream
STL class.
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:120
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::ofstream::close
T close(T...args)
FileMgr::m_pfh
std::unique_ptr< POSIXFileHandler > m_pfh
Definition: FileMgr.h:148
std::unique_ptr::reset
T reset(T...args)
std::vector::clear
T clear(T...args)
std::set::insert
T insert(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::set
STL class.
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
FileMgr::listSuppression
virtual void listSuppression() const
Definition: FileMgr.cpp:1504
FileMgr::m_printSummary
Gaudi::Property< bool > m_printSummary
Definition: FileMgr.h:111
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
FileMgr::m_logfile
Gaudi::Property< std::string > m_logfile
Definition: FileMgr.h:110
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:135
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:12
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi.Configuration.log
log
Definition: Configuration.py:13

const std::string & FileMgr::fname | ( | const Io::Fd & | fd | ) | const
| override

Definition at line 1175 of file FileMgr.cpp.

1175 {
1176
1177 auto itr = std::find_if( std::begin(m_files), std::end(m_files),
1178 [&](fileMap::const_reference f) { return f.second->fd() == fd; } );
1179 return (itr!=std::end(m_files)) ? itr->second->name() : s_empty;
1180
1181 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::end
T end(T...args)
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1198
std::find_if
T find_if(T...args)
std::begin
T begin(T...args)

const std::string & FileMgr::fname | ( | void * | vp | ) | const
| override

Definition at line 1186 of file FileMgr.cpp.

1186 {
1187
1188 auto itr = std::find_if( m_files.begin(), m_files.end(),
1189 [&](fileMap::const_reference f) {
1190 return f.second->fptr() == vp;
1191 });
1192 return itr!=m_files.end() ? itr->second->name() : s_empty;
1193 }
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:190
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::multimap::end
T end(T...args)
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
std::find_if
T find_if(T...args)
std::multimap::begin
T begin(T...args)

void * FileMgr::fptr | ( | const std::string & | fname | ) | const
| override

Definition at line 1221 of file FileMgr.cpp.

1221 {
1222 auto fitr = m_files.equal_range(fname);
1223 auto itr = std::find_if( fitr.first, fitr.second, [](fileMap::const_reference f) -> bool {
1224 return f.second->fptr();
1225 } );
1226 return itr!=fitr.second ? itr->second->fptr() : nullptr;
1227 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::find_if
T find_if(T...args)
std::multimap::equal_range
T equal_range(T...args)

void * FileMgr::fptr | ( | const Io::Fd & | fd | ) | const
| override

Definition at line 1232 of file FileMgr.cpp.

1232 {
1233
1234 auto itr = std::find_if(m_files.begin(),m_files.end(),[&](fileMap::const_reference f) {
1235 return f.second->fd() == fd;
1236 } );
1237 return itr!=m_files.end() ? itr->second->fptr() : nullptr;
1238 }
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:190
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::multimap::end
T end(T...args)
Io::FileAttr::fd
Fd fd() const
Definition: IFileMgr.h:184
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1198
std::find_if
T find_if(T...args)
std::multimap::begin
T begin(T...args)

int FileMgr::getFd | ( | std::vector< Fd > & |  | ) | const
| override

int FileMgr::getFd | ( | const Io::IoTech & | tech,
|  | std::vector< Io::Fd > & | fd
| ) |  | const
| override

Definition at line 1142 of file FileMgr.cpp.

1142 {
1143
1144 if (tech == UNKNOWN) return getFd( fd );
1145
1146 fd.clear();
1147 transform_if( std::begin(m_descriptors), std::end(m_descriptors), std::back_inserter(fd),
1148 select1st,
1149 [&](const std::pair<Fd,FileAttr*>& d) { return d.second->tech()==tech; } );
1150
1151 return fd.size();
1152
1153 }
std::end
T end(T...args)
FileMgr::m_descriptors
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:134
std::vector::clear
T clear(T...args)
std::pair
std::vector::size
T size(T...args)
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
Io::UNKNOWN
Definition: IFileMgr.h:151
FileMgr::getFd
int getFd(std::vector< Fd > &) const override

int FileMgr::getFd | ( | const Io::IoTech & | tech,
|  | const Io::IoFlags & | flags,
|  | std::vector< Io::Fd > & | fd
| ) |  | const
| override

Definition at line 1160 of file FileMgr.cpp.

1160 {
1161
1162 fd.clear();
1163 transform_if( m_descriptors.begin(), m_descriptors.end(),
1164 std::back_inserter(fd), select1st,
1165 [&](const std::pair<Fd,FileAttr*>& d) {
1166 return (d.second->tech() == tech || tech == UNKNOWN) &&
1167 ( d.second->flags() == flags );
1168 } );
1169 return fd.size();
1170 }
std::map::end
T end(T...args)
FileMgr::m_descriptors
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:134
std::vector::clear
T clear(T...args)
std::pair
std::vector::size
T size(T...args)
std::map::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
Io::UNKNOWN
Definition: IFileMgr.h:151

int FileMgr::getFileAttr | ( | const std::string & | fname,
|  | std::vector< const FileAttr * > & | fa
| ) |  | const
| override

Definition at line 937 of file FileMgr.cpp.

937 {
938
939 fa.clear();
940
941 auto fitr = m_files.equal_range(fname);
942 std::transform( fitr.first, fitr.second, std::back_inserter(fa), select2nd );
943
944 std::copy_if( std::begin(m_oldFiles), std::end(m_oldFiles),
945 std::back_inserter(fa), [&](const FileAttr* f ) { return f->name() == fname; } );
946
947 return fa.size();
948
949 }
std::copy_if
T copy_if(T...args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::end
T end(T...args)
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::vector::size
T size(T...args)
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:1175
std::transform
T transform(T...args)
std::multimap::equal_range
T equal_range(T...args)
Io::FileAttr
Definition: IFileMgr.h:174

StatusCode FileMgr::getFileAttr | ( | const Fd | ,
|  | const FileAttr *& |
| ) |  | const
| override

StatusCode FileMgr::getFileAttr | ( | void * | vp,
|  | const FileAttr *& | fa
| ) |  | const
| override

Definition at line 977 of file FileMgr.cpp.

977 {
978
979 auto i = std::find_if( std::begin(m_files), std::end(m_files),
980 [&](fileMap::const_reference f) { return f.second->fptr() == vp; } );
981 if (i != std::end(m_files)) {
982 fa = i->second;
983 return StatusCode::SUCCESS;
984 }
985
986 auto j = std::find_if( std::begin(m_oldFiles), std::end(m_oldFiles),
987 [&](const FileAttr* f) { return f->fptr() == vp; } );
988 if (j != std::end(m_oldFiles)) {
989 fa = *j;
990 return StatusCode::SUCCESS;
991 }
992
993 return StatusCode::FAILURE;
994
995 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode::FAILURE
Definition: StatusCode.h:29
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:190
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::end
T end(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::find_if
T find_if(T...args)
std::begin
T begin(T...args)
Io::FileAttr
Definition: IFileMgr.h:174

int FileMgr::getFiles | ( | std::vector< std::string > & | files,
|  | bool | onlyOpen = `true`
| ) |  | const
| override

Definition at line 1000 of file FileMgr.cpp.

1000 {
1001
1002 files.clear();
1003 auto not_in_files = [&](const std::string& i) { return std::none_of( std::begin(files), std::end(files),
1004 [&](const std::string& j) { return j==i; } ); };
1005 transform_copy_if( std::begin(m_files), std::end(m_files), std::back_inserter(files),
1006 to_name,
1007 not_in_files );
1008 if (!op) {
1009 transform_copy_if( std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files),
1010 to_name,
1011 not_in_files );
1012 }
1013 return files.size();
1014 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::end
T end(T...args)
std::string
STL class.
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::vector::size
T size(T...args)
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
std::none_of
T none_of(T...args)

int FileMgr::getFiles | ( | std::vector< const Io::FileAttr * > & | files,
|  | bool | onlyOpen = `true`
| ) |  | const
| override

Definition at line 1019 of file FileMgr.cpp.

1019 {
1020
1021 files.clear();
1022 std::transform(std::begin(m_files), std::end(m_files), std::back_inserter(files),
1023 select2nd );
1024 if (!op) {
1025 std::copy(std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files));
1026 }
1027 return files.size();
1028
1029 }
std::copy
T copy(T...args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::end
T end(T...args)
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::vector::size
T size(T...args)
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
std::transform
T transform(T...args)

int FileMgr::getFiles | ( | const Io::IoTech & | tech,
|  | std::vector< std::string > & | files,
|  | bool | onlyOpen = `true`
| ) |  | const
| override

Definition at line 1034 of file FileMgr.cpp.

1034 {
1035
1036 if (tech == UNKNOWN) return getFiles(files,op);
1037
1038 files.clear();
1039 transform_if( std::begin(m_files), std::end(m_files), std::back_inserter(files),
1040 to_name,
1041 [&](fileMap::const_reference f) { return f.second->tech() == tech &&
1042 std::none_of( std::begin(files), std::end(files), [&](const std::string& j) { return j==f.first; } ); } );
1043
1044 if (!op) {
1045 transform_if( std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files),
1046 to_name,
1047 [&](const FileAttr* f) { return f->tech() == tech &&
1048 std::none_of( std::begin(files), std::end(files), [&](const std::string& j) { return j == f->name(); } ) ; } );
1049 }
1050 return files.size();
1051
1052 }
FileMgr::getFiles
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:1000
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::end
T end(T...args)
std::string
STL class.
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::vector::size
T size(T...args)
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:187
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
std::none_of
T none_of(T...args)
Io::UNKNOWN
Definition: IFileMgr.h:151
Io::FileAttr
Definition: IFileMgr.h:174

int FileMgr::getFiles | ( | const Io::IoTech & | tech,
|  | std::vector< const Io::FileAttr * > & | files,
|  | bool | onlyOpen = `true`
| ) |  | const
| override

Definition at line 1057 of file FileMgr.cpp.

1058 {
1059
1060 if (tech == UNKNOWN) return getFiles(files,op);
1061
1062 auto matches_tech = [&](const FileAttr* f) { return f->tech()==tech; } ;
1063
1064 files.clear();
1065 transform_copy_if( std::begin(m_files), std::end(m_files), std::back_inserter(files),
1066 select2nd, matches_tech );
1067 if (!op) {
1068 std::copy_if( std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files),
1069 matches_tech );
1070 }
1071
1072 return files.size();
1073
1074 }
std::copy_if
T copy_if(T...args)
FileMgr::getFiles
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:1000
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::end
T end(T...args)
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::vector::size
T size(T...args)
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
Io::UNKNOWN
Definition: IFileMgr.h:151
Io::FileAttr
Definition: IFileMgr.h:174

int FileMgr::getFiles | ( | const Io::IoTech & | tech,
|  | const Io::IoFlags & | flags,
|  | std::vector< std::string > & | files,
|  | bool | onlyOpen = `true`
| ) |  | const
| override

Definition at line 1079 of file FileMgr.cpp.

1080 {
1081
1082 files.clear();
1083
1084 auto not_in_files = [&](const std::string& n) { return std::none_of( std::begin(files), std::end(files),
1085 [&](const std::string& f) { return f==n; } ); };
1086 auto matches_tech_and_flags = [&](const FileAttr* f) { return ( f->tech() == tech || tech == UNKNOWN ) && f->flags() == flags ; } ;
1087
1088 transform_if( std::begin(m_files), std::end(m_files), std::back_inserter(files),
1089 to_name,
1090 [&](fileMap::const_reference f) { return matches_tech_and_flags( f.second ) && not_in_files( f.first ); } );
1091 if (!op) {
1092 transform_if( std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files),
1093 to_name,
1094 [&](const FileAttr* f) { return matches_tech_and_flags(f) && not_in_files(f->name()); } );
1095 }
1096
1097 return files.size();
1098
1099 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::end
T end(T...args)
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:217
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::vector::size
T size(T...args)
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
std::none_of
T none_of(T...args)
Io::UNKNOWN
Definition: IFileMgr.h:151
Io::FileAttr
Definition: IFileMgr.h:174

int FileMgr::getFiles | ( | const Io::IoTech & | tech,
|  | const Io::IoFlags & | flags,
|  | std::vector< const Io::FileAttr * > & | files,
|  | bool | onlyOpen = `true`
| ) |  | const
| override

Definition at line 1103 of file FileMgr.cpp.

1104 {
1105
1106 files.clear();
1107
1108 auto matches_tech_and_flags = [&](const FileAttr* f) { return ( f->tech() == tech || tech == UNKNOWN )
1109 && f->flags() == flags ; } ;
1110
1111 transform_copy_if( std::begin(m_files), std::end(m_files), std::back_inserter(files),
1112 select2nd,
1113 matches_tech_and_flags );
1114 if (!op) {
1115 std::copy_if( std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files),
1116 matches_tech_and_flags );
1117 }
1118
1119 return files.size();
1120 }
std::copy_if
T copy_if(T...args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::end
T end(T...args)
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::vector::size
T size(T...args)
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
Io::UNKNOWN
Definition: IFileMgr.h:151
Io::FileAttr
Definition: IFileMgr.h:174

StatusCode FileMgr::getHandler | ( | const IoTech & | ,
|  | FileHdlr & |
| ) |  | const
| override

StatusCode FileMgr::getHandler | ( | const std::string & | fname,
|  | Io::FileHdlr & | hdlr
| ) |  | const
| override

Definition at line 1284 of file FileMgr.cpp.

1284 {
1285
1286 auto fitr = m_files.equal_range(fname);
1287 if (fitr.first == fitr.second) {
1288 error()
1289 << "no file \"" << fname << "\" registered. Cannot determine tech"
1290 << endmsg;
1291 return StatusCode::FAILURE;
1292 }
1293
1294 auto itr = fitr.first;
1295 IoTech tech = itr->second->tech();
1296
1297 ++itr;
1298 while( itr != fitr.second ) {
1299 if ( itr->second->tech() != tech ) {
1300 error()
1301 << "multiple technologies registered for file \"" << fname
1302 << "\". Cannot determine handler" << endmsg;
1303 return StatusCode::FAILURE;
1304 }
1305 ++itr;
1306 }
1307
1308 return getHandler(tech,hdlr);
1309
1310 }
Io::IoTech
IoTech
Definition: IFileMgr.h:150
StatusCode::FAILURE
Definition: StatusCode.h:29
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
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

int FileMgr::getLastError | ( | std::string & | err | ) | const
| override

Definition at line 1258 of file FileMgr.cpp.

1258 {
1259
1260 err = m_lastErrS;
1261 return m_lastErr;
1262
1263 }
FileMgr::m_lastErrS
std::string m_lastErrS
Definition: FileMgr.h:144
FileMgr::m_lastErr
int m_lastErr
Definition: FileMgr.h:145

void FileMgr::handle | ( | const Incident & |  | ) |
| override

Definition at line 234 of file FileMgr.cpp.

234 {
235
236 }

StatusCode FileMgr::hasHandler | ( | const IoTech & |  | ) | const
| override

Definition at line 306 of file FileMgr.cpp.

306 {
307
308 auto itr = m_handlers.find(tech);
309 return (itr != m_handlers.end()) ? StatusCode::SUCCESS : StatusCode::FAILURE;
310
311 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode::FAILURE
Definition: StatusCode.h:29
std::map::end
T end(T...args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:133
std::map::find
T find(T...args)

StatusCode FileMgr::initialize | ( |  | ) |
| override

Definition at line 87 of file FileMgr.cpp.

87 {
88 StatusCode status = Service::initialize();
89
90 if (status.isFailure()) {
91
92 ON_DEBUG
93 debug() << "Failed to initialize the base class (Service)"
94 << endmsg;
95 return status;
96 }
97
98 ON_VERBOSE
99 verbose() << "Initializing FileMgr" << endmsg;
100
101 if (m_loadRootHandler.value()) {
102
103 // setup file handler for ROOT
104
105 msgSvc()->setOutputLevel( "RootFileHandler", m_outputLevel.value());
106 m_rfh.reset( new RootFileHandler(msgSvc(), m_ssl_proxy, m_ssl_cert) );
107
108 auto rfh = m_rfh.get(); // used in the lambdas to avoid capturing 'this'
109 Io::FileHdlr hdlr(Io::ROOT,
110 [rfh](const std::string& n, const Io::IoFlags& f,
111 const std::string& desc, Io::Fd& fd,
112 void*& ptr) -> Io::open_t {
113 return rfh->openRootFile(n, f, desc, fd, ptr);
114 },
115 [rfh](void* ptr) -> Io::close_t {
116 return rfh->closeRootFile(ptr);
117 },
118 [rfh](void* ptr, const Io::IoFlags& f) -> Io::reopen_t {
119 return rfh->reopenRootFile(ptr, f);
120 });
121
122 if (regHandler(hdlr).isFailure()) {
123 error()
124 << "unable to register ROOT file handler with FileMgr"
125 << endmsg;
126 }
127 }
128
129 if (m_loadPosixHandler.value()) {
130
131 // setup file handler for POSIX
132
133 msgSvc()->setOutputLevel( "POSIXFileHandler", m_outputLevel.value());
134 m_pfh.reset( new POSIXFileHandler(msgSvc()) );
135
136 auto pfh = m_pfh.get(); // used in the lambdas to avoid capturing 'this'
137 Io::FileHdlr hdlp(Io::POSIX,
138 [pfh](const std::string& n, const Io::IoFlags& f,
139 const std::string& desc, Io::Fd& fd,
140 void*& ptr) -> Io::open_t {
141 return pfh->openPOSIXFile(n, f, desc, fd, ptr);
142 },
143 [pfh](Io::Fd fd) -> Io::close_t {
144 return pfh->closePOSIXFile(fd);
145 },
146 [pfh](Io::Fd fd, const Io::IoFlags& f) -> Io::reopen_t {
147 return pfh->reopenPOSIXFile(fd, f);
148 });
149
150 if (regHandler(hdlp).isFailure()) {
151 error()
152 << "unable to register ROOT file handler with FileMgr"
153 << endmsg;
154 }
155 }
156
157
158
159 return StatusCode::SUCCESS;
160
161 }
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Service.h:214
FileMgr::regHandler
StatusCode regHandler(FileHdlr) override
Definition: FileMgr.cpp:241
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
StatusCode::SUCCESS
Definition: StatusCode.h:30
Io::ROOT
Definition: IFileMgr.h:153
Io::reopen_t
int reopen_t
Definition: IFileMgr.h:254
Io::Fd
int Fd
Definition: IFileMgr.h:172
FileMgr::m_loadPosixHandler
Gaudi::Property< bool > m_loadPosixHandler
Definition: FileMgr.h:113
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:129
Io::open_t
int open_t
Definition: IFileMgr.h:252
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
POSIXFileHandler
Definition: POSIXFileHandler.h:17
FileMgr::m_rfh
std::unique_ptr< RootFileHandler > m_rfh
Definition: FileMgr.h:147
std::string
STL class.
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1198
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:217
FileMgr::m_loadRootHandler
Gaudi::Property< bool > m_loadRootHandler
Definition: FileMgr.h:112
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
Io::POSIX
Definition: IFileMgr.h:152
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Io::IoFlags
Definition: IFileMgr.h:39
Io::FileHdlr
Definition: IFileMgr.h:263
RootFileHandler
Definition: RootFileHandler.h:17
FileMgr::m_pfh
std::unique_ptr< POSIXFileHandler > m_pfh
Definition: FileMgr.h:148
std::unique_ptr::reset
T reset(T...args)
std::unique_ptr::get
T get(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:70
FileMgr::m_ssl_proxy
Gaudi::Property< std::string > m_ssl_proxy
Definition: FileMgr.h:115
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:12
FileMgr::m_ssl_cert
Gaudi::Property< std::string > m_ssl_cert
Definition: FileMgr.h:116
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Io::close_t
int close_t
Definition: IFileMgr.h:253
IMessageSvc::setOutputLevel
virtual void setOutputLevel(int new_level)=0
Set new global output level threshold.

bool FileMgr::isShareable | ( | const std::string & | filename,
|  | const Io::IoFlags & |
| ) |  | const
| private

void FileMgr::listActions | ( |  | ) | const
| virtual

Definition at line 1354 of file FileMgr.cpp.

1354 {
1355
1356 info() << "listing registered actions" << endl;
1357
1358 for (const auto& iit : m_actions) {
1359 Io::IoTech t = iit.first;
1360 const actionMap& m = iit.second;
1361
1362 if (!m.empty()) {
1363 info() << " --- Tech: ";
1364 if (t == Io::UNKNOWN) {
1365 info() << "ALL ---" << endl;
1366 } else {
1367 info() << t << " ---" << endl;
1368 }
1369 for (const auto& iia : m ) {
1370 for (const auto& it2 : iia.second ) {
1371 info() << " " << iia.first << " "
1372 << it2.second << endl;
1373 }
1374 }
1375 }
1376 }
1377 info() << endmsg;
1378 }
Io::IoTech
IoTech
Definition: IFileMgr.h:150
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:123
std::endl
T endl(T...args)
FileMgr::actionMap
std::map< Io::Action, std::list< bfcn_desc_t > > actionMap
Definition: FileMgr.h:123
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:93
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:139
Io::UNKNOWN
Definition: IFileMgr.h:151
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

void FileMgr::listFiles | ( |  | ) | const
| override

Definition at line 1243 of file FileMgr.cpp.

1243 {
1244
1245 info() << "listing registered files ["
1246 << (m_files.size() + m_oldFiles.size() )
1247 << "]:" << endl;
1248
1249 for (auto& itr : m_files ) info() << itr.second << endl;
1250 for (auto& it2 : m_oldFiles ) info() << *it2 << endl;
1251
1252 info() << endmsg;
1253 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:123
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
std::endl
T endl(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::multimap::size
T size(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

void FileMgr::listHandlers | ( |  | ) | const
| override

Definition at line 1315 of file FileMgr.cpp.

1315 {
1316
1317 info()
1318 << "Listing registered handlers:" << endl;
1319
1320 for (const auto& itr : m_handlers ) info() << " " << itr.first << endl;
1321 info() << endmsg;
1322
1323 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:123
std::endl
T endl(T...args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:133
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

void FileMgr::listSuppression | ( |  | ) | const
| virtual

Definition at line 1504 of file FileMgr.cpp.

1504 {
1505
1506 if (m_supMap.empty()) return;
1507
1508 info() << "listing suppressed file actions" << endl;
1509
1510 for (auto it2=m_supMap.begin(); it2 != m_supMap.end(); ++it2) {
1511 info() << " " << it2->first;
1512 if (get_bit(it2->second, Io::INVALID_ACTION)) {
1513 info() << " ALL" << endl;
1514 } else {
1515 for (int i=0; i<Io::INVALID_ACTION; ++i) {
1516 if (get_bit(it2->second,i)) { info() << " " << (Io::Action)i; }
1517 }
1518 info() << endl;
1519 }
1520 }
1521
1522 info() << endmsg;
1523 }
std::map::empty
T empty(T...args)
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:123
FileMgr::m_supMap
supMap m_supMap
Definition: FileMgr.h:142
std::endl
T endl(T...args)
std::map::end
T end(T...args)
Io::INVALID_ACTION
Definition: IFileMgr.h:297
Io::Action
Action
Definition: IFileMgr.h:290
std::map::begin
T begin(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

open_t FileMgr::open | ( | const Io::IoTech & | tech,
|  | const std::string & | caller,
|  | const std::string & | fname,
|  | const Io::IoFlags & | flags,
|  | Io::Fd & | fd,
|  | void *& | ptr,
|  | const std::string & | desc = `""`,
|  | const bool | shared = `false`
| ) |  |
| override

Definition at line 316 of file FileMgr.cpp.

319 {
320
321 return open(tech, caller, fname, desc, flags, fd, ptr, sh);
322
323 }
FileMgr::open
Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &fd, void *&ptr, const std::string &desc="", const bool shared=false) override
Definition: FileMgr.cpp:316
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1198

open_t FileMgr::open | ( | const Io::IoTech & | tech,
|  | const std::string & | caller,
|  | const std::string & | fname,
|  | const Io::IoFlags & | flags,
|  | Io::Fd & | fd,
|  | const std::string & | desc = `""`,
|  | const bool | shared = `false`
| ) |  |
| override

Definition at line 327 of file FileMgr.cpp.

330 {
331
332 void* dummy(0);
333 return open(tech, caller, fname, desc, flags, fd, dummy, sh);
334
335 }
FileMgr::open
Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &fd, void *&ptr, const std::string &desc="", const bool shared=false) override
Definition: FileMgr.cpp:316
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1198

open_t FileMgr::open | ( | const Io::IoTech & | tech,
|  | const std::string & | caller,
|  | const std::string & | fname,
|  | const Io::IoFlags & | flags,
|  | void *& | ptr,
|  | const std::string & | desc = `""`,
|  | const bool | shared = `false`
| ) |  |
| override

Definition at line 339 of file FileMgr.cpp.

342 {
343
344 Fd dummy(-1);
345 return open(tech, caller, fname, desc, flags, dummy, ptr, sh);
346
347 }
Io::Fd
int Fd
Definition: IFileMgr.h:172
FileMgr::open
Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &fd, void *&ptr, const std::string &desc="", const bool shared=false) override
Definition: FileMgr.cpp:316

virtual Io::open_t FileMgr::open | ( | const IoTech & | ,
|  | const std::string & | caller,
|  | const std::string & | fname,
|  | const std::string & | desc,
|  | const IoFlags & | ,
|  | Fd & | ,
|  | void *& | ,
|  | const bool | shared
| ) |  |
| private virtual

StatusCode FileMgr::regAction | ( | Io::bfcn_action_t | bf,
|  | const Io::Action & | a,
|  | const std::string & | desc = `""`
| ) |  |
| override

Definition at line 1328 of file FileMgr.cpp.

1328 {
1329
1330 return regAction(bf,a,Io::UNKNOWN,d);
1331
1332 }
FileMgr::regAction
StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &desc="") override
Definition: FileMgr.cpp:1328
Io::UNKNOWN
Definition: IFileMgr.h:151

StatusCode FileMgr::regAction | ( | Io::bfcn_action_t | bf,
|  | const Io::Action & | a,
|  | const Io::IoTech & | t,
|  | const std::string & | desc = `""`
| ) |  |
| override

Definition at line 1337 of file FileMgr.cpp.

1338 {
1339
1340 ON_DEBUG
1341 debug() << "registering " << a << " action "
1342 << System::typeinfoName(bf.target_type())
1343 << " for tech " << t << endmsg;
1344
1345 m_actions[t][a].emplace_back(bf, (!d.empty()) ? d
1346 : System::typeinfoName(bf.target_type()));
1347 return StatusCode::SUCCESS;
1348
1349 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
std::function::target_type
T target_type(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:139
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode FileMgr::regHandler | ( | FileHdlr | fh | ) |
| override

Definition at line 241 of file FileMgr.cpp.

241 {
242
243 IoTech tech = fh.tech;
244
245 if (m_handlers.find(tech) != m_handlers.end()) {
246 warning()
247 << "Handler for IoTech " << tech << " already registered. Ignoring."
248 << endmsg;
249 return StatusCode::SUCCESS;
250 }
251
252 if ( ! fh.b_open_fcn ) {
253 error()
254 << "open handler for tech " << tech << " is NULL"
255 << endmsg;
256 return StatusCode::FAILURE;
257 }
258
259 if ( ! fh.b_close_fcn && ! fh.b_closeP_fcn ) {
260 error()
261 << "no close handler for tech " << tech << " registered"
262 << endmsg;
263 return StatusCode::FAILURE;
264 }
265
266 if ( ! fh.b_reopen_fcn && ! fh.b_reopenP_fcn) {
267 error()
268 << "no reopen handler for tech " << tech << " registered"
269 << endmsg;
270 return StatusCode::FAILURE;
271 }
272
273
274 ON_DEBUG
275 debug()
276 << "Successfully registered handler for tech \"" << tech << "\""
277 << endmsg;
278
279 m_handlers[tech] = fh;
280
281 return StatusCode::SUCCESS;
282
283 }
Io::IoTech
IoTech
Definition: IFileMgr.h:150
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode::FAILURE
Definition: StatusCode.h:29
Io::FileHdlr::b_reopen_fcn
bfcn_reopen_t b_reopen_fcn
Definition: IFileMgr.h:269
std::map::end
T end(T...args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:133
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:120
Io::FileHdlr::b_close_fcn
bfcn_close_t b_close_fcn
Definition: IFileMgr.h:267
Io::FileHdlr::b_closeP_fcn
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:268
Io::FileHdlr::b_reopenP_fcn
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:270
std::map::find
T find(T...args)
Io::FileHdlr::b_open_fcn
bfcn_open_t b_open_fcn
Definition: IFileMgr.h:266
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
Io::FileHdlr::tech
IoTech tech
Definition: IFileMgr.h:264
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Io::reopen_t FileMgr::reopen | ( | const Fd | ,
|  | const IoFlags & | ,
|  | const std::string & | caller
| ) |  |
| override

reopen_t FileMgr::reopen | ( | void * | vp,
|  | const IoFlags & | flags,
|  | const std::string & | caller
| ) |  |
| override

Definition at line 857 of file FileMgr.cpp.

857 {
858 ON_VERBOSE
859 verbose() << "reopen(" << vp << "," << flags
860 << "," << caller << ")"
861 << endmsg;
862
863 reopen_t r = -1;
864
865 auto itr = std::find_if( std::begin(m_files), std::end(m_files),
866 [&](fileMap::const_reference f) {
867 return f.second->fptr() == vp ; } );
868 if (itr == m_files.end()) {
869 error()
870 << "unregistered file ptr \"" << vp
871 << "\" when calling reopen()"
872 << endmsg;
873 return r;
874 }
875
876 FileAttr *fa = itr->second;
877 FileHdlr fh;
878 IoTech tech = fa->tech();
879
880 if (getHandler(tech,fh).isFailure()) {
881 return r;
882 }
883
884 if ( ! fh.b_reopenP_fcn ) {
885 error() << "no reopen(" << tech << ",void*) function registered"
886 << endmsg;
887 return -1;
888 }
889
890 try {
891 r = fh.b_reopenP_fcn(vp,flags);
892 } catch (const std::bad_function_call& err) {
893 error() << "when calling reopen handler for " << tech
894 << " on file " << fa->name() << " with flags "
895 << flags
896 << " caught " << err.what() << endmsg;
897 return -1;
898 } catch (...) {
899 error() << "when calling reopen handler for " << tech
900 << " on file " << fa->name() << " with flags "
901 << flags
902 << " caught an unknown exception." << endmsg;
903 return -1;
904 }
905
906 if (r < 0) {
907 warning()
908 << "reopen of file with ptr \"" << vp
909 << "\", name: \"" << fa->name()
910 << "\", tech: \"" << tech
911 << "\", flags: \"" << flags << "\" failed"
912 << endmsg;
913
914 execAction(fa, caller, Io::REOPEN_ERR ).ignore();
915
916 return r;
917
918 }
919
920 fa->isOpen(true);
921 fa->flags(flags);
922
923 // exec all callbacks
924 if (execAction(fa, caller, Io::REOPEN).isFailure()) {
925 warning()
926 << "at least one reopen callback action failed"
927 << endmsg;
928 }
929
930 return r;
931
932 }
Io::IoTech
IoTech
Definition: IFileMgr.h:150
Io::REOPEN
Definition: IFileMgr.h:293
Io::reopen_t
int reopen_t
Definition: IFileMgr.h:254
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:129
Io::FileAttr::isOpen
bool isOpen() const
Definition: IFileMgr.h:191
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1383
std::end
T end(T...args)
Io::REOPEN_ERR
Definition: IFileMgr.h:296
CommonMessagingBase::err
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:114
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
std::bad_function_call
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:120
std::bad_function_call::what
T what(T...args)
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
Io::FileHdlr
Definition: IFileMgr.h:263
Io::FileHdlr::b_reopenP_fcn
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:270
std::find_if
T find_if(T...args)
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:187
std::begin
T begin(T...args)
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:106
Io::FileAttr::flags
IoFlags flags() const
Definition: IFileMgr.h:188
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:12
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Io::FileAttr
Definition: IFileMgr.h:174

void FileMgr::suppressAction | ( | const std::string & | f | ) |
| override

Definition at line 1479 of file FileMgr.cpp.

1479 {
1480
1481 return suppressAction(f,Io::INVALID_ACTION);
1482
1483 }
FileMgr::suppressAction
void suppressAction(const std::string &) override
Definition: FileMgr.cpp:1479
Io::INVALID_ACTION
Definition: IFileMgr.h:297

void FileMgr::suppressAction | ( | const std::string & | f,
|  | const Io::Action & | a
| ) |  |
| override

Definition at line 1488 of file FileMgr.cpp.

1488 {
1489
1490 auto it2 = m_supMap.find(f);
1491 if (it2 == m_supMap.end()) {
1492 int b(0);
1493 set_bit(b,a);
1494 m_supMap[f] = b;
1495 } else {
1496 set_bit(it2->second, a);
1497 }
1498
1499 }
FileMgr::m_supMap
supMap m_supMap
Definition: FileMgr.h:142
std::map::end
T end(T...args)
std::map::find
T find(T...args)

## Member Data Documentation

std::map<IoTech, actionMap> FileMgr::m_actions
| private

Definition at line 139 of file FileMgr.h.

std::vector<std::unique_ptr<FileAttr> > FileMgr::m_attr
| private

Definition at line 135 of file FileMgr.h.

std::map<Fd, FileAttr*> FileMgr::m_descriptors
| private

Definition at line 134 of file FileMgr.h.

fileMap FileMgr::m_files
| private

Definition at line 132 of file FileMgr.h.

std::map<IoTech, FileHdlr> FileMgr::m_handlers
| private

Definition at line 133 of file FileMgr.h.

int FileMgr::m_lastErr
| private

Definition at line 145 of file FileMgr.h.

std::string FileMgr::m_lastErrS
| private

Definition at line 144 of file FileMgr.h.

Gaudi::Property<bool> FileMgr::m_loadPosixHandler {this, "LoadPOSIXHandler", true}
| private

Definition at line 113 of file FileMgr.h.

Gaudi::Property<bool> FileMgr::m_loadRootHandler {this, "LoadROOTHandler", true}
| private

Definition at line 112 of file FileMgr.h.

Gaudi::Property<std::string> FileMgr::m_logfile {this, "LogFile"}
| private

Definition at line 110 of file FileMgr.h.

std::vector<FileAttr*> FileMgr::m_oldFiles
| private

Definition at line 137 of file FileMgr.h.

std::unique_ptr<POSIXFileHandler> FileMgr::m_pfh
| private

Definition at line 148 of file FileMgr.h.

Gaudi::Property<bool> FileMgr::m_printSummary {this, "PrintSummary", false}
| private

Definition at line 111 of file FileMgr.h.

std::unique_ptr<RootFileHandler> FileMgr::m_rfh
| private

Definition at line 147 of file FileMgr.h.

Gaudi::Property<std::string> FileMgr::m_ssl_cert {this, "TSSL_CertDir", "X509"}
| private

Definition at line 116 of file FileMgr.h.

Gaudi::Property<std::string> FileMgr::m_ssl_proxy {this, "TSSL_UserProxy", "X509"}
| private

Definition at line 115 of file FileMgr.h.

supMap FileMgr::m_supMap
| private

Definition at line 142 of file FileMgr.h.

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

- GaudiSvc/src/FileMgr/FileMgr.h
- GaudiSvc/src/FileMgr/FileMgr.cpp