| The Gaudi Framework v29r0 (ff2e7097)

- 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 | 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
| ~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 77 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 1228 of file FileMgr.cpp.

1229 {
1230
1231 ON_VERBOSE
1232 verbose() << "accessMatch old: " << fold << " new: " << fnew << endmsg;
1233
1234 return ( ( ( fold == Io::READ ) && ( fnew == Io::READ ) ) ||
1235 ( ( fold & Io::WRITE ) != 0 && ( fnew & Io::WRITE ) != 0 ) ||
1236 ( ( fold & Io::RDWR ) != 0 && ( fnew & Io::RDWR ) != 0 ) );
1237 }
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:123
Io::RDWR
Definition: IFileMgr.h:29
Io::WRITE
Definition: IFileMgr.h:28
Io::READ
Definition: IFileMgr.h:27
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:209

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

531 {
532
533 // return codes:
534 // < 0 : error condition
535 // 0 : actual close of one file
536 // > 0 : shared file, removed from list, no actual close, returns
537 // number of shared files still open.
538
539 ON_VERBOSE
540 verbose() << "close(" << vp << ")" << endmsg;
541
542 close_t r = -1;
543
544 auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
545 [&]( fileMap::const_reference i ) { return i.second->fptr() == vp; } );
546
547 if ( itr == m_files.end() ) {
548 error() << "unknown file ptr \"" << vp << "\" when calling close()" << endmsg;
549 return r;
550 }
551
552 IoTech tech = itr->second->tech();
553
554 FileHdlr fh;
555
556 if ( getHandler( tech, fh ).isFailure() ) {
557 return r;
558 }
559 if ( !fh.b_closeP_fcn ) {
560 error() << "no close(" << tech << ",void*) function registered" << endmsg;
561 return -1;
562 }
563
564 FileAttr* fa = itr->second;
565
566 // find how many times this file is open
567 pair<fileMap::const_iterator, fileMap::const_iterator> fitr = m_files.equal_range( fa->name() );
568
569 int i =
570 std::count_if( fitr.first, fitr.second, [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
571
572 ON_VERBOSE
573 verbose() << " ref count: " << i << endmsg;
574
575 if ( i > 1 && fa->isShared() ) {
576 // file open multiple times in shared access. don't do the actual close
577 ON_DEBUG
578 debug() << "closing file " << fa->name() << " opened " << i << " times with fptr " << vp << endmsg;
579 m_files.erase( itr );
580
581 r = i - 1;
582
583 } else if ( i == 1 || ( i > 1 && !fa->isShared() ) ) {
584 ON_DEBUG
585 debug() << "closing: " << *fa << endmsg;
586
587 try {
588 r = fh.b_closeP_fcn( vp );
589 } catch ( const std::bad_function_call& err ) {
590 error() << "when calling close handler for " << tech << " on file " << fa->name() << " caught " << err.what()
591 << endmsg;
592 execAction( fa, caller, CLOSE_ERR ).ignore();
593 return -1;
594 } catch ( ... ) {
595 error() << "when calling close handler for " << tech << " on file " << fa->name()
596 << " caught an unknown exception." << endmsg;
597 execAction( fa, caller, CLOSE_ERR ).ignore();
598 return -1;
599 }
600
601 if ( r < 0 ) {
602 warning() << "close of file with ptr \"" << vp << "\", name: \"" << fa->name() << "\", tech: \"" << tech
603 << "\" failed" << endmsg;
604
605 return r;
606 }
607
608 m_files.erase( itr );
609
610 } else {
611 // this should never happen!
612 error() << "ref count: " << i << " < 0 when closing " << fa << ". This should never happen" << endmsg;
613 return -1;
614 }
615
616 fa->fd( -1 );
617 fa->flags( INVALID );
618 fa->isOpen( false );
619 fa->fptr( 0 );
620 m_oldFiles.push_back( fa );
621
622 // exec all callbacks
623 if ( execAction( fa, caller, CLOSE ).isFailure() ) {
624 warning() << "at least one close callback action failed" << endmsg;
625 }
626
627 return r;
628 }
Io::IoTech
IoTech
Definition: IFileMgr.h:157
Io::INVALID
Definition: IFileMgr.h:37
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:194
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:123
Io::FileAttr::isOpen
bool isOpen() const
Definition: IFileMgr.h:195
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1165
std::end
T end(T...args)
Io::FileAttr::fd
Fd fd() const
Definition: IFileMgr.h:188
CommonMessagingBase::err
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:108
Io::CLOSE
Definition: IFileMgr.h:284
Io::CLOSE_ERR
Definition: IFileMgr.h:284
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:189
std::vector::push_back
T push_back(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
std::bad_function_call
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:114
Io::FileAttr::isShared
bool isShared() const
Definition: IFileMgr.h:196
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:260
Io::FileHdlr::b_closeP_fcn
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:265
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:120
std::begin
T begin(T...args)
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109
Io::FileAttr::flags
IoFlags flags() const
Definition: IFileMgr.h:192
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:209
Io::close_t
int close_t
Definition: IFileMgr.h:250
Io::FileAttr
Definition: IFileMgr.h:173

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

Definition at line 240 of file FileMgr.cpp.

241 {
242 FileHdlr hdlr;
243
244 auto itr = m_handlers.find( tech );
245 if ( itr == m_handlers.end() ) {
246 error() << "Can't de-register tech " << tech << " as it hasn't been registered!" << endmsg;
247 return StatusCode::FAILURE;
248 }
249
250 m_handlers.erase( itr );
251 return StatusCode::SUCCESS;
252 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
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:111
std::map::erase
T erase(T...args)
Io::FileHdlr
Definition: IFileMgr.h:260
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:209

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

Definition at line 1165 of file FileMgr.cpp.

1166 {
1167
1168 Io::IoTech tech = fa->tech();
1169
1170 StatusCode s1, s2;
1171
1172 auto itr = m_actions.find( Io::UNKNOWN );
1173
1174 if ( itr != m_actions.end() && !itr->second.empty() ) {
1175 s1 = execActs( fa, caller, a, itr->second );
1176 }
1177
1178 itr = m_actions.find( tech );
1179 if ( itr != m_actions.end() && !itr->second.empty() ) {
1180 s2 = execActs( fa, caller, a, itr->second );
1181 }
1182
1183 return ( s1.isFailure() || s2.isFailure() ) ? StatusCode::FAILURE : StatusCode::SUCCESS;
1184 }
Io::IoTech
IoTech
Definition: IFileMgr.h:157
StatusCode::SUCCESS
Definition: StatusCode.h:31
HiveAlgSequencer.s1
s1
Definition: HiveAlgSequencer.py:27
StatusCode::FAILURE
Definition: StatusCode.h:31
HiveAlgSequencer.s2
s2
Definition: HiveAlgSequencer.py:28
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
FileMgr::execActs
StatusCode execActs(Io::FileAttr *, const std::string &, const Io::Action &, const actionMap &m) const
Definition: FileMgr.cpp:1188
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:191
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:139
Io::UNKNOWN
Definition: IFileMgr.h:157

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

Definition at line 1188 of file FileMgr.cpp.

1190 {
1191
1192 auto mitr = m.find( a );
1193
1194 if ( mitr == m.end() || mitr->second.empty() ) {
1195 return StatusCode::SUCCESS;
1196 }
1197
1198 ON_DEBUG
1199 debug() << "executing " << mitr->second.size() << " " << a << " actions on " << *fa << " from " << caller << endmsg;
1200
1201 bool fail( false );
1202
1203 auto it2 = m_supMap.find( fa->name() );
1204 if ( it2 != m_supMap.end() ) {
1205 if ( get_bit( it2->second, a ) || get_bit( it2->second, Io::INVALID_ACTION ) ) {
1206 ON_DEBUG
1207 debug() << " --> suppressing callback action for " << a << endmsg;
1208 return StatusCode::SUCCESS;
1209 }
1210 }
1211
1212 for ( const auto& itr : mitr->second ) {
1213
1214 ON_DEBUG
1215 debug() << "executing " << itr.second << endmsg;
1216
1217 if ( ( ( ( itr.first ) )( fa, caller ) ).isFailure() ) {
1218 warning() << "execution of " << itr.second << " on " << *fa << " failed during " << a << " action" << endmsg;
1219 fail = true;
1220 }
1221 }
1222
1223 return fail ? StatusCode::FAILURE : StatusCode::SUCCESS;
1224 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
FileMgr::m_supMap
supMap m_supMap
Definition: FileMgr.h:142
std::map::end
T end(T...args)
Io::INVALID_ACTION
Definition: IFileMgr.h:284
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:189
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:114
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:94
std::map::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:120
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:209

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

Definition at line 1003 of file FileMgr.cpp.

1004 {
1005
1006 auto fitr = m_files.equal_range( fname );
1007 auto itr = std::find_if( fitr.first, fitr.second, []( fileMap::const_reference f ) { return f.second->fd() != -1; } );
1008 return itr != fitr.second ? itr->second->fd() : -1;
1009 }
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 1013 of file FileMgr.cpp.

1014 {
1015
1016 auto itr = std::find_if( m_files.begin(), m_files.end(),
1017 [&]( fileMap::const_reference f ) { return f.second->fptr() == fptr; } );
1018 return itr != m_files.end() ? itr->second->fd() : -1;
1019 }
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:194
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:188
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:1023

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

Definition at line 143 of file FileMgr.cpp.

144 {
145 ON_VERBOSE
146 verbose() << "FileMgr::finalize()" << endmsg;
147
148 if ( m_printSummary || msgLevel( MSG::DEBUG ) ) {
149 listHandlers();
150 listFiles();
151 listActions();
152 listSuppression();
153 }
154
155 if ( !m_files.empty() ) {
156 auto& log = warning();
157 log << "At finalize, the following files remained open:" << endl;
158 for ( const auto& itr : m_files ) log << *( itr.second ) << endl;
159 log << endmsg;
160 }
161
162 if ( m_logfile.value() != "" ) {
163 std::ofstream ofs;
164 ofs.open( m_logfile.value().c_str() );
165 if ( !ofs ) {
166 error() << "Unable to open output file \"" << m_logfile.value() << "\" for writing" << endmsg;
167 } else {
168 ON_DEBUG
169 debug() << "Saving log to \"" << m_logfile.value() << "\"" << endmsg;
170 for ( const auto& itr : m_files ) {
171 ofs << itr.second->name() << " " << itr.second->tech() << " " << itr.second->desc() << " "
172 << itr.second->iflags() << endl;
173 }
174
175 set<FileAttr> fs;
176 for ( const auto& it2 : m_oldFiles ) fs.insert( *it2 );
177 for ( const auto& it3 : fs ) {
178 ofs << it3.name() << " " << it3.tech() << " " << it3.desc() << " " << it3.iflags()
179 << ( it3.isShared() ? " SHARED" : "" ) << endl;
180 }
181 ofs.close();
182 }
183 }
184
185 // cleanup FileAttrs
186 m_attr.clear();
187
188 m_rfh.reset();
189 m_pfh.reset();
190
191 StatusCode status = Service::finalize();
192
193 ON_DEBUG
194 if ( status.isSuccess() ) debug() << "Service finalised successfully" << endmsg;
195
196 return status;
197 }
FileMgr::m_attr
std::vector< std::unique_ptr< FileAttr > > m_attr
Definition: FileMgr.h:135
FileMgr::listHandlers
void listHandlers() const override
Definition: FileMgr.cpp:1105
FileMgr::listFiles
void listFiles() const override
Definition: FileMgr.cpp:1043
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:75
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:123
MSG::DEBUG
Definition: IMessageSvc.h:16
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:1137
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
std::ofstream
STL class.
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:114
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
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:120
FileMgr::listSuppression
virtual void listSuppression() const
Definition: FileMgr.cpp:1260
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:129
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:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

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

Definition at line 983 of file FileMgr.cpp.

984 {
985
986 auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
987 [&]( fileMap::const_reference f ) { return f.second->fd() == fd; } );
988 return ( itr != std::end( m_files ) ) ? itr->second->name() : s_empty;
989 }
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:1003
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 993 of file FileMgr.cpp.

994 {
995
996 auto itr = std::find_if( m_files.begin(), m_files.end(),
997 [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
998 return itr != m_files.end() ? itr->second->name() : s_empty;
999 }
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:194
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:189
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 1023 of file FileMgr.cpp.

1024 {
1025 auto fitr = m_files.equal_range( fname );
1026 auto itr =
1027 std::find_if( fitr.first, fitr.second, []( fileMap::const_reference f ) -> bool { return f.second->fptr(); } );
1028 return itr != fitr.second ? itr->second->fptr() : nullptr;
1029 }
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 1033 of file FileMgr.cpp.

1034 {
1035
1036 auto itr = std::find_if( m_files.begin(), m_files.end(),
1037 [&]( fileMap::const_reference f ) { return f.second->fd() == fd; } );
1038 return itr != m_files.end() ? itr->second->fptr() : nullptr;
1039 }
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:194
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:188
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1003
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 954 of file FileMgr.cpp.

955 {
956
957 if ( tech == UNKNOWN ) return getFd( fd );
958
959 fd.clear();
960 transform_if( std::begin( m_descriptors ), std::end( m_descriptors ), std::back_inserter( fd ), select1st,
961 [&]( const std::pair<Fd, FileAttr*>& d ) { return d.second->tech() == tech; } );
962
963 return fd.size();
964 }
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:157
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 970 of file FileMgr.cpp.

971 {
972
973 fd.clear();
974 transform_if( m_descriptors.begin(), m_descriptors.end(), std::back_inserter( fd ), select1st,
975 [&]( const std::pair<Fd, FileAttr*>& d ) {
976 return ( d.second->tech() == tech || tech == UNKNOWN ) && ( d.second->flags() == flags );
977 } );
978 return fd.size();
979 }
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:157

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

Definition at line 761 of file FileMgr.cpp.

762 {
763
764 fa.clear();
765
766 auto fitr = m_files.equal_range( fname );
767 std::transform( fitr.first, fitr.second, std::back_inserter( fa ), select2nd );
768
769 std::copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( fa ),
770 [&]( const FileAttr* f ) { return f->name() == fname; } );
771
772 return fa.size();
773 }
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:189
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:983
std::transform
T transform(T...args)
std::multimap::equal_range
T equal_range(T...args)
Io::FileAttr
Definition: IFileMgr.h:173

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

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

Definition at line 799 of file FileMgr.cpp.

800 {
801
802 auto i = std::find_if( std::begin( m_files ), std::end( m_files ),
803 [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
804 if ( i != std::end( m_files ) ) {
805 fa = i->second;
806 return StatusCode::SUCCESS;
807 }
808
809 auto j = std::find_if( std::begin( m_oldFiles ), std::end( m_oldFiles ),
810 [&]( const FileAttr* f ) { return f->fptr() == vp; } );
811 if ( j != std::end( m_oldFiles ) ) {
812 fa = *j;
813 return StatusCode::SUCCESS;
814 }
815
816 return StatusCode::FAILURE;
817 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:194
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:173

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

Definition at line 821 of file FileMgr.cpp.

822 {
823
824 files.clear();
825 auto not_in_files = [&]( const std::string& i ) {
826 return std::none_of( std::begin( files ), std::end( files ), [&]( const std::string& j ) { return j == i; } );
827 };
828 transform_copy_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), to_name, not_in_files );
829 if ( !op ) {
830 transform_copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), to_name,
831 not_in_files );
832 }
833 return files.size();
834 }
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 838 of file FileMgr.cpp.

839 {
840
841 files.clear();
842 std::transform( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), select2nd );
843 if ( !op ) {
844 std::copy( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ) );
845 }
846 return files.size();
847 }
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 851 of file FileMgr.cpp.

852 {
853
854 if ( tech == UNKNOWN ) return getFiles( files, op );
855
856 files.clear();
857 transform_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), to_name,
858 [&]( fileMap::const_reference f ) {
859 return f.second->tech() == tech &&
860 std::none_of( std::begin( files ), std::end( files ),
861 [&]( const std::string& j ) { return j == f.first; } );
862 } );
863
864 if ( !op ) {
865 transform_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), to_name,
866 [&]( const FileAttr* f ) {
867 return f->tech() == tech && std::none_of( std::begin( files ), std::end( files ),
868 [&]( const std::string& j ) { return j == f->name(); } );
869 } );
870 }
871 return files.size();
872 }
FileMgr::getFiles
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:821
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:189
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:191
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:157
Io::FileAttr
Definition: IFileMgr.h:173

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

Definition at line 876 of file FileMgr.cpp.

877 {
878
879 if ( tech == UNKNOWN ) return getFiles( files, op );
880
881 auto matches_tech = [&]( const FileAttr* f ) { return f->tech() == tech; };
882
883 files.clear();
884 transform_copy_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), select2nd, matches_tech );
885 if ( !op ) {
886 std::copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), matches_tech );
887 }
888
889 return files.size();
890 }
std::copy_if
T copy_if(T...args)
FileMgr::getFiles
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:821
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:157
Io::FileAttr
Definition: IFileMgr.h:173

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

Definition at line 894 of file FileMgr.cpp.

895 {
896
897 files.clear();
898
899 auto not_in_files = [&]( const std::string& n ) {
900 return std::none_of( std::begin( files ), std::end( files ), [&]( const std::string& f ) { return f == n; } );
901 };
902 auto matches_tech_and_flags = [&]( const FileAttr* f ) {
903 return ( f->tech() == tech || tech == UNKNOWN ) && f->flags() == flags;
904 };
905
906 transform_if(
907 std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), to_name,
908 [&]( fileMap::const_reference f ) { return matches_tech_and_flags( f.second ) && not_in_files( f.first ); } );
909 if ( !op ) {
910 transform_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), to_name,
911 [&]( const FileAttr* f ) { return matches_tech_and_flags( f ) && not_in_files( f->name() ); } );
912 }
913
914 return files.size();
915 }
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:228
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:189
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:157
Io::FileAttr
Definition: IFileMgr.h:173

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

919 {
920
921 files.clear();
922
923 auto matches_tech_and_flags = [&]( const FileAttr* f ) {
924 return ( f->tech() == tech || tech == UNKNOWN ) && f->flags() == flags;
925 };
926
927 transform_copy_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), select2nd,
928 matches_tech_and_flags );
929 if ( !op ) {
930 std::copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ),
931 matches_tech_and_flags );
932 }
933
934 return files.size();
935 }
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:157
Io::FileAttr
Definition: IFileMgr.h:173

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

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

Definition at line 1079 of file FileMgr.cpp.

1080 {
1081
1082 auto fitr = m_files.equal_range( fname );
1083 if ( fitr.first == fitr.second ) {
1084 error() << "no file \"" << fname << "\" registered. Cannot determine tech" << endmsg;
1085 return StatusCode::FAILURE;
1086 }
1087
1088 auto itr = fitr.first;
1089 IoTech tech = itr->second->tech();
1090
1091 ++itr;
1092 while ( itr != fitr.second ) {
1093 if ( itr->second->tech() != tech ) {
1094 error() << "multiple technologies registered for file \"" << fname << "\". Cannot determine handler" << endmsg;
1095 return StatusCode::FAILURE;
1096 }
1097 ++itr;
1098 }
1099
1100 return getHandler( tech, hdlr );
1101 }
Io::IoTech
IoTech
Definition: IFileMgr.h:157
StatusCode::FAILURE
Definition: StatusCode.h:31
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:111
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:209

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

Definition at line 1056 of file FileMgr.cpp.

1057 {
1058
1059 err = m_lastErrS;
1060 return m_lastErr;
1061 }
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 201 of file FileMgr.cpp.

201 {}

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

Definition at line 255 of file FileMgr.cpp.

256 {
257
258 auto itr = m_handlers.find( tech );
259 return ( itr != m_handlers.end() ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
260 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
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 86 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)" << endmsg;
94 return status;
95 }
96
97 ON_VERBOSE
98 verbose() << "Initializing FileMgr" << endmsg;
99
100 if ( m_loadRootHandler.value() ) {
101
102 // setup file handler for ROOT
103
104 msgSvc()->setOutputLevel( "RootFileHandler", m_outputLevel.value() );
105 m_rfh.reset( new RootFileHandler( msgSvc(), m_ssl_proxy, m_ssl_cert ) );
106
107 auto rfh = m_rfh.get(); // used in the lambdas to avoid capturing 'this'
108 Io::FileHdlr hdlr(
109 Io::ROOT, [rfh]( const std::string& n, const Io::IoFlags& f, const std::string& desc, Io::Fd& fd,
110 void*& ptr ) -> Io::open_t { return rfh->openRootFile( n, f, desc, fd, ptr ); },
111 [rfh]( void* ptr ) -> Io::close_t { return rfh->closeRootFile( ptr ); },
112 [rfh]( void* ptr, const Io::IoFlags& f ) -> Io::reopen_t { return rfh->reopenRootFile( ptr, f ); } );
113
114 if ( regHandler( hdlr ).isFailure() ) {
115 error() << "unable to register ROOT file handler with FileMgr" << endmsg;
116 }
117 }
118
119 if ( m_loadPosixHandler.value() ) {
120
121 // setup file handler for POSIX
122
123 msgSvc()->setOutputLevel( "POSIXFileHandler", m_outputLevel.value() );
124 m_pfh.reset( new POSIXFileHandler( msgSvc() ) );
125
126 auto pfh = m_pfh.get(); // used in the lambdas to avoid capturing 'this'
127 Io::FileHdlr hdlp(
128 Io::POSIX, [pfh]( const std::string& n, const Io::IoFlags& f, const std::string& desc, Io::Fd& fd,
129 void*& ptr ) -> Io::open_t { return pfh->openPOSIXFile( n, f, desc, fd, ptr ); },
130 [pfh]( Io::Fd fd ) -> Io::close_t { return pfh->closePOSIXFile( fd ); },
131 [pfh]( Io::Fd fd, const Io::IoFlags& f ) -> Io::reopen_t { return pfh->reopenPOSIXFile( fd, f ); } );
132
133 if ( regHandler( hdlp ).isFailure() ) {
134 error() << "unable to register ROOT file handler with FileMgr" << endmsg;
135 }
136 }
137
138 return StatusCode::SUCCESS;
139 }
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Service.h:183
FileMgr::regHandler
StatusCode regHandler(FileHdlr) override
Definition: FileMgr.cpp:205
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
StatusCode::SUCCESS
Definition: StatusCode.h:31
Io::ROOT
Definition: IFileMgr.h:157
Io::reopen_t
int reopen_t
Definition: IFileMgr.h:251
Io::Fd
int Fd
Definition: IFileMgr.h:171
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:123
Io::open_t
int open_t
Definition: IFileMgr.h:249
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
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:1003
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:228
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:111
Io::POSIX
Definition: IFileMgr.h:157
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
Io::IoFlags
Definition: IFileMgr.h:40
Io::FileHdlr
Definition: IFileMgr.h:260
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:120
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:76
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:209
Io::close_t
int close_t
Definition: IFileMgr.h:250
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 1137 of file FileMgr.cpp.

1138 {
1139
1140 info() << "listing registered actions" << endl;
1141
1142 for ( const auto& iit : m_actions ) {
1143 Io::IoTech t = iit.first;
1144 const actionMap& m = iit.second;
1145
1146 if ( !m.empty() ) {
1147 info() << " --- Tech: ";
1148 if ( t == Io::UNKNOWN ) {
1149 info() << "ALL ---" << endl;
1150 } else {
1151 info() << t << " ---" << endl;
1152 }
1153 for ( const auto& iia : m ) {
1154 for ( const auto& it2 : iia.second ) {
1155 info() << " " << iia.first << " " << it2.second << endl;
1156 }
1157 }
1158 }
1159 }
1160 info() << endmsg;
1161 }
Io::IoTech
IoTech
Definition: IFileMgr.h:157
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:117
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:94
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:139
Io::UNKNOWN
Definition: IFileMgr.h:157
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

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

Definition at line 1043 of file FileMgr.cpp.

1044 {
1045
1046 info() << "listing registered files [" << ( m_files.size() + m_oldFiles.size() ) << "]:" << endl;
1047
1048 for ( auto& itr : m_files ) info() << itr.second << endl;
1049 for ( auto& it2 : m_oldFiles ) info() << *it2 << endl;
1050
1051 info() << endmsg;
1052 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:117
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:209

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

Definition at line 1105 of file FileMgr.cpp.

1106 {
1107
1108 info() << "Listing registered handlers:" << endl;
1109
1110 for ( const auto& itr : m_handlers ) info() << " " << itr.first << endl;
1111 info() << endmsg;
1112 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:117
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:209

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

Definition at line 1260 of file FileMgr.cpp.

1261 {
1262
1263 if ( m_supMap.empty() ) return;
1264
1265 info() << "listing suppressed file actions" << endl;
1266
1267 for ( auto it2 = m_supMap.begin(); it2 != m_supMap.end(); ++it2 ) {
1268 info() << " " << it2->first;
1269 if ( get_bit( it2->second, Io::INVALID_ACTION ) ) {
1270 info() << " ALL" << endl;
1271 } else {
1272 for ( int i = 0; i < Io::INVALID_ACTION; ++i ) {
1273 if ( get_bit( it2->second, i ) ) {
1274 info() << " " << (Io::Action)i;
1275 }
1276 }
1277 info() << endl;
1278 }
1279 }
1280
1281 info() << endmsg;
1282 }
std::map::empty
T empty(T...args)
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:117
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:284
Io::Action
Action
Definition: IFileMgr.h:284
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:209

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

266 {
267
268 return open( tech, caller, fname, desc, flags, fd, ptr, sh );
269 }
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:264
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1003

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

274 {
275
276 void* dummy( 0 );
277 return open( tech, caller, fname, desc, flags, fd, dummy, sh );
278 }
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:264
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1003

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

283 {
284
285 Fd dummy( -1 );
286 return open( tech, caller, fname, desc, flags, dummy, ptr, sh );
287 }
Io::Fd
int Fd
Definition: IFileMgr.h:171
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:264

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

1117 {
1118
1119 return regAction( bf, a, Io::UNKNOWN, d );
1120 }
FileMgr::regAction
StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &desc="") override
Definition: FileMgr.cpp:1116
Io::UNKNOWN
Definition: IFileMgr.h:157

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

Definition at line 1124 of file FileMgr.cpp.

1125 {
1126
1127 ON_DEBUG
1128 debug() << "registering " << a << " action " << System::typeinfoName( bf.target_type() ) << " for tech " << t
1129 << endmsg;
1130
1131 m_actions[t][a].emplace_back( bf, ( !d.empty() ) ? d : System::typeinfoName( bf.target_type() ) );
1132 return StatusCode::SUCCESS;
1133 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
std::function::target_type
T target_type(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:120
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:209

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

Definition at line 205 of file FileMgr.cpp.

206 {
207
208 IoTech tech = fh.tech;
209
210 if ( m_handlers.find( tech ) != m_handlers.end() ) {
211 warning() << "Handler for IoTech " << tech << " already registered. Ignoring." << endmsg;
212 return StatusCode::SUCCESS;
213 }
214
215 if ( !fh.b_open_fcn ) {
216 error() << "open handler for tech " << tech << " is NULL" << endmsg;
217 return StatusCode::FAILURE;
218 }
219
220 if ( !fh.b_close_fcn && !fh.b_closeP_fcn ) {
221 error() << "no close handler for tech " << tech << " registered" << endmsg;
222 return StatusCode::FAILURE;
223 }
224
225 if ( !fh.b_reopen_fcn && !fh.b_reopenP_fcn ) {
226 error() << "no reopen handler for tech " << tech << " registered" << endmsg;
227 return StatusCode::FAILURE;
228 }
229
230 ON_DEBUG
231 debug() << "Successfully registered handler for tech \"" << tech << "\"" << endmsg;
232
233 m_handlers[tech] = fh;
234
235 return StatusCode::SUCCESS;
236 }
Io::IoTech
IoTech
Definition: IFileMgr.h:157
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
Io::FileHdlr::b_reopen_fcn
bfcn_reopen_t b_reopen_fcn
Definition: IFileMgr.h:266
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:111
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:114
Io::FileHdlr::b_close_fcn
bfcn_close_t b_close_fcn
Definition: IFileMgr.h:264
Io::FileHdlr::b_closeP_fcn
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:265
Io::FileHdlr::b_reopenP_fcn
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:267
std::map::find
T find(T...args)
Io::FileHdlr::b_open_fcn
bfcn_open_t b_open_fcn
Definition: IFileMgr.h:263
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:120
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
Io::FileHdlr::tech
IoTech tech
Definition: IFileMgr.h:261
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

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

701 {
702 ON_VERBOSE
703 verbose() << "reopen(" << vp << "," << flags << "," << caller << ")" << endmsg;
704
705 reopen_t r = -1;
706
707 auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
708 [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
709 if ( itr == m_files.end() ) {
710 error() << "unregistered file ptr \"" << vp << "\" when calling reopen()" << endmsg;
711 return r;
712 }
713
714 FileAttr* fa = itr->second;
715 FileHdlr fh;
716 IoTech tech = fa->tech();
717
718 if ( getHandler( tech, fh ).isFailure() ) {
719 return r;
720 }
721
722 if ( !fh.b_reopenP_fcn ) {
723 error() << "no reopen(" << tech << ",void*) function registered" << endmsg;
724 return -1;
725 }
726
727 try {
728 r = fh.b_reopenP_fcn( vp, flags );
729 } catch ( const std::bad_function_call& err ) {
730 error() << "when calling reopen handler for " << tech << " on file " << fa->name() << " with flags " << flags
731 << " caught " << err.what() << endmsg;
732 return -1;
733 } catch ( ... ) {
734 error() << "when calling reopen handler for " << tech << " on file " << fa->name() << " with flags " << flags
735 << " caught an unknown exception." << endmsg;
736 return -1;
737 }
738
739 if ( r < 0 ) {
740 warning() << "reopen of file with ptr \"" << vp << "\", name: \"" << fa->name() << "\", tech: \"" << tech
741 << "\", flags: \"" << flags << "\" failed" << endmsg;
742
743 execAction( fa, caller, Io::REOPEN_ERR ).ignore();
744
745 return r;
746 }
747
748 fa->isOpen( true );
749 fa->flags( flags );
750
751 // exec all callbacks
752 if ( execAction( fa, caller, Io::REOPEN ).isFailure() ) {
753 warning() << "at least one reopen callback action failed" << endmsg;
754 }
755
756 return r;
757 }
Io::IoTech
IoTech
Definition: IFileMgr.h:157
Io::REOPEN
Definition: IFileMgr.h:284
Io::reopen_t
int reopen_t
Definition: IFileMgr.h:251
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:123
Io::FileAttr::isOpen
bool isOpen() const
Definition: IFileMgr.h:195
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1165
std::end
T end(T...args)
Io::REOPEN_ERR
Definition: IFileMgr.h:284
CommonMessagingBase::err
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:108
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:189
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
std::bad_function_call
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:114
std::bad_function_call::what
T what(T...args)
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
Io::FileHdlr
Definition: IFileMgr.h:260
Io::FileHdlr::b_reopenP_fcn
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:267
std::find_if
T find_if(T...args)
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:191
std::begin
T begin(T...args)
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109
Io::FileAttr::flags
IoFlags flags() const
Definition: IFileMgr.h:192
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:209
Io::FileAttr
Definition: IFileMgr.h:173

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

Definition at line 1241 of file FileMgr.cpp.

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

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

Definition at line 1245 of file FileMgr.cpp.

1246 {
1247
1248 auto it2 = m_supMap.find( f );
1249 if ( it2 == m_supMap.end() ) {
1250 int b( 0 );
1251 set_bit( b, a );
1252 m_supMap[f] = b;
1253 } else {
1254 set_bit( it2->second, a );
1255 }
1256 }
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