| The Gaudi Framework v27r1

- 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 (const std::string &name, ISvcLocator *svc)
| ~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...
StatusCode | setProperty (const Property &p) override
StatusCode | setProperty (const std::string &s) override
StatusCode | setProperty (const std::string &n, const std::string &v) override
StatusCode | getProperty (Property *p) const override
const Property & | getProperty (const std::string &name) const override
StatusCode | getProperty (const std::string &n, std::string &v) const override
const std::vector< Property * > & | getProperties () const override
bool | hasProperty (const std::string &name) const override
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value 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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties. More...
template<class T >
StatusCode | declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Private tool. More...
template<class T >
StatusCode | declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Public tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from 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
StringProperty | m_logfile
BooleanProperty | m_printSummary
BooleanProperty | m_loadRootHandler
BooleanProperty | m_loadPosixHandler
StringProperty | m_ssl_proxy
StringProperty | m_ssl_cert
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 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 CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
IntegerProperty | m_outputLevel = MSG::NIL
| Service output level. More...
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. 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 143 of file FileMgr.h.

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

Definition at line 142 of file FileMgr.h.

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

Definition at line 153 of file FileMgr.h.

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

Definition at line 164 of file FileMgr.h.

## Constructor & Destructor Documentation

FileMgr::FileMgr | ( | const std::string & | name,
|  | ISvcLocator * | svc
| ) |  |

Definition at line 78 of file FileMgr.cpp.

79 : base_class( name, svc )
80 {
81
82 declareProperty("LogFile",m_logfile="");
83 declareProperty("PrintSummary",m_printSummary=false);
84 declareProperty("LoadROOTHandler", m_loadRootHandler=true);
85 declareProperty("LoadPOSIXHandler", m_loadPosixHandler=true);
86
87 declareProperty("TSSL_UserProxy", m_ssl_proxy="X509");
88 declareProperty("TSSL_CertDir", m_ssl_cert="X509");
89
90 m_lastErrS = "";
91
92 }
FileMgr::m_logfile
StringProperty m_logfile
Definition: FileMgr.h:133
extends< Service, IFileMgr, IIncidentListener >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
FileMgr::m_printSummary
BooleanProperty m_printSummary
Definition: FileMgr.h:134
FileMgr::m_lastErrS
std::string m_lastErrS
Definition: FileMgr.h:167
FileMgr::m_loadRootHandler
BooleanProperty m_loadRootHandler
Definition: FileMgr.h:134
FileMgr::m_loadPosixHandler
BooleanProperty m_loadPosixHandler
Definition: FileMgr.h:134
FileMgr::m_ssl_cert
StringProperty m_ssl_cert
Definition: FileMgr.h:135
Service::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
FileMgr::m_ssl_proxy
StringProperty m_ssl_proxy
Definition: FileMgr.h:135

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

Definition at line 96 of file FileMgr.cpp.

96 {
97 // Where do the new-ed FileAttr get deleted?
98 // they get pushed into m_descriptors, but m_attr is presumably
99 // where they _also_ should be pushed in order to track ownership...
100 }

## Member Function Documentation

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

Definition at line 1495 of file FileMgr.cpp.

1496 {
1497
1498 ON_VERBOSE
1499 verbose() << "accessMatch old: " << fold
1500 << " new: " << fnew
1501 << endmsg;
1502
1503 return ( ((fold == Io::READ) && (fnew == Io::READ)) ||
1504 ( (fold & Io::WRITE) != 0 && (fnew & Io::WRITE) != 0) ||
1505 ( (fold & Io::RDWR) != 0 && (fnew & Io::RDWR) != 0) ) ;
1506
1507 }
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:130
Io::RDWR
Definition: IFileMgr.h:28
Io::WRITE
Definition: IFileMgr.h:27
Io::READ
Definition: IFileMgr.h:26
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:12
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

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

Definition at line 681 of file FileMgr.cpp.

681 {
682
683 // return codes:
684 // < 0 : error condition
685 // 0 : actual close of one file
686 // > 0 : shared file, removed from list, no actual close, returns
687 // number of shared files still open.
688
689 ON_VERBOSE
690 verbose() << "close(" << vp << ")"
691 << endmsg;
692
693 close_t r = -1;
694
695 auto itr = std::find_if( std::begin(m_files), std::end(m_files),
696 [&](fileMap::const_reference i ) { return i.second->fptr()==vp; } );
697
698 if (itr == m_files.end()) {
699 error() << "unknown file ptr \"" << vp
700 << "\" when calling close()"
701 << endmsg;
702 return r;
703 }
704
705 IoTech tech = itr->second->tech();
706
707 FileHdlr fh;
708
709 if (getHandler(tech,fh).isFailure()) {
710 return r;
711 }
712 if (! fh.b_closeP_fcn) {
713 error() << "no close(" << tech << ",void*) function registered"
714 << endmsg;
715 return -1;
716 }
717
718 FileAttr *fa = itr->second;
719
720 // find how many times this file is open
721 pair<fileMap::const_iterator, fileMap::const_iterator> fitr =
722 m_files.equal_range(fa->name());
723
724 int i = std::count_if( fitr.first, fitr.second, [&](fileMap::const_reference f)
725 { return f.second->fptr()==vp; } );
726
727 ON_VERBOSE
728 verbose() << " ref count: " << i
729 << endmsg;
730
731 if (i > 1 && fa->isShared()) {
732 // file open multiple times in shared access. don't do the actual close
733 ON_DEBUG
734 debug() << "closing file " << fa->name() << " opened "
735 << i << " times with fptr " << vp << endmsg;
736 m_files.erase(itr);
737
738 r = i-1;
739
740 } else if (i == 1 || (i>1 && !fa->isShared()) ) {
741 ON_DEBUG
742 debug() << "closing: " << *fa << endmsg;
743
744 try {
745 r = fh.b_closeP_fcn(vp);
746 } catch (const std::bad_function_call& err) {
747 error() << "when calling close handler for " << tech
748 << " on file " << fa->name()
749 << " caught " << err.what() << endmsg;
750 execAction(fa, caller, CLOSE_ERR ).ignore();
751 return -1;
752 } catch (...) {
753 error() << "when calling close handler for " << tech
754 << " on file " << fa->name()
755 << " caught an unknown exception." << endmsg;
756 execAction(fa, caller, CLOSE_ERR ).ignore();
757 return -1;
758 }
759
760 if (r < 0) {
761 warning()
762 << "close of file with ptr \"" << vp
763 << "\", name: \"" << fa->name()
764 << "\", tech: \"" << tech << "\" failed"
765 << endmsg;
766
767 return r;
768 }
769
770 m_files.erase(itr);
771
772 } else {
773 // this should never happen!
774 error()
775 << "ref count: " << i << " < 0 when closing " << fa
776 << ". This should never happen"
777 << endmsg;
778 return -1;
779
780 }
781
782 fa->fd(-1);
783 fa->flags(INVALID);
784 fa->isOpen(false);
785 fa->fptr(0);
786 m_oldFiles.push_back( fa );
787
788
789 // exec all callbacks
790 if (execAction(fa, caller, CLOSE).isFailure()) {
791 warning()
792 << "at least one close callback action failed"
793 << endmsg;
794 }
795
796 return r;
797
798 }
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
Io::IoTech
IoTech
Definition: IFileMgr.h:150
Io::INVALID
Definition: IFileMgr.h:36
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:190
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:130
Io::FileAttr::isOpen
bool isOpen() const
Definition: IFileMgr.h:191
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1416
std::end
T end(T...args)
Io::FileAttr::fd
Fd fd() const
Definition: IFileMgr.h:184
CommonMessagingBase::err
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:115
Io::CLOSE
Definition: IFileMgr.h:292
Io::CLOSE_ERR
Definition: IFileMgr.h:295
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
std::vector::push_back
T push_back(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
std::bad_function_call
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:121
Io::FileAttr::isShared
bool isShared() const
Definition: IFileMgr.h:192
std::bad_function_call::what
T what(T...args)
std::multimap::erase
T erase(T...args)
Io::FileHdlr
Definition: IFileMgr.h:263
Io::FileHdlr::b_closeP_fcn
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:268
std::count_if
T count_if(T...args)
std::pair
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
std::find_if
T find_if(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
std::begin
T begin(T...args)
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
ana.i
list i
Definition: ana.py:128
Io::FileAttr::flags
IoFlags flags() const
Definition: IFileMgr.h:188
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:12
std::multimap::equal_range
T equal_range(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Io::close_t
int close_t
Definition: IFileMgr.h:253
Io::FileAttr
Definition: IFileMgr.h:174

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

Definition at line 321 of file FileMgr.cpp.

321 {
322 FileHdlr hdlr;
323
324 auto itr = m_handlers.find(tech);
325 if (itr == m_handlers.end()) {
326 error() << "Can't de-register tech " << tech
327 << " as it hasn't been registered!"
328 << endmsg;
329 return StatusCode::FAILURE;
330 }
331
332 m_handlers.erase(itr);
333 return StatusCode::SUCCESS;
334
335 }
std::map::end
T end(T...args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:156
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::map::erase
T erase(T...args)
Io::FileHdlr
Definition: IFileMgr.h:263
std::map::find
T find(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 1416 of file FileMgr.cpp.

1417 {
1418
1419 Io::IoTech tech = fa->tech();
1420
1421 StatusCode s1,s2;
1422
1423 auto itr = m_actions.find(Io::UNKNOWN);
1424
1425 if (itr != m_actions.end() && !itr->second.empty() ) {
1426 s1 = execActs(fa, caller, a, itr->second);
1427 }
1428
1429 itr = m_actions.find(tech);
1430 if (itr != m_actions.end() && !itr->second.empty() ) {
1431 s2 = execActs(fa, caller, a, itr->second);
1432 }
1433
1434 return (s1.isFailure() || s2.isFailure()) ? StatusCode::FAILURE
1435 : StatusCode::SUCCESS;
1436 }
Io::IoTech
IoTech
Definition: IFileMgr.h:150
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
HiveAlgSequencer.s2
tuple s2
Definition: HiveAlgSequencer.py:28
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
FileMgr::execActs
StatusCode execActs(Io::FileAttr *, const std::string &, const Io::Action &, const actionMap &m) const
Definition: FileMgr.cpp:1441
HiveAlgSequencer.s1
tuple s1
Definition: HiveAlgSequencer.py:27
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:187
Io::UNKNOWN
Definition: IFileMgr.h:151
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:162

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

Definition at line 1441 of file FileMgr.cpp.

1442 {
1443
1444 auto mitr = m.find(a);
1445
1446 if (mitr == m.end() || mitr->second.empty()) {
1447 return StatusCode::SUCCESS;
1448 }
1449
1450 ON_DEBUG
1451 debug()
1452 << "executing " << mitr->second.size() << " " << a
1453 << " actions on "
1454 << *fa << " from "
1455 << caller
1456 << endmsg;
1457
1458
1459 bool fail(false);
1460
1461 auto it2 = m_supMap.find(fa->name());
1462 if (it2 != m_supMap.end()) {
1463 if (get_bit(it2->second,a) || get_bit(it2->second,Io::INVALID_ACTION)) {
1464 ON_DEBUG
1465 debug() << " --> suppressing callback action for "
1466 << a
1467 << endmsg;
1468 return StatusCode::SUCCESS;
1469 }
1470 }
1471
1472 for (const auto& itr : mitr->second ) {
1473
1474 ON_DEBUG
1475 debug() << "executing "
1476 << itr.second << endmsg;
1477
1478 if ( (((itr.first))(fa,caller)).isFailure() ) {
1479 warning() << "execution of "
1480 << itr.second << " on " << *fa
1481 << " failed during " << a << " action"
1482 << endmsg;
1483 fail = true;
1484 }
1485
1486 }
1487
1488 return fail ? StatusCode::FAILURE : StatusCode::SUCCESS;
1489
1490 }
FileMgr::m_supMap
supMap m_supMap
Definition: FileMgr.h:165
std::map::end
T end(T...args)
Io::INVALID_ACTION
Definition: IFileMgr.h:297
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:121
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:93
std::map::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 1231 of file FileMgr.cpp.

1231 {
1232
1233 auto fitr = m_files.equal_range(fname);
1234 auto itr = std::find_if( fitr.first, fitr.second, [](fileMap::const_reference f) {
1235 return f.second->fd() != -1;
1236 } );
1237 return itr!=fitr.second ? itr->second->fd() : -1 ;
1238 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
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 1243 of file FileMgr.cpp.

1243 {
1244
1245 auto itr = std::find_if(m_files.begin(),m_files.end(),[&](fileMap::const_reference f) {
1246 return f.second->fptr() == fptr;
1247 } );
1248 return itr!=m_files.end() ? itr->second->fd() : -1 ;
1249 }
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:190
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::multimap::end
T end(T...args)
Io::FileAttr::fd
Fd fd() const
Definition: IFileMgr.h:184
std::find_if
T find_if(T...args)
std::multimap::begin
T begin(T...args)
FileMgr::fptr
void * fptr(const std::string &) const override
Definition: FileMgr.cpp:1254

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

Definition at line 199 of file FileMgr.cpp.

199 {
200 ON_VERBOSE
201 verbose() << "FileMgr::finalize()" << endmsg;
202
203
204 if (m_printSummary || msgLevel(MSG::DEBUG)) {
205 listHandlers();
206 listFiles();
207 listActions();
208 listSuppression();
209 }
210
211
212 if (!m_files.empty()) {
213 auto& log = warning();
214 log << "At finalize, the following files remained open:" << endl;
215 for (const auto& itr : m_files) log << *(itr.second) << endl;
216 log << endmsg;
217 }
218
219 if (m_logfile.value() != "") {
220 std::ofstream ofs;
221 ofs.open(m_logfile.value().c_str());
222 if (!ofs) {
223 error() << "Unable to open output file \"" << m_logfile.value()
224 << "\" for writing"
225 << endmsg;
226 } else {
227 ON_DEBUG
228 debug() << "Saving log to \"" << m_logfile.value() << "\""
229 << endmsg;
230 for (const auto& itr : m_files) {
231 ofs << itr.second->name() << " " << itr.second->tech() << " "
232 << itr.second->desc() << " " << itr.second->iflags() << endl;
233 }
234
235 set<FileAttr> fs;
236 for (const auto& it2 : m_oldFiles) fs.insert(*it2);
237 for (const auto& it3 : fs ) {
238 ofs << it3.name() << " " << it3.tech() << " " << it3.desc()
239 << " " << it3.iflags()
240 << ( it3.isShared() ? " SHARED" : "" )
241 << endl;
242 }
243 ofs.close();
244 }
245 }
246
247 // cleanup FileAttrs
248 m_attr.clear();
249
250 m_rfh.reset();
251 m_pfh.reset();
252
253
254 StatusCode status = Service::finalize();
255
256 ON_DEBUG
257 if ( status.isSuccess() )
258 debug() << "Service finalised successfully" << endmsg;
259
260 return status;
261
262 }
FileMgr::m_attr
std::vector< std::unique_ptr< FileAttr > > m_attr
Definition: FileMgr.h:158
FileMgr::m_logfile
StringProperty m_logfile
Definition: FileMgr.h:133
std::multimap::empty
T empty(T...args)
std::ofstream::open
T open(T...args)
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:193
Gaudi.Configuration.log
tuple log
Definition: Configuration.py:13
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:130
MSG::DEBUG
Definition: IMessageSvc.h:18
std::endl
T endl(T...args)
FileMgr::m_rfh
std::unique_ptr< RootFileHandler > m_rfh
Definition: FileMgr.h:170
FileMgr::listActions
virtual void listActions() const
Definition: FileMgr.cpp:1387
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
std::ofstream
STL class.
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:121
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::ofstream::close
T close(T...args)
FileMgr::m_printSummary
BooleanProperty m_printSummary
Definition: FileMgr.h:134
FileMgr::m_pfh
std::unique_ptr< POSIXFileHandler > m_pfh
Definition: FileMgr.h:171
std::unique_ptr::reset
T reset(T...args)
std::vector::clear
T clear(T...args)
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
std::set::insert
T insert(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
std::set
STL class.
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
FileMgr::listSuppression
virtual void listSuppression() const
Definition: FileMgr.cpp:1537
std::string::c_str
T c_str(T...args)
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
FileMgr::listFiles
void listFiles() const override
Definition: FileMgr.cpp:1276
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:136
FileMgr::listHandlers
void listHandlers() const override
Definition: FileMgr.cpp:1348
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:12
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 1208 of file FileMgr.cpp.

1208 {
1209
1210 auto itr = std::find_if( std::begin(m_files), std::end(m_files),
1211 [&](fileMap::const_reference f) { return f.second->fd() == fd; } );
1212 return (itr!=std::end(m_files)) ? itr->second->name() : s_empty;
1213
1214 }
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1231
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::end
T end(T...args)
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 1219 of file FileMgr.cpp.

1219 {
1220
1221 auto itr = std::find_if( m_files.begin(), m_files.end(),
1222 [&](fileMap::const_reference f) {
1223 return f.second->fptr() == vp;
1224 });
1225 return itr!=m_files.end() ? itr->second->name() : s_empty;
1226 }
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:190
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::multimap::end
T end(T...args)
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
std::find_if
T find_if(T...args)
std::multimap::begin
T begin(T...args)

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

Definition at line 1254 of file FileMgr.cpp.

1254 {
1255 auto fitr = m_files.equal_range(fname);
1256 auto itr = std::find_if( fitr.first, fitr.second, [](fileMap::const_reference f) -> bool {
1257 return f.second->fptr();
1258 } );
1259 return itr!=fitr.second ? itr->second->fptr() : nullptr;
1260 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
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 1265 of file FileMgr.cpp.

1265 {
1266
1267 auto itr = std::find_if(m_files.begin(),m_files.end(),[&](fileMap::const_reference f) {
1268 return f.second->fd() == fd;
1269 } );
1270 return itr!=m_files.end() ? itr->second->fptr() : nullptr;
1271 }
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1231
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:190
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::multimap::end
T end(T...args)
Io::FileAttr::fd
Fd fd() const
Definition: IFileMgr.h:184
std::find_if
T find_if(T...args)
std::multimap::begin
T begin(T...args)

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

1175 {
1176
1177 if (tech == UNKNOWN) return getFd( fd );
1178
1179 fd.clear();
1180 transform_if( std::begin(m_descriptors), std::end(m_descriptors), std::back_inserter(fd),
1181 select1st,
1182 [&](const std::pair<Fd,FileAttr*>& d) { return d.second->tech()==tech; } );
1183
1184 return fd.size();
1185
1186 }
select1st
constexpr struct select1st_t select1st
std::end
T end(T...args)
FileMgr::m_descriptors
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:157
std::vector::clear
T clear(T...args)
std::pair
std::vector::size
T size(T...args)
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
Io::UNKNOWN
Definition: IFileMgr.h:151
FileMgr::getFd
int getFd(std::vector< Fd > &) const override

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

Definition at line 1193 of file FileMgr.cpp.

1193 {
1194
1195 fd.clear();
1196 transform_if( m_descriptors.begin(), m_descriptors.end(),
1197 std::back_inserter(fd), select1st,
1198 [&](const std::pair<Fd,FileAttr*>& d) {
1199 return (d.second->tech() == tech || tech == UNKNOWN) &&
1200 ( d.second->flags() == flags );
1201 } );
1202 return fd.size();
1203 }
select1st
constexpr struct select1st_t select1st
std::map::end
T end(T...args)
FileMgr::m_descriptors
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:157
std::vector::clear
T clear(T...args)
std::pair
std::vector::size
T size(T...args)
std::map::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
Io::UNKNOWN
Definition: IFileMgr.h:151

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

Definition at line 970 of file FileMgr.cpp.

970 {
971
972 fa.clear();
973
974 auto fitr = m_files.equal_range(fname);
975 std::transform( fitr.first, fitr.second, std::back_inserter(fa), select2nd );
976
977 std::copy_if( std::begin(m_oldFiles), std::end(m_oldFiles),
978 std::back_inserter(fa), [&](const FileAttr* f ) { return f->name() == fname; } );
979
980 return fa.size();
981
982 }
std::copy_if
T copy_if(T...args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::end
T end(T...args)
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
std::vector::size
T size(T...args)
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:1208
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:174

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

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

Definition at line 1010 of file FileMgr.cpp.

1010 {
1011
1012 auto i = std::find_if( std::begin(m_files), std::end(m_files),
1013 [&](fileMap::const_reference f) { return f.second->fptr() == vp; } );
1014 if (i != std::end(m_files)) {
1015 fa = i->second;
1016 return StatusCode::SUCCESS;
1017 }
1018
1019 auto j = std::find_if( std::begin(m_oldFiles), std::end(m_oldFiles),
1020 [&](const FileAttr* f) { return f->fptr() == vp; } );
1021 if (j != std::end(m_oldFiles)) {
1022 fa = *j;
1023 return StatusCode::SUCCESS;
1024 }
1025
1026 return StatusCode::FAILURE;
1027
1028 }
Io::FileAttr::fptr
void * fptr() const
Definition: IFileMgr.h:190
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::end
T end(T...args)
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
std::find_if
T find_if(T...args)
std::begin
T begin(T...args)
ana.i
list i
Definition: ana.py:128
Io::FileAttr
Definition: IFileMgr.h:174

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

Definition at line 1033 of file FileMgr.cpp.

1033 {
1034
1035 files.clear();
1036 auto not_in_files = [&](const std::string& i) { return std::none_of( std::begin(files), std::end(files),
1037 [&](const std::string& j) { return j==i; } ); };
1038 transform_copy_if( std::begin(m_files), std::end(m_files), std::back_inserter(files),
1039 to_name,
1040 not_in_files );
1041 if (!op) {
1042 transform_copy_if( std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files),
1043 to_name,
1044 not_in_files );
1045 }
1046 return files.size();
1047 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
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:160
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)
ana.i
list i
Definition: ana.py:128

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

Definition at line 1052 of file FileMgr.cpp.

1052 {
1053
1054 files.clear();
1055 std::transform(std::begin(m_files), std::end(m_files), std::back_inserter(files),
1056 select2nd );
1057 if (!op) {
1058 std::copy(std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files));
1059 }
1060 return files.size();
1061
1062 }
std::copy
T copy(T...args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::end
T end(T...args)
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
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 1067 of file FileMgr.cpp.

1067 {
1068
1069 if (tech == UNKNOWN) return getFiles(files,op);
1070
1071 files.clear();
1072 transform_if( std::begin(m_files), std::end(m_files), std::back_inserter(files),
1073 to_name,
1074 [&](fileMap::const_reference f) { return f.second->tech() == tech &&
1075 std::none_of( std::begin(files), std::end(files), [&](const std::string& j) { return j==f.first; } ); } );
1076
1077 if (!op) {
1078 transform_if( std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files),
1079 to_name,
1080 [&](const FileAttr* f) { return f->tech() == tech &&
1081 std::none_of( std::begin(files), std::end(files), [&](const std::string& j) { return j == f->name(); } ) ; } );
1082 }
1083 return files.size();
1084
1085 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::end
T end(T...args)
std::string
STL class.
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
std::vector::size
T size(T...args)
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:187
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
std::none_of
T none_of(T...args)
FileMgr::getFiles
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:1033
Io::UNKNOWN
Definition: IFileMgr.h:151
Io::FileAttr
Definition: IFileMgr.h:174

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

Definition at line 1090 of file FileMgr.cpp.

1091 {
1092
1093 if (tech == UNKNOWN) return getFiles(files,op);
1094
1095 auto matches_tech = [&](const FileAttr* f) { return f->tech()==tech; } ;
1096
1097 files.clear();
1098 transform_copy_if( std::begin(m_files), std::end(m_files), std::back_inserter(files),
1099 select2nd, matches_tech );
1100 if (!op) {
1101 std::copy_if( std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files),
1102 matches_tech );
1103 }
1104
1105 return files.size();
1106
1107 }
std::copy_if
T copy_if(T...args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::end
T end(T...args)
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
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:1033
Io::UNKNOWN
Definition: IFileMgr.h:151
Io::FileAttr
Definition: IFileMgr.h:174

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

Definition at line 1112 of file FileMgr.cpp.

1113 {
1114
1115 files.clear();
1116
1117 auto not_in_files = [&](const std::string& n) { return std::none_of( std::begin(files), std::end(files),
1118 [&](const std::string& f) { return f==n; } ); };
1119 auto matches_tech_and_flags = [&](const FileAttr* f) { return ( f->tech() == tech || tech == UNKNOWN ) && f->flags() == flags ; } ;
1120
1121 transform_if( std::begin(m_files), std::end(m_files), std::back_inserter(files),
1122 to_name,
1123 [&](fileMap::const_reference f) { return matches_tech_and_flags( f.second ) && not_in_files( f.first ); } );
1124 if (!op) {
1125 transform_if( std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files),
1126 to_name,
1127 [&](const FileAttr* f) { return matches_tech_and_flags(f) && not_in_files(f->name()); } );
1128 }
1129
1130 return files.size();
1131
1132 }
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::end
T end(T...args)
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
std::string
STL class.
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
std::vector::size
T size(T...args)
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
std::none_of
T none_of(T...args)
Io::UNKNOWN
Definition: IFileMgr.h:151
Io::FileAttr
Definition: IFileMgr.h:174

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

Definition at line 1136 of file FileMgr.cpp.

1137 {
1138
1139 files.clear();
1140
1141 auto matches_tech_and_flags = [&](const FileAttr* f) { return ( f->tech() == tech || tech == UNKNOWN )
1142 && f->flags() == flags ; } ;
1143
1144 transform_copy_if( std::begin(m_files), std::end(m_files), std::back_inserter(files),
1145 select2nd,
1146 matches_tech_and_flags );
1147 if (!op) {
1148 std::copy_if( std::begin(m_oldFiles), std::end(m_oldFiles), std::back_inserter(files),
1149 matches_tech_and_flags );
1150 }
1151
1152 return files.size();
1153 }
std::copy_if
T copy_if(T...args)
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::end
T end(T...args)
std::vector::clear
T clear(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
std::vector::size
T size(T...args)
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
Io::UNKNOWN
Definition: IFileMgr.h:151
Io::FileAttr
Definition: IFileMgr.h:174

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

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

Definition at line 1317 of file FileMgr.cpp.

1317 {
1318
1319 auto fitr = m_files.equal_range(fname);
1320 if (fitr.first == fitr.second) {
1321 error()
1322 << "no file \"" << fname << "\" registered. Cannot determine tech"
1323 << endmsg;
1324 return StatusCode::FAILURE;
1325 }
1326
1327 auto itr = fitr.first;
1328 IoTech tech = itr->second->tech();
1329
1330 ++itr;
1331 while( itr != fitr.second ) {
1332 if ( itr->second->tech() != tech ) {
1333 error()
1334 << "multiple technologies registered for file \"" << fname
1335 << "\". Cannot determine handler" << endmsg;
1336 return StatusCode::FAILURE;
1337 }
1338 ++itr;
1339 }
1340
1341 return getHandler(tech,hdlr);
1342
1343 }
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
Io::IoTech
IoTech
Definition: IFileMgr.h:150
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
std::multimap::equal_range
T equal_range(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 1291 of file FileMgr.cpp.

1291 {
1292
1293 err = m_lastErrS;
1294 return m_lastErr;
1295
1296 }
FileMgr::m_lastErrS
std::string m_lastErrS
Definition: FileMgr.h:167
FileMgr::m_lastErr
int m_lastErr
Definition: FileMgr.h:168

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

Definition at line 267 of file FileMgr.cpp.

267 {
268
269 }

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

Definition at line 339 of file FileMgr.cpp.

339 {
340
341 auto itr = m_handlers.find(tech);
342 return (itr != m_handlers.end()) ? StatusCode::SUCCESS : StatusCode::FAILURE;
343
344 }
std::map::end
T end(T...args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:156
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::map::find
T find(T...args)

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

Definition at line 105 of file FileMgr.cpp.

105 {
106
107 // Super ugly hack to make sure we have the OutputLevel set first, so we
108 // can see DEBUG printouts in update handlers.
109 auto jos = serviceLocator()->service<IJobOptionsSvc>( "JobOptionsSvc", true );
110 const auto *props = ( jos ? jos->getProperties( name() ) : nullptr );
111 if (props) {
112 auto prop = std::find_if( std::begin(*props), std::end(*props),
113 [&](const Property* p) {
114 return p->name() == "OutputLevel";
115 });
116 if (prop!=std::end(*props)) {
117 setProperty( **prop ).ignore();
118 }
119 }
120
121 StatusCode status = Service::initialize();
122
123 if (status.isFailure()) {
124
125 ON_DEBUG
126 debug() << "Failed to initialize the base class (Service)"
127 << endmsg;
128 return status;
129 }
130
131 ON_VERBOSE
132 verbose() << "Initializing FileMgr" << endmsg;
133
134 if (m_loadRootHandler.value()) {
135
136 // setup file handler for ROOT
137
138 msgSvc()->setOutputLevel( "RootFileHandler", m_outputLevel.value());
139 m_rfh.reset( new RootFileHandler(msgSvc(), m_ssl_proxy, m_ssl_cert) );
140
141 auto rfh = m_rfh.get(); // used in the lambdas to avoid capturing 'this'
142 Io::FileHdlr hdlr(Io::ROOT,
143 [rfh](const std::string& n, const Io::IoFlags& f,
144 const std::string& desc, Io::Fd& fd,
145 void*& ptr) -> Io::open_t {
146 return rfh->openRootFile(n, f, desc, fd, ptr);
147 },
148 [rfh](void* ptr) -> Io::close_t {
149 return rfh->closeRootFile(ptr);
150 },
151 [rfh](void* ptr, const Io::IoFlags& f) -> Io::reopen_t {
152 return rfh->reopenRootFile(ptr, f);
153 });
154
155 if (regHandler(hdlr).isFailure()) {
156 error()
157 << "unable to register ROOT file handler with FileMgr"
158 << endmsg;
159 }
160 }
161
162 if (m_loadPosixHandler.value()) {
163
164 // setup file handler for POSIX
165
166 msgSvc()->setOutputLevel( "POSIXFileHandler", m_outputLevel.value());
167 m_pfh.reset( new POSIXFileHandler(msgSvc()) );
168
169 auto pfh = m_pfh.get(); // used in the lambdas to avoid capturing 'this'
170 Io::FileHdlr hdlp(Io::POSIX,
171 [pfh](const std::string& n, const Io::IoFlags& f,
172 const std::string& desc, Io::Fd& fd,
173 void*& ptr) -> Io::open_t {
174 return pfh->openPOSIXFile(n, f, desc, fd, ptr);
175 },
176 [pfh](Io::Fd fd) -> Io::close_t {
177 return pfh->closePOSIXFile(fd);
178 },
179 [pfh](Io::Fd fd, const Io::IoFlags& f) -> Io::reopen_t {
180 return pfh->reopenPOSIXFile(fd, f);
181 });
182
183 if (regHandler(hdlp).isFailure()) {
184 error()
185 << "unable to register ROOT file handler with FileMgr"
186 << endmsg;
187 }
188 }
189
190
191
192 return StatusCode::SUCCESS;
193
194 }
FileMgr::regHandler
StatusCode regHandler(FileHdlr) override
Definition: FileMgr.cpp:274
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1231
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:68
Service::m_outputLevel
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
Io::ROOT
Definition: IFileMgr.h:153
Property::name
const std::string & name() const
property name
Definition: Property.h:45
Io::reopen_t
int reopen_t
Definition: IFileMgr.h:254
Io::Fd
int Fd
Definition: IFileMgr.h:172
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:130
Service::setProperty
StatusCode setProperty(const Property &p) override
Definition: Service.cpp:330
Io::open_t
int open_t
Definition: IFileMgr.h:252
std::end
T end(T...args)
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
POSIXFileHandler
Definition: POSIXFileHandler.h:17
FileMgr::m_rfh
std::unique_ptr< RootFileHandler > m_rfh
Definition: FileMgr.h:170
std::string
STL class.
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
Io::POSIX
Definition: IFileMgr.h:152
IJobOptionsSvc
Main interface for the JobOptions service.
Definition: IJobOptionsSvc.h:20
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Io::IoFlags
Definition: IFileMgr.h:39
Io::FileHdlr
Definition: IFileMgr.h:263
RootFileHandler
Definition: RootFileHandler.h:17
FileMgr::m_pfh
std::unique_ptr< POSIXFileHandler > m_pfh
Definition: FileMgr.h:171
std::unique_ptr::reset
T reset(T...args)
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
FileMgr::m_loadRootHandler
BooleanProperty m_loadRootHandler
Definition: FileMgr.h:134
std::unique_ptr::get
T get(T...args)
std::find_if
T find_if(T...args)
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
FileMgr::m_loadPosixHandler
BooleanProperty m_loadPosixHandler
Definition: FileMgr.h:134
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
std::begin
T begin(T...args)
FileMgr::m_ssl_cert
StringProperty m_ssl_cert
Definition: FileMgr.h:135
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
FileMgr::m_ssl_proxy
StringProperty m_ssl_proxy
Definition: FileMgr.h:135
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:12
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Io::close_t
int close_t
Definition: IFileMgr.h:253
IMessageSvc::setOutputLevel
virtual void setOutputLevel(int new_level)=0
Set new global output level threshold.

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

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

Definition at line 1387 of file FileMgr.cpp.

1387 {
1388
1389 info() << "listing registered actions" << endl;
1390
1391 for (const auto& iit : m_actions) {
1392 Io::IoTech t = iit.first;
1393 const actionMap& m = iit.second;
1394
1395 if (!m.empty()) {
1396 info() << " --- Tech: ";
1397 if (t == Io::UNKNOWN) {
1398 info() << "ALL ---" << endl;
1399 } else {
1400 info() << t << " ---" << endl;
1401 }
1402 for (const auto& iia : m ) {
1403 for (const auto& it2 : iia.second ) {
1404 info() << " " << iia.first << " "
1405 << it2.second << endl;
1406 }
1407 }
1408 }
1409 }
1410 info() << endmsg;
1411 }
Io::IoTech
IoTech
Definition: IFileMgr.h:150
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
std::endl
T endl(T...args)
FileMgr::actionMap
std::map< Io::Action, std::list< bfcn_desc_t > > actionMap
Definition: FileMgr.h:143
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:93
Io::UNKNOWN
Definition: IFileMgr.h:151
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:162

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

Definition at line 1276 of file FileMgr.cpp.

1276 {
1277
1278 info() << "listing registered files ["
1279 << (m_files.size() + m_oldFiles.size() )
1280 << "]:" << endl;
1281
1282 for (auto& itr : m_files ) info() << itr.second << endl;
1283 for (auto& it2 : m_oldFiles ) info() << *it2 << endl;
1284
1285 info() << endmsg;
1286 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
std::endl
T endl(T...args)
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
std::multimap::size
T size(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 1348 of file FileMgr.cpp.

1348 {
1349
1350 info()
1351 << "Listing registered handlers:" << endl;
1352
1353 for (const auto& itr : m_handlers ) info() << " " << itr.first << endl;
1354 info() << endmsg;
1355
1356 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
std::endl
T endl(T...args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:156
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 1537 of file FileMgr.cpp.

1537 {
1538
1539 if (m_supMap.empty()) return;
1540
1541 info() << "listing suppressed file actions" << endl;
1542
1543 for (auto it2=m_supMap.begin(); it2 != m_supMap.end(); ++it2) {
1544 info() << " " << it2->first;
1545 if (get_bit(it2->second, Io::INVALID_ACTION)) {
1546 info() << " ALL" << endl;
1547 } else {
1548 for (int i=0; i<Io::INVALID_ACTION; ++i) {
1549 if (get_bit(it2->second,i)) { info() << " " << (Io::Action)i; }
1550 }
1551 info() << endl;
1552 }
1553 }
1554
1555 info() << endmsg;
1556 }
std::map::empty
T empty(T...args)
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
FileMgr::m_supMap
supMap m_supMap
Definition: FileMgr.h:165
std::endl
T endl(T...args)
std::map::end
T end(T...args)
Io::INVALID_ACTION
Definition: IFileMgr.h:297
Io::Action
Action
Definition: IFileMgr.h:290
std::map::begin
T begin(T...args)
ana.i
list i
Definition: ana.py:128
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 349 of file FileMgr.cpp.

352 {
353
354 return open(tech, caller, fname, desc, flags, fd, ptr, sh);
355
356 }
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1231
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:349

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

363 {
364
365 void* dummy(0);
366 return open(tech, caller, fname, desc, flags, fd, dummy, sh);
367
368 }
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1231
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:349

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

375 {
376
377 Fd dummy(-1);
378 return open(tech, caller, fname, desc, flags, dummy, ptr, sh);
379
380 }
Io::Fd
int Fd
Definition: IFileMgr.h:172
FileMgr::open
Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &fd, void *&ptr, const std::string &desc="", const bool shared=false) override
Definition: FileMgr.cpp:349

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

1361 {
1362
1363 return regAction(bf,a,Io::UNKNOWN,d);
1364
1365 }
FileMgr::regAction
StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &desc="") override
Definition: FileMgr.cpp:1361
Io::UNKNOWN
Definition: IFileMgr.h:151

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

Definition at line 1370 of file FileMgr.cpp.

1371 {
1372
1373 ON_DEBUG
1374 debug() << "registering " << a << " action "
1375 << System::typeinfoName(bf.target_type())
1376 << " for tech " << t << endmsg;
1377
1378 m_actions[t][a].emplace_back(bf, (!d.empty()) ? d
1379 : System::typeinfoName(bf.target_type()));
1380 return StatusCode::SUCCESS;
1381
1382 }
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::function::target_type
T target_type(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:162

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

Definition at line 274 of file FileMgr.cpp.

274 {
275
276 IoTech tech = fh.tech;
277
278 if (m_handlers.find(tech) != m_handlers.end()) {
279 warning()
280 << "Handler for IoTech " << tech << " already registered. Ignoring."
281 << endmsg;
282 return StatusCode::SUCCESS;
283 }
284
285 if ( ! fh.b_open_fcn ) {
286 error()
287 << "open handler for tech " << tech << " is NULL"
288 << endmsg;
289 return StatusCode::FAILURE;
290 }
291
292 if ( ! fh.b_close_fcn && ! fh.b_closeP_fcn ) {
293 error()
294 << "no close handler for tech " << tech << " registered"
295 << endmsg;
296 return StatusCode::FAILURE;
297 }
298
299 if ( ! fh.b_reopen_fcn && ! fh.b_reopenP_fcn) {
300 error()
301 << "no reopen handler for tech " << tech << " registered"
302 << endmsg;
303 return StatusCode::FAILURE;
304 }
305
306
307 ON_DEBUG
308 debug()
309 << "Successfully registered handler for tech \"" << tech << "\""
310 << endmsg;
311
312 m_handlers[tech] = fh;
313
314 return StatusCode::SUCCESS;
315
316 }
Io::IoTech
IoTech
Definition: IFileMgr.h:150
Io::FileHdlr::b_reopen_fcn
bfcn_reopen_t b_reopen_fcn
Definition: IFileMgr.h:269
std::map::end
T end(T...args)
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:156
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:121
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
Io::FileHdlr::b_close_fcn
bfcn_close_t b_close_fcn
Definition: IFileMgr.h:267
Io::FileHdlr::b_closeP_fcn
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:268
Io::FileHdlr::b_reopenP_fcn
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:270
std::map::find
T find(T...args)
Io::FileHdlr::b_open_fcn
bfcn_open_t b_open_fcn
Definition: IFileMgr.h:266
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
ON_DEBUG
#define ON_DEBUG
Definition: FileMgr.cpp:11
Io::FileHdlr::tech
IoTech tech
Definition: IFileMgr.h:264
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

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

Definition at line 890 of file FileMgr.cpp.

890 {
891 ON_VERBOSE
892 verbose() << "reopen(" << vp << "," << flags
893 << "," << caller << ")"
894 << endmsg;
895
896 reopen_t r = -1;
897
898 auto itr = std::find_if( std::begin(m_files), std::end(m_files),
899 [&](fileMap::const_reference f) {
900 return f.second->fptr() == vp ; } );
901 if (itr == m_files.end()) {
902 error()
903 << "unregistered file ptr \"" << vp
904 << "\" when calling reopen()"
905 << endmsg;
906 return r;
907 }
908
909 FileAttr *fa = itr->second;
910 FileHdlr fh;
911 IoTech tech = fa->tech();
912
913 if (getHandler(tech,fh).isFailure()) {
914 return r;
915 }
916
917 if ( ! fh.b_reopenP_fcn ) {
918 error() << "no reopen(" << tech << ",void*) function registered"
919 << endmsg;
920 return -1;
921 }
922
923 try {
924 r = fh.b_reopenP_fcn(vp,flags);
925 } catch (const std::bad_function_call& err) {
926 error() << "when calling reopen handler for " << tech
927 << " on file " << fa->name() << " with flags "
928 << flags
929 << " caught " << err.what() << endmsg;
930 return -1;
931 } catch (...) {
932 error() << "when calling reopen handler for " << tech
933 << " on file " << fa->name() << " with flags "
934 << flags
935 << " caught an unknown exception." << endmsg;
936 return -1;
937 }
938
939 if (r < 0) {
940 warning()
941 << "reopen of file with ptr \"" << vp
942 << "\", name: \"" << fa->name()
943 << "\", tech: \"" << tech
944 << "\", flags: \"" << flags << "\" failed"
945 << endmsg;
946
947 execAction(fa, caller, Io::REOPEN_ERR ).ignore();
948
949 return r;
950
951 }
952
953 fa->isOpen(true);
954 fa->flags(flags);
955
956 // exec all callbacks
957 if (execAction(fa, caller, Io::REOPEN).isFailure()) {
958 warning()
959 << "at least one reopen callback action failed"
960 << endmsg;
961 }
962
963 return r;
964
965 }
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
Io::IoTech
IoTech
Definition: IFileMgr.h:150
Io::REOPEN
Definition: IFileMgr.h:293
Io::reopen_t
int reopen_t
Definition: IFileMgr.h:254
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:130
Io::FileAttr::isOpen
bool isOpen() const
Definition: IFileMgr.h:191
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1416
std::end
T end(T...args)
Io::REOPEN_ERR
Definition: IFileMgr.h:296
CommonMessagingBase::err
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:115
Io::FileAttr::name
const std::string & name() const
Definition: IFileMgr.h:185
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
std::bad_function_call
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:121
std::bad_function_call::what
T what(T...args)
Io::FileHdlr
Definition: IFileMgr.h:263
Io::FileHdlr::b_reopenP_fcn
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:270
std::find_if
T find_if(T...args)
Io::FileAttr::tech
IoTech tech() const
Definition: IFileMgr.h:187
std::begin
T begin(T...args)
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
Io::FileAttr::flags
IoFlags flags() const
Definition: IFileMgr.h:188
ON_VERBOSE
#define ON_VERBOSE
Definition: FileMgr.cpp:12
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Io::FileAttr
Definition: IFileMgr.h:174

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

Definition at line 1512 of file FileMgr.cpp.

1512 {
1513
1514 return suppressAction(f,Io::INVALID_ACTION);
1515
1516 }
FileMgr::suppressAction
void suppressAction(const std::string &) override
Definition: FileMgr.cpp:1512
Io::INVALID_ACTION
Definition: IFileMgr.h:297

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

Definition at line 1521 of file FileMgr.cpp.

1521 {
1522
1523 auto it2 = m_supMap.find(f);
1524 if (it2 == m_supMap.end()) {
1525 int b(0);
1526 set_bit(b,a);
1527 m_supMap[f] = b;
1528 } else {
1529 set_bit(it2->second, a);
1530 }
1531
1532 }
FileMgr::m_supMap
supMap m_supMap
Definition: FileMgr.h:165
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 162 of file FileMgr.h.

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

Definition at line 158 of file FileMgr.h.

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

Definition at line 157 of file FileMgr.h.

fileMap FileMgr::m_files
| private

Definition at line 155 of file FileMgr.h.

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

Definition at line 156 of file FileMgr.h.

int FileMgr::m_lastErr
| private

Definition at line 168 of file FileMgr.h.

std::string FileMgr::m_lastErrS
| private

Definition at line 167 of file FileMgr.h.

BooleanProperty FileMgr::m_loadPosixHandler
| private

Definition at line 134 of file FileMgr.h.

BooleanProperty FileMgr::m_loadRootHandler
| private

Definition at line 134 of file FileMgr.h.

StringProperty FileMgr::m_logfile
| private

Definition at line 133 of file FileMgr.h.

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

Definition at line 160 of file FileMgr.h.

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

Definition at line 171 of file FileMgr.h.

BooleanProperty FileMgr::m_printSummary
| private

Definition at line 134 of file FileMgr.h.

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

Definition at line 170 of file FileMgr.h.

StringProperty FileMgr::m_ssl_cert
| private

Definition at line 135 of file FileMgr.h.

StringProperty FileMgr::m_ssl_proxy
| private

Definition at line 135 of file FileMgr.h.

supMap FileMgr::m_supMap
| private

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