| The Gaudi Framework v32r1 (f65d50dc)

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...
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 | declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
| Declare used 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
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, 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
Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level | msgLevel () const
| get the cached level (originally extracted from the embedded MsgStream) More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const
| Backward compatibility function for getting the output level. More...
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
const 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...

## 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

## 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
std::map< std::string, Io::Action_bitmap > | m_supMap
std::string | m_lastErrS
int | m_lastErr
std::optional< RootFileHandler > | m_rfh
std::optional< 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
using | Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces... >
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
| take union of the ext_iids of all Interfaces... More...
Protected Member Functions inherited from Service
| ~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 > >
MSG::Level | setUpMessaging () const
| Set up local caches. More...
MSG::Level | resetMessaging ()
| Reinitialize internal states. More...
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::Property< int > | m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
Gaudi::Property< bool > | m_auditInit {this, "AuditServices", false, " 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 35 of file FileMgr.h.

## Member Typedef Documentation

## ◆ actionMap

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

Definition at line 126 of file FileMgr.h.

## ◆ bfcn_desc_t

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

Definition at line 125 of file FileMgr.h.

## ◆ fileMap

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

Definition at line 133 of file FileMgr.h.

## Constructor & Destructor Documentation

## ◆ ~FileMgr()

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

Definition at line 54 of file FileMgr.cpp.

54 {
55 // Where do the new-ed FileAttr get deleted?
56 // they get pushed into m_descriptors, but m_attr is presumably
57 // where they _also_ should be pushed in order to track ownership...
58 }

## Member Function Documentation

## ◆ accessMatch()

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

Definition at line 1142 of file FileMgr.cpp.

1142 {
1143 ON_VERBOSE
1144 verbose() << "accessMatch old: " << fold << " new: " << fnew << endmsg;
1145
1146 return ( ( ( fold == Io::READ ) && ( fnew == Io::READ ) ) ||
1147 ( ( fold & Io::WRITE ) != 0 && ( fnew & Io::WRITE ) != 0 ) ||
1148 ( ( fold & Io::RDWR ) != 0 && ( fnew & Io::RDWR ) != 0 ) );
1149 }
Io::RDWR
Definition: IFileMgr.h:29
Io::WRITE
Definition: IFileMgr.h:28
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
Io::READ
Definition: IFileMgr.h:27
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:9
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ close() [1/2]

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

## ◆ close() [2/2]

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

Definition at line 492 of file FileMgr.cpp.

492 {
493
494 // return codes:
495 // < 0 : error condition
496 // 0 : actual close of one file
497 // > 0 : shared file, removed from list, no actual close, returns
498 // number of shared files still open.
499
500 ON_VERBOSE
501 verbose() << "close(" << vp << ")" << endmsg;
502
503 close_t r = -1;
504
505 auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
506 [&]( fileMap::const_reference i ) { return i.second->fptr() == vp; } );
507
508 if ( itr == m_files.end() ) {
509 error() << "unknown file ptr \"" << vp << "\" when calling close()" << endmsg;
510 return r;
511 }
512
513 IoTech tech = itr->second->tech();
514
515 FileHdlr fh;
516
517 if ( getHandler( tech, fh ).isFailure() ) { return r; }
518 if ( !fh.b_closeP_fcn ) {
519 error() << "no close(" << tech << ",void*) function registered" << endmsg;
520 return -1;
521 }
522
523 FileAttr* fa = itr->second;
524
525 // find how many times this file is open
526 pair<fileMap::const_iterator, fileMap::const_iterator> fitr = m_files.equal_range( fa->name() );
527
528 int i =
529 std::count_if( fitr.first, fitr.second, [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
530
531 ON_VERBOSE
532 verbose() << " ref count: " << i << endmsg;
533
534 if ( i > 1 && fa->isShared() ) {
535 // file open multiple times in shared access. don't do the actual close
536 ON_DEBUG
537 debug() << "closing file " << fa->name() << " opened " << i << " times with fptr " << vp << endmsg;
538 m_files.erase( itr );
539
540 r = i - 1;
541
542 } else if ( i == 1 || ( i > 1 && !fa->isShared() ) ) {
543 ON_DEBUG
544 debug() << "closing: " << *fa << endmsg;
545
546 try {
547 r = fh.b_closeP_fcn( vp );
548 } catch ( const std::bad_function_call& err ) {
549 error() << "when calling close handler for " << tech << " on file " << fa->name() << " caught " << err.what()
550 << endmsg;
551 execAction( fa, caller, CLOSE_ERR ).ignore();
552 return -1;
553 } catch ( ... ) {
554 error() << "when calling close handler for " << tech << " on file " << fa->name()
555 << " caught an unknown exception." << endmsg;
556 execAction( fa, caller, CLOSE_ERR ).ignore();
557 return -1;
558 }
559
560 if ( r < 0 ) {
561 warning() << "close of file with ptr \"" << vp << "\", name: \"" << fa->name() << "\", tech: \"" << tech
562 << "\" failed" << endmsg;
563
564 return r;
565 }
566
567 m_files.erase( itr );
568
569 } else {
570 // this should never happen!
571 error() << "ref count: " << i << " < 0 when closing " << fa << ". This should never happen" << endmsg;
572 return -1;
573 }
574
575 fa->fd( -1 );
576 fa->flags( INVALID );
577 fa->isOpen( false );
578 fa->fptr( 0 );
579 m_oldFiles.push_back( fa );
580
581 // exec all callbacks
582 if ( execAction( fa, caller, CLOSE ).isFailure() ) {
583 warning() << "at least one close callback action failed" << endmsg;
584 }
585
586 return r;
587 }
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
Io::IoTech
IoTech
Definition: IFileMgr.h:146
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:101
Io::INVALID
Definition: IFileMgr.h:37
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:176
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:181
std::end
T end(T... args)
Io::FileAttr::fd
Fd fd() const
Definition: IFileMgr.h:175
Io::FileAttr::flags
IoFlags flags() const
Definition: IFileMgr.h:179
Io::CLOSE
Definition: IFileMgr.h:268
Io::FileAttr::isShared
bool isShared() const
Definition: IFileMgr.h:183
Io::CLOSE_ERR
Definition: IFileMgr.h:268
std::vector::push_back
T push_back(T... args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
std::bad_function_call
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1088
std::multimap::erase
T erase(T... args)
Io::FileHdlr
Definition: IFileMgr.h:244
Io::FileHdlr::b_closeP_fcn
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:249
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
Io::FileAttr::isOpen
bool isOpen() const
Definition: IFileMgr.h:182
std::count_if
T count_if(T... args)
std::pair
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:140
std::find_if
T find_if(T... args)
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
std::begin
T begin(T... args)
CommonMessagingBase::err
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:95
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:8
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:9
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:192
Io::close_t
int close_t
Definition: IFileMgr.h:234
Io::FileAttr
Definition: IFileMgr.h:161

## ◆ deregHandler()

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

Definition at line 211 of file FileMgr.cpp.

211 {
212 FileHdlr hdlr;
213
214 auto itr = m_handlers.find( tech );
215 if ( itr == m_handlers.end() ) {
216 error() << "Can't de-register tech " << tech << " as it hasn't been registered!" << endmsg;
217 return StatusCode::FAILURE;
218 }
219
220 m_handlers.erase( itr );
221 return StatusCode::SUCCESS;
222 }
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std::map::end
T end(T... args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:136
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
std::map::erase
T erase(T... args)
Io::FileHdlr
Definition: IFileMgr.h:244
std::map::find
T find(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ execAction()

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

Definition at line 1088 of file FileMgr.cpp.

1088 {
1089
1090 Io::IoTech tech = fa->tech();
1091
1092 StatusCode s1, s2;
1093
1094 auto itr = m_actions.find( Io::UNKNOWN );
1095
1096 if ( itr != m_actions.end() && !itr->second.empty() ) { s1 = execActs( fa, caller, a, itr->second ); }
1097
1098 itr = m_actions.find( tech );
1099 if ( itr != m_actions.end() && !itr->second.empty() ) { s2 = execActs( fa, caller, a, itr->second ); }
1100
1101 return ( s1.isFailure() || s2.isFailure() ) ? StatusCode::FAILURE : StatusCode::SUCCESS;
1102 }
Io::IoTech
IoTech
Definition: IFileMgr.h:146
FileMgr::execActs
StatusCode execActs(Io::FileAttr *, const std::string &, const Io::Action &, const actionMap &m) const
Definition: FileMgr.cpp:1106
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:178
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:142
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130
Io::UNKNOWN
Definition: IFileMgr.h:146

## ◆ execActs()

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

Definition at line 1106 of file FileMgr.cpp.

1107 {
1108
1109 auto mitr = m.find( a );
1110 if ( mitr == m.end() || mitr->second.empty() ) return StatusCode::SUCCESS;
1111
1112 ON_DEBUG
1113 debug() << "executing " << mitr->second.size() << " " << a << " actions on " << *fa << " from " << caller << endmsg;
1114
1115 bool fail( false );
1116
1117 auto it2 = m_supMap.find( fa->name() );
1118 if ( it2 != m_supMap.end() ) {
1119 if ( it2->second[a] || it2->second[Io::INVALID_ACTION] ) {
1120 ON_DEBUG
1121 debug() << " --> suppressing callback action for " << a << endmsg;
1122 return StatusCode::SUCCESS;
1123 }
1124 }
1125
1126 for ( const auto& itr : mitr->second ) {
1127
1128 ON_DEBUG
1129 debug() << "executing " << itr.second << endmsg;
1130
1131 if ( ( ( ( itr.first ) )( fa, caller ) ).isFailure() ) {
1132 warning() << "execution of " << itr.second << " on " << *fa << " failed during " << a << " action" << endmsg;
1133 fail = true;
1134 }
1135 }
1136
1137 return fail ? StatusCode::FAILURE : StatusCode::SUCCESS;
1138 }
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:101
FileMgr::m_supMap
std::map< std::string, Io::Action_bitmap > m_supMap
Definition: FileMgr.h:144
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:176
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Io::INVALID_ACTION
Definition: IFileMgr.h:268
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:92
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:8
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ fd() [1/2]

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

Definition at line 940 of file FileMgr.cpp.

940 {
941
942 auto fitr = m_files.equal_range( fname );
943 auto itr = std::find_if( fitr.first, fitr.second, []( fileMap::const_reference f ) { return f.second->fd() != -1; } );
944 return itr != fitr.second ? itr->second->fd() : -1;
945 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
std::find_if
T find_if(T... args)
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:922
std::multimap::equal_range
T equal_range(T... args)

## ◆ fd() [2/2]

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

Definition at line 949 of file FileMgr.cpp.

949 {
950
951 auto itr = std::find_if( m_files.begin(), m_files.end(),
952 [&]( fileMap::const_reference f ) { return f.second->fptr() == fptr; } );
953 return itr != m_files.end() ? itr->second->fd() : -1;
954 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:181
std::multimap::end
T end(T... args)
Io::FileAttr::fd
Fd fd() const
Definition: IFileMgr.h:175
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:958

## ◆ finalize()

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

Definition at line 116 of file FileMgr.cpp.

116 {
117 ON_VERBOSE
118 verbose() << "FileMgr::finalize()" << endmsg;
119
120 if ( m_printSummary || msgLevel( MSG::DEBUG ) ) {
121 listHandlers();
122 listFiles();
123 listActions();
124 listSuppression();
125 }
126
127 if ( !m_files.empty() ) {
128 auto& log = warning();
129 log << "At finalize, the following files remained open:\n";
130 for ( const auto& itr : m_files ) log << *( itr.second ) << '\n';
131 log << endmsg;
132 }
133
134 if ( m_logfile.value() != "" ) {
135 std::ofstream ofs;
136 ofs.open( m_logfile.value().c_str() );
137 if ( !ofs ) {
138 error() << "Unable to open output file \"" << m_logfile.value() << "\" for writing" << endmsg;
139 } else {
140 ON_DEBUG
141 debug() << "Saving log to \"" << m_logfile.value() << "\"" << endmsg;
142 for ( const auto& itr : m_files ) {
143 ofs << itr.second->name() << " " << itr.second->tech() << " " << itr.second->desc() << " "
144 << itr.second->iflags() << '\n';
145 }
146
147 set<FileAttr> fs;
148 for ( const auto& it2 : m_oldFiles ) fs.insert( *it2 );
149 for ( const auto& it3 : fs ) {
150 ofs << it3.name() << " " << it3.tech() << " " << it3.desc() << " " << it3.iflags()
151 << ( it3.isShared() ? " SHARED" : "" ) << '\n';
152 }
153 ofs.close();
154 }
155 }
156
157 // cleanup FileAttrs
158 m_attr.clear();
159
160 m_rfh.reset();
161 m_pfh.reset();
162
163 StatusCode status = Service::finalize();
164
165 ON_DEBUG
166 if ( status.isSuccess() ) debug() << "Service finalised successfully" << endmsg;
167
168 return status;
169 }
FileMgr::m_attr
std::vector< std::unique_ptr< FileAttr > > m_attr
Definition: FileMgr.h:138
FileMgr::m_pfh
std::optional< POSIXFileHandler > m_pfh
Definition: FileMgr.h:150
std::multimap::empty
T empty(T... args)
std::ofstream::open
T open(T... args)
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:164
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:101
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
MSG::DEBUG
Definition: IMessageSvc.h:15
FileMgr::listSuppression
virtual void listSuppression() const
Definition: FileMgr.cpp:1161
CommonMessaging< implements< IService, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:138
std::ofstream
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
std::ofstream::close
T close(T... args)
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
FileMgr::listActions
virtual void listActions() const
Definition: FileMgr.cpp:1063
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
std::vector::clear
T clear(T... args)
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
std::set::insert
T insert(T... args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:140
std::set
STL class.
FileMgr::m_rfh
std::optional< RootFileHandler > m_rfh
Definition: FileMgr.h:149
FileMgr::m_printSummary
Gaudi::Property< bool > m_printSummary
Definition: FileMgr.h:114
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:8
FileMgr::listFiles
void listFiles() const override
Definition: FileMgr.cpp:976
FileMgr::m_logfile
Gaudi::Property< std::string > m_logfile
Definition: FileMgr.h:113
FileMgr::listHandlers
void listHandlers() const override
Definition: FileMgr.cpp:1034
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:9
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## ◆ fname() [1/2]

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

Definition at line 922 of file FileMgr.cpp.

922 {
923
924 auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
925 [&]( fileMap::const_reference f ) { return f.second->fd() == fd; } );
926 return ( itr != std::end( m_files ) ) ? itr->second->name() : s_empty;
927 }
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:940
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
std::end
T end(T... args)
std::find_if
T find_if(T... args)
std::begin
T begin(T... args)

## ◆ fname() [2/2]

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

Definition at line 931 of file FileMgr.cpp.

931 {
932
933 auto itr = std::find_if( m_files.begin(), m_files.end(),
934 [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
935 return itr != m_files.end() ? itr->second->name() : s_empty;
936 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:176
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:181
std::multimap::end
T end(T... args)
std::find_if
T find_if(T... args)
std::multimap::begin
T begin(T... args)

## ◆ fptr() [1/2]

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

Definition at line 958 of file FileMgr.cpp.

958 {
959 auto fitr = m_files.equal_range( fname );
960 auto itr =
961 std::find_if( fitr.first, fitr.second, []( fileMap::const_reference f ) -> bool { return f.second->fptr(); } );
962 return itr != fitr.second ? itr->second->fptr() : nullptr;
963 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
std::find_if
T find_if(T... args)
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:922
std::multimap::equal_range
T equal_range(T... args)

## ◆ fptr() [2/2]

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

Definition at line 967 of file FileMgr.cpp.

967 {
968
969 auto itr = std::find_if( m_files.begin(), m_files.end(),
970 [&]( fileMap::const_reference f ) { return f.second->fd() == fd; } );
971 return itr != m_files.end() ? itr->second->fptr() : nullptr;
972 }
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:940
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:181
std::multimap::end
T end(T... args)
Io::FileAttr::fd
Fd fd() const
Definition: IFileMgr.h:175
std::find_if
T find_if(T... args)
std::multimap::begin
T begin(T... args)

## ◆ getFd() [1/3]

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

## ◆ getFd() [2/3]

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

Definition at line 895 of file FileMgr.cpp.

895 {
896
897 if ( tech == UNKNOWN ) return getFd( fd );
898
899 fd.clear();
900 transform_if( std::begin( m_descriptors ), std::end( m_descriptors ), std::back_inserter( fd ), select1st,
901 [&]( const std::pair<Fd, FileAttr*>& d ) { return d.second->tech() == tech; } );
902
903 return fd.size();
904 }
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:940
std::end
T end(T... args)
FileMgr::m_descriptors
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:137
std::pair
std::begin
T begin(T... args)
std::back_inserter
T back_inserter(T... args)
Io::UNKNOWN
Definition: IFileMgr.h:146
FileMgr::getFd
int getFd(std::vector< Fd > &) const override

## ◆ getFd() [3/3]

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

Definition at line 910 of file FileMgr.cpp.

910 {
911
912 fd.clear();
913 transform_if( m_descriptors.begin(), m_descriptors.end(), std::back_inserter( fd ), select1st,
914 [&]( const std::pair<Fd, FileAttr*>& d ) {
915 return ( d.second->tech() == tech || tech == UNKNOWN ) && ( d.second->flags() == flags );
916 } );
917 return fd.size();
918 }
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:940
std::map::end
T end(T... args)
FileMgr::m_descriptors
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:137
std::pair
std::map::begin
T begin(T... args)
std::back_inserter
T back_inserter(T... args)
Io::UNKNOWN
Definition: IFileMgr.h:146

## ◆ getFileAttr() [1/3]

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

Definition at line 714 of file FileMgr.cpp.

714 {
715
716 fa.clear();
717
718 auto fitr = m_files.equal_range( fname );
719 std::transform( fitr.first, fitr.second, std::back_inserter( fa ), select2nd );
720
721 std::copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( fa ),
722 [&]( const FileAttr* f ) { return f->name() == fname; } );
723
724 return fa.size();
725 }
std::copy_if
T copy_if(T... args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:176
std::end
T end(T... args)
std::vector::clear
T clear(T... args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:140
std::vector::size
T size(T... args)
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:922
std::begin
T begin(T... args)
std::back_inserter
T back_inserter(T... args)
std::transform
T transform(T... args)
std::multimap::equal_range
T equal_range(T... args)
Io::FileAttr
Definition: IFileMgr.h:161

## ◆ getFileAttr() [2/3]

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

## ◆ getFileAttr() [3/3]

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

Definition at line 750 of file FileMgr.cpp.

750 {
751
752 auto i = std::find_if( std::begin( m_files ), std::end( m_files ),
753 [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
754 if ( i != std::end( m_files ) ) {
755 fa = i->second;
756 return StatusCode::SUCCESS;
757 }
758
759 auto j = std::find_if( std::begin( m_oldFiles ), std::end( m_oldFiles ),
760 [&]( const FileAttr* f ) { return f->fptr() == vp; } );
761 if ( j != std::end( m_oldFiles ) ) {
762 fa = *j;
763 return StatusCode::SUCCESS;
764 }
765
766 return StatusCode::FAILURE;
767 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:181
std::end
T end(T... args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:140
std::find_if
T find_if(T... args)
std::begin
T begin(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Io::FileAttr
Definition: IFileMgr.h:161

## ◆ getFiles() [1/6]

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

Definition at line 771 of file FileMgr.cpp.

771 {
772
773 files.clear();
774 auto not_in_files = [&]( const std::string& i ) {
775 return std::none_of( std::begin( files ), std::end( files ), [&]( const std::string& j ) { return j == i; } );
776 };
777 transform_copy_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), to_name, not_in_files );
778 if ( !op ) {
779 transform_copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), to_name,
780 not_in_files );
781 }
782 return files.size();
783 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
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:140
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)

## ◆ getFiles() [2/6]

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

Definition at line 787 of file FileMgr.cpp.

787 {
788
789 files.clear();
790 std::transform( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), select2nd );
791 if ( !op ) { std::copy( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ) ); }
792 return files.size();
793 }
std::copy
T copy(T... args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
std::end
T end(T... args)
std::vector::clear
T clear(T... args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:140
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)

## ◆ getFiles() [3/6]

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

Definition at line 797 of file FileMgr.cpp.

797 {
798
799 if ( tech == UNKNOWN ) return getFiles( files, op );
800
801 files.clear();
802 transform_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), to_name,
803 [&]( fileMap::const_reference f ) {
804 return f.second->tech() == tech &&
805 std::none_of( std::begin( files ), std::end( files ),
806 [&]( const std::string& j ) { return j == f.first; } );
807 } );
808
809 if ( !op ) {
810 transform_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), to_name,
811 [&]( const FileAttr* f ) {
812 return f->tech() == tech && std::none_of( std::begin( files ), std::end( files ),
813 [&]( const std::string& j ) { return j == f->name(); } );
814 } );
815 }
816 return files.size();
817 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:176
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:178
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:140
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)
FileMgr::getFiles
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:771
Io::UNKNOWN
Definition: IFileMgr.h:146
Io::FileAttr
Definition: IFileMgr.h:161

## ◆ getFiles() [4/6]

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

Definition at line 821 of file FileMgr.cpp.

821 {
822
823 if ( tech == UNKNOWN ) return getFiles( files, op );
824
825 auto matches_tech = [&]( const FileAttr* f ) { return f->tech() == tech; };
826
827 files.clear();
828 transform_copy_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), select2nd, matches_tech );
829 if ( !op ) {
830 std::copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), matches_tech );
831 }
832
833 return files.size();
834 }
std::copy_if
T copy_if(T... args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
std::end
T end(T... args)
std::vector::clear
T clear(T... args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:140
std::vector::size
T size(T... args)
std::begin
T begin(T... args)
std::back_inserter
T back_inserter(T... args)
FileMgr::getFiles
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:771
Io::UNKNOWN
Definition: IFileMgr.h:146
Io::FileAttr
Definition: IFileMgr.h:161

## ◆ getFiles() [5/6]

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

Definition at line 838 of file FileMgr.cpp.

838 {
839
840 files.clear();
841
842 auto not_in_files = [&]( const std::string& n ) {
843 return std::none_of( std::begin( files ), std::end( files ), [&]( const std::string& f ) { return f == n; } );
844 };
845 auto matches_tech_and_flags = [&]( const FileAttr* f ) {
846 return ( f->tech() == tech || tech == UNKNOWN ) && f->flags() == flags;
847 };
848
849 transform_if(
850 std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), to_name,
851 [&]( fileMap::const_reference f ) { return matches_tech_and_flags( f.second ) && not_in_files( f.first ); } );
852 if ( !op ) {
853 transform_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), to_name,
854 [&]( const FileAttr* f ) { return matches_tech_and_flags( f ) && not_in_files( f->name() ); } );
855 }
856
857 return files.size();
858 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:176
std::end
T end(T... args)
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
std::vector::clear
T clear(T... args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:140
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:146
Io::FileAttr
Definition: IFileMgr.h:161

## ◆ getFiles() [6/6]

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 861 of file FileMgr.cpp.

861 {
862
863 files.clear();
864
865 auto matches_tech_and_flags = [&]( const FileAttr* f ) {
866 return ( f->tech() == tech || tech == UNKNOWN ) && f->flags() == flags;
867 };
868
869 transform_copy_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), select2nd,
870 matches_tech_and_flags );
871 if ( !op ) {
872 std::copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ),
873 matches_tech_and_flags );
874 }
875
876 return files.size();
877 }
std::copy_if
T copy_if(T... args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
std::end
T end(T... args)
std::vector::clear
T clear(T... args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:140
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:146
Io::FileAttr
Definition: IFileMgr.h:161

## ◆ getHandler() [1/2]

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

## ◆ getHandler() [2/2]

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

Definition at line 1009 of file FileMgr.cpp.

1009 {
1010
1011 auto fitr = m_files.equal_range( fname );
1012 if ( fitr.first == fitr.second ) {
1013 error() << "no file \"" << fname << "\" registered. Cannot determine tech" << endmsg;
1014 return StatusCode::FAILURE;
1015 }
1016
1017 auto itr = fitr.first;
1018 IoTech tech = itr->second->tech();
1019
1020 ++itr;
1021 while ( itr != fitr.second ) {
1022 if ( itr->second->tech() != tech ) {
1023 error() << "multiple technologies registered for file \"" << fname << "\". Cannot determine handler" << endmsg;
1024 return StatusCode::FAILURE;
1025 }
1026 ++itr;
1027 }
1028
1029 return getHandler( tech, hdlr );
1030 }
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
Io::IoTech
IoTech
Definition: IFileMgr.h:146
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:922
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:192

## ◆ getLastError()

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

Definition at line 988 of file FileMgr.cpp.

988 {
989
990 err = m_lastErrS;
991 return m_lastErr;
992 }
FileMgr::m_lastErrS
std::string m_lastErrS
Definition: FileMgr.h:146
CommonMessagingBase::err
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:95
FileMgr::m_lastErr
int m_lastErr
Definition: FileMgr.h:147

## ◆ handle()

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

Definition at line 173 of file FileMgr.cpp.

173 {}

## ◆ hasHandler()

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

Definition at line 225 of file FileMgr.cpp.

225 {
226
227 auto itr = m_handlers.find( tech );
228 return ( itr != m_handlers.end() ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
229 }
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std::map::end
T end(T... args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:136
std::map::find
T find(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86

## ◆ initialize()

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

Definition at line 62 of file FileMgr.cpp.

62 {
63 StatusCode status = Service::initialize();
64
65 if ( status.isFailure() ) {
66
67 ON_DEBUG
68 debug() << "Failed to initialize the base class (Service)" << endmsg;
69 return status;
70 }
71
72 ON_VERBOSE
73 verbose() << "Initializing FileMgr" << endmsg;
74
75 if ( m_loadRootHandler.value() ) {
76
77 // setup file handler for ROOT
78
79 msgSvc()->setOutputLevel( "RootFileHandler", m_outputLevel.value() );
80 m_rfh.emplace( msgSvc(), m_ssl_proxy, m_ssl_cert );
81
82 auto& rfh = m_rfh.value(); // used in the lambdas to avoid capturing 'this'
83 Io::FileHdlr hdlr(
84 Io::ROOT,
85 [&rfh]( const std::string& n, const Io::IoFlags& f, const std::string& desc, Io::Fd& fd,
86 void*& ptr ) -> Io::open_t { return rfh.openRootFile( n, f, desc, fd, ptr ); },
87 [&rfh]( void* ptr ) -> Io::close_t { return rfh.closeRootFile( ptr ); },
88 [&rfh]( void* ptr, const Io::IoFlags& f ) -> Io::reopen_t { return rfh.reopenRootFile( ptr, f ); } );
89
90 if ( regHandler( hdlr ).isFailure() ) { error() << "unable to register ROOT file handler with FileMgr" << endmsg; }
91 }
92
93 if ( m_loadPosixHandler.value() ) {
94
95 // setup file handler for POSIX
96
97 msgSvc()->setOutputLevel( "POSIXFileHandler", m_outputLevel.value() );
98 m_pfh.emplace( msgSvc() );
99
100 auto& pfh = m_pfh.value(); // used in the lambdas to avoid capturing 'this'
101 Io::FileHdlr hdlp(
102 Io::POSIX,
103 [&pfh]( const std::string& n, const Io::IoFlags& f, const std::string& desc, Io::Fd& fd,
104 void*& ptr ) -> Io::open_t { return pfh.openPOSIXFile( n, f, desc, fd, ptr ); },
105 [&pfh]( Io::Fd fd ) -> Io::close_t { return pfh.closePOSIXFile( fd ); },
106 [&pfh]( Io::Fd fd, const Io::IoFlags& f ) -> Io::reopen_t { return pfh.reopenPOSIXFile( fd, f ); } );
107
108 if ( regHandler( hdlp ).isFailure() ) { error() << "unable to register ROOT file handler with FileMgr" << endmsg; }
109 }
110
111 return StatusCode::SUCCESS;
112 }
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Service.h:176
FileMgr::regHandler
StatusCode regHandler(FileHdlr) override
Definition: FileMgr.cpp:177
FileMgr::m_pfh
std::optional< POSIXFileHandler > m_pfh
Definition: FileMgr.h:150
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:940
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:60
Io::ROOT
Definition: IFileMgr.h:146
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
Io::reopen_t
int reopen_t
Definition: IFileMgr.h:235
Io::Fd
int Fd
Definition: IFileMgr.h:159
FileMgr::m_loadPosixHandler
Gaudi::Property< bool > m_loadPosixHandler
Definition: FileMgr.h:116
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Io::open_t
int open_t
Definition: IFileMgr.h:233
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
FileMgr::m_loadRootHandler
Gaudi::Property< bool > m_loadRootHandler
Definition: FileMgr.h:115
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
Io::POSIX
Definition: IFileMgr.h:146
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Io::IoFlags
Definition: IFileMgr.h:40
Io::FileHdlr
Definition: IFileMgr.h:244
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
FileMgr::m_rfh
std::optional< RootFileHandler > m_rfh
Definition: FileMgr.h:149
FileMgr::m_ssl_proxy
Gaudi::Property< std::string > m_ssl_proxy
Definition: FileMgr.h:118
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:8
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:9
FileMgr::m_ssl_cert
Gaudi::Property< std::string > m_ssl_cert
Definition: FileMgr.h:119
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Io::close_t
int close_t
Definition: IFileMgr.h:234
IMessageSvc::setOutputLevel
virtual void setOutputLevel(int new_level)=0
Set new global output level threshold.

## ◆ isShareable()

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

## ◆ listActions()

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

Definition at line 1063 of file FileMgr.cpp.

1063 {
1064
1065 info() << "listing registered actions\n";
1066
1067 for ( const auto& iit : m_actions ) {
1068 Io::IoTech t = iit.first;
1069 const actionMap& m = iit.second;
1070
1071 if ( !m.empty() ) {
1072 info() << " --- Tech: ";
1073 if ( t == Io::UNKNOWN ) {
1074 info() << "ALL ---\n";
1075 } else {
1076 info() << t << " ---\n";
1077 }
1078 for ( const auto& iia : m ) {
1079 for ( const auto& it2 : iia.second ) { info() << " " << iia.first << " " << it2.second << '\n'; }
1080 }
1081 }
1082 }
1083 info() << endmsg;
1084 }
Io::IoTech
IoTech
Definition: IFileMgr.h:146
FileMgr::actionMap
std::map< Io::Action, std::list< bfcn_desc_t > > actionMap
Definition: FileMgr.h:126
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:104
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:92
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:142
Io::UNKNOWN
Definition: IFileMgr.h:146
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ listFiles()

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

Definition at line 976 of file FileMgr.cpp.

976 {
977
978 info() << "listing registered files [" << ( m_files.size() + m_oldFiles.size() ) << "]:\n";
979
980 for ( auto& itr : m_files ) info() << itr.second << '\n';
981 for ( auto& it2 : m_oldFiles ) info() << *it2 << '\n';
982
983 info() << endmsg;
984 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:104
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:140
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:192

## ◆ listHandlers()

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

Definition at line 1034 of file FileMgr.cpp.

1034 {
1035
1036 info() << "Listing registered handlers:\n";
1037
1038 for ( const auto& itr : m_handlers ) info() << " " << itr.first << '\n';
1039 info() << endmsg;
1040 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:104
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:136
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ listSuppression()

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

Definition at line 1161 of file FileMgr.cpp.

1161 {
1162 if ( m_supMap.empty() ) return;
1163
1164 info() << "listing suppressed file actions\n";
1165
1166 for ( const auto& sup : m_supMap ) {
1167 info() << " " << sup.first;
1168 if ( sup.second[Io::INVALID_ACTION] ) {
1169 info() << " ALL\n";
1170 } else {
1171 for ( unsigned i = 0; i != sup.second.size(); ++i ) {
1172 if ( sup.second[i] ) info() << " " << (Io::Action)i;
1173 }
1174 info() << '\n';
1175 }
1176 }
1177 info() << endmsg;
1178 }
FileMgr::m_supMap
std::map< std::string, Io::Action_bitmap > m_supMap
Definition: FileMgr.h:144
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:104
Io::INVALID_ACTION
Definition: IFileMgr.h:268
Io::Action
Action
Definition: IFileMgr.h:268
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ open() [1/4]

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 233 of file FileMgr.cpp.

234 {
235
236 return open( tech, caller, fname, desc, flags, fd, ptr, sh );
237 }
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:940
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:233
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:922

## ◆ open() [2/4]

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 240 of file FileMgr.cpp.

241 {
242
243 void* dummy( 0 );
244 return open( tech, caller, fname, desc, flags, fd, dummy, sh );
245 }
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:940
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:233
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:922

## ◆ open() [3/4]

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 248 of file FileMgr.cpp.

249 {
250
251 Fd dummy( -1 );
252 return open( tech, caller, fname, desc, flags, dummy, ptr, sh );
253 }
Io::Fd
int Fd
Definition: IFileMgr.h:159
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:233
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:922

## ◆ open() [4/4]

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

## ◆ regAction() [1/2]

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

Definition at line 1044 of file FileMgr.cpp.

1044 {
1045
1046 return regAction( bf, a, Io::UNKNOWN, d );
1047 }
FileMgr::regAction
StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &desc="") override
Definition: FileMgr.cpp:1044
Io::UNKNOWN
Definition: IFileMgr.h:146

## ◆ regAction() [2/2]

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

Definition at line 1051 of file FileMgr.cpp.

1051 {
1052
1053 ON_DEBUG
1054 debug() << "registering " << a << " action " << System::typeinfoName( bf.target_type() ) << " for tech " << t
1055 << endmsg;
1056
1057 m_actions[t][a].emplace_back( bf, ( !d.empty() ) ? d : System::typeinfoName( bf.target_type() ) );
1058 return StatusCode::SUCCESS;
1059 }
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
std::function::target_type
T target_type(T... args)
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:142
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:8
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ regHandler()

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

Definition at line 177 of file FileMgr.cpp.

177 {
178
179 IoTech tech = fh.tech;
180
181 if ( m_handlers.find( tech ) != m_handlers.end() ) {
182 warning() << "Handler for IoTech " << tech << " already registered. Ignoring." << endmsg;
183 return StatusCode::SUCCESS;
184 }
185
186 if ( !fh.b_open_fcn ) {
187 error() << "open handler for tech " << tech << " is NULL" << endmsg;
188 return StatusCode::FAILURE;
189 }
190
191 if ( !fh.b_close_fcn && !fh.b_closeP_fcn ) {
192 error() << "no close handler for tech " << tech << " registered" << endmsg;
193 return StatusCode::FAILURE;
194 }
195
196 if ( !fh.b_reopen_fcn && !fh.b_reopenP_fcn ) {
197 error() << "no reopen handler for tech " << tech << " registered" << endmsg;
198 return StatusCode::FAILURE;
199 }
200
201 ON_DEBUG
202 debug() << "Successfully registered handler for tech \"" << tech << "\"" << endmsg;
203
204 m_handlers[tech] = fh;
205
206 return StatusCode::SUCCESS;
207 }
Io::IoTech
IoTech
Definition: IFileMgr.h:146
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:101
Io::FileHdlr::b_reopen_fcn
bfcn_reopen_t b_reopen_fcn
Definition: IFileMgr.h:250
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std::map::end
T end(T... args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:136
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
Io::FileHdlr::b_close_fcn
bfcn_close_t b_close_fcn
Definition: IFileMgr.h:248
Io::FileHdlr::b_closeP_fcn
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:249
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
Io::FileHdlr::b_reopenP_fcn
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:251
std::map::find
T find(T... args)
Io::FileHdlr::b_open_fcn
bfcn_open_t b_open_fcn
Definition: IFileMgr.h:247
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:8
Io::FileHdlr::tech
IoTech tech
Definition: IFileMgr.h:245
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ reopen() [1/2]

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

## ◆ reopen() [2/2]

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

Definition at line 656 of file FileMgr.cpp.

656 {
657 ON_VERBOSE
658 verbose() << "reopen(" << vp << "," << flags << "," << caller << ")" << endmsg;
659
660 reopen_t r = -1;
661
662 auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
663 [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
664 if ( itr == m_files.end() ) {
665 error() << "unregistered file ptr \"" << vp << "\" when calling reopen()" << endmsg;
666 return r;
667 }
668
669 FileAttr* fa = itr->second;
670 FileHdlr fh;
671 IoTech tech = fa->tech();
672
673 if ( getHandler( tech, fh ).isFailure() ) { return r; }
674
675 if ( !fh.b_reopenP_fcn ) {
676 error() << "no reopen(" << tech << ",void*) function registered" << endmsg;
677 return -1;
678 }
679
680 try {
681 r = fh.b_reopenP_fcn( vp, flags );
682 } catch ( const std::bad_function_call& err ) {
683 error() << "when calling reopen handler for " << tech << " on file " << fa->name() << " with flags " << flags
684 << " caught " << err.what() << endmsg;
685 return -1;
686 } catch ( ... ) {
687 error() << "when calling reopen handler for " << tech << " on file " << fa->name() << " with flags " << flags
688 << " caught an unknown exception." << endmsg;
689 return -1;
690 }
691
692 if ( r < 0 ) {
693 warning() << "reopen of file with ptr \"" << vp << "\", name: \"" << fa->name() << "\", tech: \"" << tech
694 << "\", flags: \"" << flags << "\" failed" << endmsg;
695
696 execAction( fa, caller, Io::REOPEN_ERR ).ignore();
697
698 return r;
699 }
700
701 fa->isOpen( true );
702 fa->flags( flags );
703
704 // exec all callbacks
705 if ( execAction( fa, caller, Io::REOPEN ).isFailure() ) {
706 warning() << "at least one reopen callback action failed" << endmsg;
707 }
708
709 return r;
710 }
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
Io::IoTech
IoTech
Definition: IFileMgr.h:146
Io::REOPEN
Definition: IFileMgr.h:268
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:101
Io::reopen_t
int reopen_t
Definition: IFileMgr.h:235
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:135
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:176
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:178
std::end
T end(T... args)
Io::REOPEN_ERR
Definition: IFileMgr.h:268
Io::FileAttr::flags
IoFlags flags() const
Definition: IFileMgr.h:179
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
std::bad_function_call
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1088
Io::FileHdlr
Definition: IFileMgr.h:244
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
Io::FileHdlr::b_reopenP_fcn
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:251
Io::FileAttr::isOpen
bool isOpen() const
Definition: IFileMgr.h:182
std::find_if
T find_if(T... args)
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
std::begin
T begin(T... args)
CommonMessagingBase::err
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:95
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:9
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Io::FileAttr
Definition: IFileMgr.h:161

## ◆ suppressAction() [1/2]

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

Definition at line 1153 of file FileMgr.cpp.

1153 { return suppressAction( f, Io::INVALID_ACTION ); }
FileMgr::suppressAction
void suppressAction(const std::string &) override
Definition: FileMgr.cpp:1153
Io::INVALID_ACTION
Definition: IFileMgr.h:268

## ◆ suppressAction() [2/2]

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

Definition at line 1157 of file FileMgr.cpp.

1157 { m_supMap[f].set( a ); }
FileMgr::m_supMap
std::map< std::string, Io::Action_bitmap > m_supMap
Definition: FileMgr.h:144

## Member Data Documentation

## ◆ m_actions

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

Definition at line 142 of file FileMgr.h.

## ◆ m_attr

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

Definition at line 138 of file FileMgr.h.

## ◆ m_descriptors

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

Definition at line 137 of file FileMgr.h.

## ◆ m_files

fileMap FileMgr::m_files
| private

Definition at line 135 of file FileMgr.h.

## ◆ m_handlers

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

Definition at line 136 of file FileMgr.h.

## ◆ m_lastErr

int FileMgr::m_lastErr
| private

Definition at line 147 of file FileMgr.h.

## ◆ m_lastErrS

std::string FileMgr::m_lastErrS
| private

Definition at line 146 of file FileMgr.h.

## ◆ m_loadPosixHandler

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

Definition at line 116 of file FileMgr.h.

## ◆ m_loadRootHandler

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

Definition at line 115 of file FileMgr.h.

## ◆ m_logfile

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

Definition at line 113 of file FileMgr.h.

## ◆ m_oldFiles

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

Definition at line 140 of file FileMgr.h.

## ◆ m_pfh

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

Definition at line 150 of file FileMgr.h.

## ◆ m_printSummary

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

Definition at line 114 of file FileMgr.h.

## ◆ m_rfh

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

Definition at line 149 of file FileMgr.h.

## ◆ m_ssl_cert

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

Definition at line 119 of file FileMgr.h.

## ◆ m_ssl_proxy

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

Definition at line 118 of file FileMgr.h.

## ◆ m_supMap

std::map<std::string, Io::Action_bitmap> FileMgr::m_supMap
| private

Definition at line 144 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