FileMgr Class Reference

#include <src/FileMgr/FileMgr.h>

Inheritance diagram for FileMgr:
Collaboration diagram for FileMgr:

Public Member Functions

 FileMgr (const std::string &name, ISvcLocator *svc)
 
virtual ~FileMgr ()
 
virtual StatusCode initialize ()
 Initialization (from CONFIGURED to INITIALIZED). More...
 
virtual StatusCode finalize ()
 Finalize (from INITIALIZED to CONFIGURED). More...
 
virtual void handle (const Incident &)
 Inform that a new incident has occurred. More...
 
virtual StatusCode regHandler (FileHdlr)
 
virtual StatusCode hasHandler (const IoTech &) const
 
virtual StatusCode deregHandler (const IoTech &)
 
virtual StatusCode getHandler (const IoTech &, FileHdlr &) const
 
virtual StatusCode getHandler (const std::string &, FileHdlr &) const
 
virtual int getFileAttr (const std::string &, std::vector< const FileAttr * > &) const
 
virtual StatusCode getFileAttr (const Fd, const FileAttr *&) const
 
virtual StatusCode getFileAttr (void *, const FileAttr *&) const
 
virtual void listHandlers () const
 
virtual void listFiles () const
 
virtual void listActions () const
 
virtual void listSuppression () const
 
virtual int getFiles (std::vector< std::string > &, bool onlyOpen=true) const
 
virtual int getFiles (std::vector< const Io::FileAttr * > &, bool onlyOpen=true) const
 
virtual int getFiles (const Io::IoTech &, std::vector< std::string > &, bool onlyOpen=true) const
 
virtual int getFiles (const Io::IoTech &, std::vector< const Io::FileAttr * > &, bool onlyOpen=true) const
 
virtual int getFiles (const Io::IoTech &, const Io::IoFlags &, std::vector< std::string > &, bool onlyOpen=true) const
 
virtual int getFiles (const Io::IoTech &, const Io::IoFlags &, std::vector< const Io::FileAttr * > &, bool onlyOpen=true) const
 
virtual int getFd (std::vector< Fd > &) const
 
virtual int getFd (const Io::IoTech &, std::vector< Io::Fd > &) const
 
virtual int getFd (const Io::IoTech &, const Io::IoFlags &, std::vector< Io::Fd > &) const
 
virtual const std::string & fname (const Io::Fd &) const
 
virtual const std::string & fname (void *) const
 
virtual Io::Fd fd (const std::string &) const
 
virtual Io::Fd fd (void *) const
 
virtual void * fptr (const std::string &) const
 
virtual void * fptr (const Io::Fd &) const
 
virtual int getLastError (std::string &) const
 
virtual 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)
 
virtual 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)
 
virtual 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)
 
virtual Io::close_t close (const Fd, const std::string &caller)
 
virtual Io::close_t close (void *, const std::string &caller)
 
virtual Io::reopen_t reopen (const Fd, const IoFlags &, const std::string &caller)
 
virtual Io::reopen_t reopen (void *, const IoFlags &, const std::string &caller)
 
virtual StatusCode regAction (Io::bfcn_action_t, const Io::Action &, const std::string &desc="")
 
virtual StatusCode regAction (Io::bfcn_action_t, const Io::Action &, const Io::IoTech &, const std::string &desc="")
 
virtual void suppressAction (const std::string &)
 
virtual void suppressAction (const std::string &, const Io::Action &)
 
- Public Member Functions inherited from extends2< Service, IFileMgr, IIncidentListener >
 extends2 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends2 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends2 ()
 Default constructor. More...
 
 extends2 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends2 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends2 ()
 Default constructor. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual ~extends2 ()
 Virtual destructor. More...
 
virtual ~extends2 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector< Property * > & getProperties () const
 Get list of properties. More...
 
virtual bool hasProperty (const std::string &name) const
 Return true if we have a property with the given name. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 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<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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector< Property * > & getProperties () const
 Get list of properties. More...
 
virtual bool hasProperty (const std::string &name) const
 Return true if we have a property with the given name. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 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<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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces3< IService, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 1)
 InterfaceID. More...
 
 DeclareInterfaceID (IProperty, 2, 1)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
- Public Member Functions inherited from extend_interfaces2< IFileMgr, IIncidentListener >
virtual ~extend_interfaces2 ()
 Virtual destructor. More...
 
virtual ~extend_interfaces2 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IFileMgr
virtual ~IFileMgr ()
 
 DeclareInterfaceID (IFileMgr, 1, 0)
 
virtual StatusCode deregHandler (const Io::IoTech &)=0
 
virtual StatusCode hasHandler (const Io::IoTech &) const =0
 
virtual StatusCode getHandler (const Io::IoTech &, Io::FileHdlr &) const =0
 
virtual StatusCode getFileAttr (const Io::Fd, const Io::FileAttr *&) const =0
 
virtual int getFd (std::vector< Io::Fd > &) const =0
 
virtual Io::close_t close (const Io::Fd, const std::string &caller)=0
 
virtual Io::reopen_t reopen (const Io::Fd, const Io::IoFlags &, const std::string &)=0
 
virtual ~IFileMgr ()
 
 DeclareInterfaceID (IFileMgr, 1, 0)
 
virtual StatusCode deregHandler (const Io::IoTech &)=0
 
virtual StatusCode hasHandler (const Io::IoTech &) const =0
 
virtual StatusCode getHandler (const Io::IoTech &, Io::FileHdlr &) const =0
 
virtual StatusCode getFileAttr (const Io::Fd, const Io::FileAttr *&) const =0
 
virtual int getFd (std::vector< Io::Fd > &) const =0
 
virtual Io::close_t close (const Io::Fd, const std::string &caller)=0
 
virtual Io::reopen_t reopen (const Io::Fd, const Io::IoFlags &, const std::string &)=0
 
- Public Member Functions inherited from IIncidentListener
 DeclareInterfaceID (IIncidentListener, 2, 0)
 InterfaceID. More...
 
 DeclareInterfaceID (IIncidentListener, 2, 0)
 InterfaceID. 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::list< FileAttr * > fileList
 
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, FileHdlrm_handlers
 
std::map< Fd, FileAttr * > m_descriptors
 
std::map< void *, FileAttr * > m_fptr
 
std::vector< FileAttr * > m_attr
 
fileList m_oldFiles
 
std::map< IoTech, actionMapm_actions
 
supMap m_supMap
 
std::string m_lastErrS
 
int m_lastErr
 
RootFileHandlerm_rfh
 
POSIXFileHandlerm_pfh
 
MsgStream m_log
 

Additional Inherited Members

- Public Types inherited from extends2< Service, IFileMgr, IIncidentListener >
typedef extends2 base_class
 Typedef to this class. More...
 
typedef extends2 base_class
 Typedef to this class. More...
 
typedef extend_interfaces2< IFileMgr, IIncidentListenerextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces2< IFileMgr, IIncidentListenerextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging base_class
 
typedef CommonMessaging base_class
 
- Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class. More...
 
typedef implements3 base_class
 Typedef to this class. More...
 
typedef extend_interfaces3< IService, IProperty, IStatefulextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces3< IService, IProperty, IStatefulextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IService, IProperty, IStateful >
typedef mpl::fold< typename IService::iid::iids::type, typename mpl::fold< typename IProperty::iid::iids::type, typename IStateful::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type, mpl::insert< mpl::_1, mpl::_2 > >::type ext_iids
 MPL set of interfaces extended by this one. More...
 
typedef mpl::fold< typename IService::iid::iids::type, typename mpl::fold< typename IProperty::iid::iids::type, typename IStateful::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type, mpl::insert< mpl::_1, mpl::_2 > >::type ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
typedef Gaudi::InterfaceId< IInterface, 0, 0 > iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
typedef Gaudi::InterfaceId< IInterface, 0, 0 > iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Public Types inherited from extend_interfaces2< IFileMgr, IIncidentListener >
typedef mpl::fold< typename IFileMgr::iid::iids::type, typename IIncidentListener::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type ext_iids
 MPL set of interfaces extended by this one. More...
 
typedef mpl::fold< typename IFileMgr::iid::iids::type, typename IIncidentListener::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type ext_iids
 MPL set of interfaces extended by this one. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level. More...
 
Gaudi::StateMachine::State m_state
 Service state. More...
 
Gaudi::StateMachine::State m_targetState
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::auto_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

Detailed Description

Definition at line 32 of file FileMgr.h.

Member Typedef Documentation

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

Definition at line 145 of file FileMgr.h.

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

Definition at line 144 of file FileMgr.h.

typedef std::list<FileAttr*> FileMgr::fileList
private

Definition at line 163 of file FileMgr.h.

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

Definition at line 155 of file FileMgr.h.

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

Definition at line 168 of file FileMgr.h.

Constructor & Destructor Documentation

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

Definition at line 38 of file FileMgr.cpp.

39  : base_class( name, svc ),m_rfh(0), m_pfh(0),
40  m_log(msgSvc(), name )
41  {
42 
43  declareProperty("LogFile",m_logfile="");
44  declareProperty("PrintSummary",m_printSummary=false);
45  declareProperty("LoadROOTHandler", m_loadRootHandler=true);
46  declareProperty("LoadPOSIXHandler", m_loadPosixHandler=true);
47 
48  declareProperty("TSSL_UserProxy", m_ssl_proxy="X509");
49  declareProperty("TSSL_CertDir", m_ssl_cert="X509");
50 
51  m_lastErrS = "";
52 
53 }
StringProperty m_logfile
Definition: FileMgr.h:135
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
extends2 base_class
Typedef to this class.
Definition: extends.h:77
MsgStream m_log
Definition: FileMgr.h:176
BooleanProperty m_printSummary
Definition: FileMgr.h:136
std::string m_lastErrS
Definition: FileMgr.h:171
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:329
RootFileHandler * m_rfh
Definition: FileMgr.h:174
BooleanProperty m_loadRootHandler
Definition: FileMgr.h:136
POSIXFileHandler * m_pfh
Definition: FileMgr.h:175
BooleanProperty m_loadPosixHandler
Definition: FileMgr.h:136
StringProperty m_ssl_cert
Definition: FileMgr.h:137
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:212
StringProperty m_ssl_proxy
Definition: FileMgr.h:137
FileMgr::~FileMgr ( )
virtual

Definition at line 57 of file FileMgr.cpp.

57  {
58 
59 }

Member Function Documentation

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

Definition at line 1695 of file FileMgr.cpp.

1696  {
1697 
1698  ON_VERBOSE
1699  m_log << MSG::VERBOSE << "accessMatch old: " << fold
1700  << " new: " << fnew
1701  << endmsg;
1702 
1703 
1704  if ( ((fold == Io::READ) && (fnew == Io::READ)) ||
1705  ((fold & Io::WRITE) != 0 && (fnew & Io::WRITE) != 0) ||
1706  ((fold & Io::RDWR) != 0 && (fnew & Io::RDWR) != 0) ) {
1707  return true;
1708  } else {
1709  return false;
1710  }
1711 
1712 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream m_log
Definition: FileMgr.h:176
#define ON_VERBOSE
Definition: FileMgr.cpp:15
virtual Io::close_t FileMgr::close ( const Fd  ,
const std::string &  caller 
)
virtual
close_t FileMgr::close ( void *  vp,
const std::string &  caller 
)
virtual

Implements IFileMgr.

Definition at line 686 of file FileMgr.cpp.

686  {
687 
688  // return codes:
689  // < 0 : error condition
690  // 0 : actual close of one file
691  // > 0 : shared file, removed from list, no actual close, returns
692  // number of shared files still open.
693 
694  ON_VERBOSE
695  m_log << MSG::VERBOSE << "close(" << vp << ")"
696  << endmsg;
697 
698  close_t r = -1;
699 
700  fileMap::iterator itr;
701  for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
702  if (itr->second->fptr() == vp) {
703  break;
704  }
705  }
706 
707  if (itr == m_files.end()) {
708  m_log << MSG::ERROR << "unknown file ptr \"" << vp
709  << "\" when calling close()"
710  << endmsg;
711  return r;
712  }
713 
714  IoTech tech = itr->second->tech();
715 
716  FileHdlr fh;
717 
718  if (getHandler(tech,fh).isFailure()) {
719  return r;
720  }
721  if (! fh.b_closeP_fcn) {
722  m_log << MSG::ERROR << "no close(" << tech << ",void*) function registered"
723  << endmsg;
724  return -1;
725  }
726 
727  FileAttr *fa = itr->second;
728 
729  // find how many times this file is open
730  pair<fileMap::const_iterator, fileMap::const_iterator> fitr =
731  m_files.equal_range(fa->name());
732 
733  int i(0);
734  for (fileMap::const_iterator it=fitr.first; it != fitr.second; ++it) {
735  if (it->second->fptr() == vp) {
736  i++;
737  }
738  }
739 
740  ON_VERBOSE
741  m_log << MSG::VERBOSE << " ref count: " << i
742  << endmsg;
743 
744  if (i > 1 && fa->isShared()) {
745  // file open multiple times in shared access. don't do the actual close
746  ON_DEBUG
747  m_log << MSG::DEBUG << "closing file " << fa->name() << " opened "
748  << i << " times with fptr " << vp << endmsg;
749  m_files.erase(itr);
750 
751  r = i-1;
752 
753  } else if (i == 1 || (i>1 && !fa->isShared()) ) {
754  ON_DEBUG
755  m_log << MSG::DEBUG << "closing: " << *fa << endmsg;
756 
757  try {
758  r = fh.b_closeP_fcn(vp);
759  } catch (const boost::bad_function_call& err) {
760  m_log << MSG::ERROR << "when calling close handler for " << tech
761  << " on file " << fa->name()
762  << " caught " << err.what() << endmsg;
763  execAction(fa, caller, CLOSE_ERR ).ignore();
764  return -1;
765  } catch (...) {
766  m_log << MSG::ERROR << "when calling close handler for " << tech
767  << " on file " << fa->name()
768  << " caught an unknown exception." << endmsg;
769  execAction(fa, caller, CLOSE_ERR ).ignore();
770  return -1;
771  }
772 
773  if (r < 0) {
775  << "close of file with ptr \"" << vp
776  << "\", name: \"" << fa->name()
777  << "\", tech: \"" << tech << "\" failed"
778  << endmsg;
779 
780  return r;
781  }
782 
783  m_files.erase(itr);
784 
785  } else {
786  // this should never happen!
787  m_log << MSG::ERROR
788  << "ref count: " << i << " < 0 when closing " << fa
789  << ". This should never happen"
790  << endmsg;
791  return -1;
792 
793  }
794 
795  fa->fd(-1);
796  fa->flags(INVALID);
797  fa->isOpen(false);
798  fa->fptr(0);
799  m_oldFiles.push_back( fa );
800 
801 
802  // exec all callbacks
803  if (execAction(fa, caller, CLOSE).isFailure()) {
805  << "at least one close callback action failed"
806  << endmsg;
807  }
808 
809  return r;
810 
811 }
IoTech
Definition: IFileMgr.h:170
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream m_log
Definition: FileMgr.h:176
void * fptr() const
Definition: IFileMgr.h:215
fileMap m_files
Definition: FileMgr.h:157
fileList m_oldFiles
Definition: FileMgr.h:164
bool isOpen() const
Definition: IFileMgr.h:216
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1604
virtual StatusCode getHandler(const IoTech &, FileHdlr &) const
Fd fd() const
Definition: IFileMgr.h:209
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
const std::string & name() const
Definition: IFileMgr.h:210
bool isShared() const
Definition: IFileMgr.h:217
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:294
#define ON_DEBUG
Definition: FileMgr.cpp:14
void ignore() const
Definition: StatusCode.h:107
list i
Definition: ana.py:128
IoFlags flags() const
Definition: IFileMgr.h:213
#define ON_VERBOSE
Definition: FileMgr.cpp:15
int close_t
Definition: IFileMgr.h:279
StatusCode FileMgr::deregHandler ( const IoTech )
virtual

Definition at line 302 of file FileMgr.cpp.

302  {
303  FileHdlr hdlr;
304 
305  map<IoTech,FileHdlr>::iterator itr = m_handlers.find(tech);
306  if (itr == m_handlers.end()) {
307  m_log << MSG::ERROR << "Can't de-register tech " << tech
308  << " as it hasn't been registered!"
309  << endmsg;
310  return StatusCode::FAILURE;
311  } else {
312  m_handlers.erase(itr);
313  }
314 
315  return StatusCode::SUCCESS;
316 
317 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream m_log
Definition: FileMgr.h:176
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:158
StatusCode FileMgr::execAction ( Io::FileAttr fa,
const std::string &  caller,
const Io::Action a 
) const
private

Definition at line 1604 of file FileMgr.cpp.

1605  {
1606 
1607  Io::IoTech tech = fa->tech();
1608 
1609  StatusCode s1,s2;
1610 
1611  std::map<IoTech, actionMap>::const_iterator itr;
1612  itr = m_actions.find(Io::UNKNOWN);
1613 
1614  if (itr != m_actions.end() && itr->second.size() != 0) {
1615  const actionMap &m = itr->second;
1616  s1 = execActs(fa, caller, a, m);
1617  }
1618 
1619  itr = m_actions.find(tech);
1620  if (itr != m_actions.end() && itr->second.size() != 0) {
1621  const actionMap &m = itr->second;
1622  s2 = execActs(fa, caller, a, m);
1623  }
1624 
1625  if (s1.isFailure() || s2.isFailure()) {
1626  return StatusCode::FAILURE;
1627  } else {
1628  return StatusCode::SUCCESS;
1629  }
1630 
1631 }
IoTech
Definition: IFileMgr.h:170
std::map< Io::Action, std::list< bfcn_desc_t > > actionMap
Definition: FileMgr.h:145
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:85
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
constexpr double m
Definition: SystemOfUnits.h:93
StatusCode execActs(Io::FileAttr *, const std::string &, const Io::Action &, const actionMap &m) const
Definition: FileMgr.cpp:1636
string s1
Definition: ana.py:142
IoTech tech() const
Definition: IFileMgr.h:212
string s2
Definition: ana.py:143
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:166
StatusCode FileMgr::execActs ( Io::FileAttr fa,
const std::string &  caller,
const Io::Action a,
const actionMap m 
) const
private

Definition at line 1636 of file FileMgr.cpp.

1637  {
1638 
1639  actionMap::const_iterator mitr = m.find(a);
1640 
1641  if (mitr == m.end() || mitr->second.size() == 0) {
1642  return StatusCode::SUCCESS;
1643  }
1644 
1645  ON_DEBUG
1646  m_log << MSG::DEBUG
1647  << "executing " << mitr->second.size() << " " << a
1648  << " actions on "
1649  << *fa << " from "
1650  << caller
1651  << endmsg;
1652 
1653 
1654  bool fail(false);
1655 
1656  supMap::const_iterator it2 = m_supMap.find(fa->name());
1657  if (it2 != m_supMap.end()) {
1658  if (get_bit(it2->second,a) || get_bit(it2->second,Io::INVALID_ACTION)) {
1659  ON_DEBUG
1660  m_log << MSG::DEBUG << " --> suppressing callback action for "
1661  << a
1662  << endmsg;
1663  return StatusCode::SUCCESS;
1664  }
1665  }
1666 
1667  for (list<bfcn_desc_t>::const_iterator itr = mitr->second.begin();
1668  itr != mitr->second.end(); ++itr) {
1669 
1670  ON_DEBUG
1671  m_log << MSG::DEBUG << "executing "
1672  << itr->second << endmsg;
1673 
1674  if ( (((itr->first))(fa,caller)).isFailure() ) {
1675  m_log << MSG::WARNING << "execution of "
1676  << itr->second << " on " << *fa
1677  << " failed during " << a << " action"
1678  << endmsg;
1679  fail = true;
1680  }
1681 
1682  }
1683 
1684  if (fail) {
1685  return StatusCode::FAILURE;
1686  } else {
1687  return StatusCode::SUCCESS;
1688  }
1689 
1690 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream m_log
Definition: FileMgr.h:176
supMap m_supMap
Definition: FileMgr.h:169
const std::string & name() const
Definition: IFileMgr.h:210
constexpr double m
Definition: SystemOfUnits.h:93
bool get_bit(const int &f, const unsigned int &b)
Definition: FileMgr.cpp:31
#define ON_DEBUG
Definition: FileMgr.cpp:14
Io::Fd FileMgr::fd ( const std::string &  fname) const
virtual

Implements IFileMgr.

Definition at line 1345 of file FileMgr.cpp.

1345  {
1346 
1347  pair<fileMap::const_iterator,fileMap::const_iterator> fitr =
1348  m_files.equal_range(fname);
1349 
1350  fileMap::const_iterator itr;
1351  for (itr=fitr.first; itr != fitr.second; ++itr) {
1352  if (itr->second->fd() != -1) {
1353  return itr->second->fd();
1354  }
1355  }
1356 
1357  return -1;
1358 
1359 }
fileMap m_files
Definition: FileMgr.h:157
virtual const std::string & fname(const Io::Fd &) const
Definition: FileMgr.cpp:1311
Io::Fd FileMgr::fd ( void *  fptr) const
virtual

Implements IFileMgr.

Definition at line 1364 of file FileMgr.cpp.

1364  {
1365 
1366  fileMap::const_iterator itr;
1367  for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
1368  if (itr->second->fptr() == fptr) {
1369  return itr->second->fd();
1370  }
1371  }
1372 
1373  return -1;
1374 
1375 }
fileMap m_files
Definition: FileMgr.h:157
virtual void * fptr(const std::string &) const
Definition: FileMgr.cpp:1380
StatusCode FileMgr::finalize ( )
virtual

Finalize (from INITIALIZED to CONFIGURED).

Reimplemented from Service.

Definition at line 163 of file FileMgr.cpp.

163  {
164  ON_VERBOSE
165  m_log << MSG::VERBOSE << "FileMgr::finalize()" << endmsg;
166 
167 
168  if (m_printSummary || outputLevel() <= MSG::DEBUG) {
169  listHandlers();
170  listFiles();
171  listActions();
172  listSuppression();
173  }
174 
175 
176  if (m_files.size() > 0) {
178  << "At finalize, the following files remained open:"
179  << endl;
180  map<string,FileAttr*>::const_iterator itr;
181  for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
182  m_log << *(itr->second) << endl;
183  }
184  m_log << endmsg;
185  }
186 
187 
188 
189  if (m_logfile.value() != "") {
190  std::ofstream ofs;
191  ofs.open(m_logfile.value().c_str());
192  if (!ofs) {
193  m_log << MSG::ERROR << "Unable to open output file \"" << m_logfile.value()
194  << "\" for writing"
195  << endmsg;
196  } else {
197  ON_DEBUG
198  m_log << MSG::DEBUG << "Saving log to \"" << m_logfile.value() << "\""
199  << endmsg;
200  fileMap::const_iterator itr;
201  for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
202  ofs << itr->second->name() << " " << itr->second->tech() << " "
203  << itr->second->desc() << " " << itr->second->iflags() << endl;
204  }
205 
206  set<FileAttr> fs;
207  set<FileAttr>::const_iterator it3;
208  list<FileAttr*>::const_iterator it2;
209  for (it2=m_oldFiles.begin(); it2 != m_oldFiles.end(); ++it2) {
210  fs.insert(**it2);
211  }
212 
213  for (it3=fs.begin(); it3!=fs.end(); ++it3) {
214  ofs << (it3)->name() << " " << (it3)->tech() << " " << (it3)->desc()
215  << " " << (it3)->iflags()
216  << ( (it3->isShared()) ? " SHARED" : "" )
217  << endl;
218  }
219 
220  ofs.close();
221  }
222  }
223 
224  // cleanup FileAttrs
225  for (vector<FileAttr*>::iterator itr = m_attr.begin(); itr != m_attr.end();
226  ++itr) {
227  delete(*itr);
228  }
229  m_attr.clear();
230 
231  delete m_rfh;
232  delete m_pfh;
233 
234 
235  StatusCode status = Service::finalize();
236 
237  ON_DEBUG
238  if ( status.isSuccess() )
239  m_log << MSG::DEBUG << "Service finalised successfully" << endmsg;
240 
241  return status;
242 
243 }
StringProperty m_logfile
Definition: FileMgr.h:135
virtual void listFiles() const
Definition: FileMgr.cpp:1414
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
MsgStream m_log
Definition: FileMgr.h:176
fileMap m_files
Definition: FileMgr.h:157
int outputLevel() const
get the Service's output level
Definition: Service.h:251
fileList m_oldFiles
Definition: FileMgr.h:164
virtual void listActions() const
Definition: FileMgr.cpp:1559
std::vector< FileAttr * > m_attr
Definition: FileMgr.h:161
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
BooleanProperty m_printSummary
Definition: FileMgr.h:136
const TYPE & value() const
explicit conversion
Definition: Property.h:355
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:329
RootFileHandler * m_rfh
Definition: FileMgr.h:174
POSIXFileHandler * m_pfh
Definition: FileMgr.h:175
virtual void listSuppression() const
Definition: FileMgr.cpp:1742
#define ON_DEBUG
Definition: FileMgr.cpp:14
#define ON_VERBOSE
Definition: FileMgr.cpp:15
virtual void listHandlers() const
Definition: FileMgr.cpp:1499
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
Definition: Service.cpp:197
const std::string & FileMgr::fname ( const Io::Fd fd) const
virtual

Implements IFileMgr.

Definition at line 1311 of file FileMgr.cpp.

1311  {
1312 
1313  fileMap::const_iterator itr;
1314  for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
1315  if (itr->second->fd() == fd) {
1316  return itr->second->name();
1317  }
1318  }
1319 
1320  static const std::string s_empty = "";
1321  return s_empty;
1322 
1323 }
fileMap m_files
Definition: FileMgr.h:157
virtual Io::Fd fd(const std::string &) const
Definition: FileMgr.cpp:1345
const std::string & FileMgr::fname ( void *  vp) const
virtual

Implements IFileMgr.

Definition at line 1328 of file FileMgr.cpp.

1328  {
1329 
1330  fileMap::const_iterator itr;
1331  for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
1332  if (itr->second->fptr() == vp) {
1333  return itr->second->name();
1334  }
1335  }
1336 
1337  static const std::string s_empty = "";
1338  return s_empty;
1339 
1340 }
fileMap m_files
Definition: FileMgr.h:157
void * FileMgr::fptr ( const std::string &  fname) const
virtual

Implements IFileMgr.

Definition at line 1380 of file FileMgr.cpp.

1380  {
1381  pair<fileMap::const_iterator,fileMap::const_iterator> fitr =
1382  m_files.equal_range(fname);
1383 
1384  fileMap::const_iterator itr;
1385  for (itr=fitr.first; itr != fitr.second; ++itr) {
1386  if (itr->second->fptr() != 0) {
1387  return itr->second->fptr();
1388  }
1389  }
1390 
1391  return 0;
1392 
1393 }
fileMap m_files
Definition: FileMgr.h:157
virtual const std::string & fname(const Io::Fd &) const
Definition: FileMgr.cpp:1311
void * FileMgr::fptr ( const Io::Fd fd) const
virtual

Implements IFileMgr.

Definition at line 1398 of file FileMgr.cpp.

1398  {
1399 
1400  fileMap::const_iterator itr;
1401  for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
1402  if (itr->second->fd() == fd) {
1403  return itr->second->fptr();
1404  }
1405  }
1406 
1407  return 0;
1408 
1409 }
fileMap m_files
Definition: FileMgr.h:157
virtual Io::Fd fd(const std::string &) const
Definition: FileMgr.cpp:1345
virtual int FileMgr::getFd ( std::vector< Fd > &  ) const
virtual
int FileMgr::getFd ( const Io::IoTech tech,
std::vector< Io::Fd > &  fd 
) const
virtual

Implements IFileMgr.

Definition at line 1269 of file FileMgr.cpp.

1269  {
1270 
1271  if (tech == UNKNOWN) {
1272  return getFd( fd );
1273  }
1274 
1275  fd.clear();
1276  map<Fd,FileAttr*>::const_iterator itr;
1277  for (itr=m_descriptors.begin(); itr != m_descriptors.end(); ++itr) {
1278  if (itr->second->tech() == tech) {
1279  fd.push_back(itr->first);
1280  }
1281  }
1282 
1283  return fd.size();
1284 
1285 }
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:159
virtual int getFd(std::vector< Fd > &) const
int FileMgr::getFd ( const Io::IoTech tech,
const Io::IoFlags flags,
std::vector< Io::Fd > &  fd 
) const
virtual

Implements IFileMgr.

Definition at line 1292 of file FileMgr.cpp.

1292  {
1293 
1294  fd.clear();
1295  map<Fd,FileAttr*>::const_iterator itr;
1296  for (itr=m_descriptors.begin(); itr != m_descriptors.end(); ++itr) {
1297  if (itr->second->tech() == tech || tech == UNKNOWN) {
1298  if ( itr->second->flags() == flags ) {
1299  fd.push_back(itr->first);
1300  }
1301  }
1302  }
1303 
1304  return fd.size();
1305 
1306 }
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:159
int FileMgr::getFileAttr ( const std::string &  fname,
std::vector< const FileAttr * > &  fa 
) const
virtual

Implements IFileMgr.

Definition at line 991 of file FileMgr.cpp.

991  {
992 
993  fa.clear();
994  pair<fileMap::const_iterator,fileMap::const_iterator> fitr =
995  m_files.equal_range(fname);
996 
997  fileMap::const_iterator itr;
998  for (itr=fitr.first; itr != fitr.second; ++itr) {
999  fa.push_back( (itr->second) );
1000  }
1001 
1002  fileList::const_iterator it2;
1003  for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
1004  if ( (*it2)->name() == fname ) {
1005  fa.push_back( *it2 );
1006  }
1007  }
1008 
1009  return fa.size();
1010 
1011 
1012 }
fileMap m_files
Definition: FileMgr.h:157
fileList m_oldFiles
Definition: FileMgr.h:164
virtual const std::string & fname(const Io::Fd &) const
Definition: FileMgr.cpp:1311
virtual StatusCode FileMgr::getFileAttr ( const Fd  ,
const FileAttr *&   
) const
virtual
StatusCode FileMgr::getFileAttr ( void *  vp,
const FileAttr *&  fa 
) const
virtual

Implements IFileMgr.

Definition at line 1042 of file FileMgr.cpp.

1042  {
1043 
1044  fileMap::const_iterator itr;
1045  for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
1046  if (itr->second->fptr() == vp) {
1047  fa = (itr->second);
1048  return StatusCode::SUCCESS;
1049  }
1050  }
1051 
1052  fileList::const_iterator it2;
1053  for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
1054  if ( (*it2)->fptr() == vp ) {
1055  fa = *it2;
1056  return StatusCode::SUCCESS;
1057  }
1058  }
1059 
1060  return StatusCode::FAILURE;
1061 
1062 }
fileMap m_files
Definition: FileMgr.h:157
fileList m_oldFiles
Definition: FileMgr.h:164
int FileMgr::getFiles ( std::vector< std::string > &  files,
bool  onlyOpen = true 
) const
virtual

Implements IFileMgr.

Definition at line 1067 of file FileMgr.cpp.

1067  {
1068 
1069  files.clear();
1070 
1071  map<string,FileAttr*>::const_iterator itr;
1072  for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
1073  if (find( files.begin(), files.end(), itr->first) == files.end()) {
1074  files.push_back(itr->first);
1075  }
1076  }
1077 
1078  if (!op) {
1079  std::list<FileAttr*>::const_iterator it2;
1080  for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
1081  if (find(files.begin(), files.end(), (*it2)->name()) == files.end()) {
1082  files.push_back( (*it2)->name());
1083  }
1084  }
1085  }
1086 
1087  return files.size();
1088 
1089 }
fileMap m_files
Definition: FileMgr.h:157
fileList m_oldFiles
Definition: FileMgr.h:164
int FileMgr::getFiles ( std::vector< const Io::FileAttr * > &  files,
bool  onlyOpen = true 
) const
virtual

Implements IFileMgr.

Definition at line 1094 of file FileMgr.cpp.

1094  {
1095 
1096  files.clear();
1097 
1098  map<string,FileAttr*>::const_iterator itr;
1099  for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
1100  files.push_back( (itr->second) );
1101  }
1102 
1103  if (!op) {
1104  std::list<FileAttr*>::const_iterator it2;
1105  for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
1106  files.push_back( *it2 );
1107  }
1108  }
1109 
1110  return files.size();
1111 
1112 }
fileMap m_files
Definition: FileMgr.h:157
fileList m_oldFiles
Definition: FileMgr.h:164
int FileMgr::getFiles ( const Io::IoTech tech,
std::vector< std::string > &  files,
bool  onlyOpen = true 
) const
virtual

Implements IFileMgr.

Definition at line 1117 of file FileMgr.cpp.

1117  {
1118 
1119  if (tech == UNKNOWN) {
1120  return getFiles(files,op);
1121  }
1122 
1123  files.clear();
1124 
1125  map<string,FileAttr*>::const_iterator itr;
1126  for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
1127  if (itr->second->tech() == tech &&
1128  find(files.begin(),files.end(),itr->first) == files.end()) {
1129  files.push_back(itr->first);
1130  }
1131  }
1132 
1133  if (!op) {
1134  std::list<FileAttr*>::const_iterator it2;
1135  for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
1136  if ( (*it2)->tech() == tech &&
1137  find(files.begin(), files.end(), (*it2)->name()) == files.end()) {
1138  files.push_back( (*it2)->name());
1139  }
1140  }
1141  }
1142 
1143  return files.size();
1144 
1145 }
fileMap m_files
Definition: FileMgr.h:157
fileList m_oldFiles
Definition: FileMgr.h:164
virtual int getFiles(std::vector< std::string > &, bool onlyOpen=true) const
Definition: FileMgr.cpp:1067
int FileMgr::getFiles ( const Io::IoTech tech,
std::vector< const Io::FileAttr * > &  files,
bool  onlyOpen = true 
) const
virtual

Implements IFileMgr.

Definition at line 1150 of file FileMgr.cpp.

1151  {
1152 
1153  if (tech == UNKNOWN) {
1154  return getFiles(files,op);
1155  }
1156 
1157  files.clear();
1158 
1159  map<string,FileAttr*>::const_iterator itr;
1160  for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
1161  if (itr->second->tech() == tech) {
1162  files.push_back( (itr->second) );
1163  }
1164  }
1165 
1166  if (!op) {
1167  std::list<FileAttr*>::const_iterator it2;
1168  for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
1169  if ( (*it2)->tech() == tech) {
1170  files.push_back( *it2 );
1171  }
1172  }
1173  }
1174 
1175  return files.size();
1176 
1177 }
fileMap m_files
Definition: FileMgr.h:157
fileList m_oldFiles
Definition: FileMgr.h:164
virtual int getFiles(std::vector< std::string > &, bool onlyOpen=true) const
Definition: FileMgr.cpp:1067
int FileMgr::getFiles ( const Io::IoTech tech,
const Io::IoFlags flags,
std::vector< std::string > &  files,
bool  onlyOpen = true 
) const
virtual

Implements IFileMgr.

Definition at line 1182 of file FileMgr.cpp.

1183  {
1184 
1185  files.clear();
1186 
1187  map<string,FileAttr*>::const_iterator itr;
1188  for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
1189  if (itr->second->tech() == tech || tech == UNKNOWN) {
1190  if ( itr->second->flags() == flags ) {
1191  if (find( files.begin(), files.end(), itr->first ) == files.end()) {
1192  files.push_back(itr->first);
1193  }
1194  }
1195  }
1196  }
1197 
1198  if (!op) {
1199  std::list<FileAttr*>::const_iterator it2;
1200  for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
1201  if ( (*it2)->tech() == tech || tech == UNKNOWN) {
1202  if ( (*it2)->flags() == flags ) {
1203  if (find(files.begin(), files.end(), (*it2)->name()) == files.end()){
1204  files.push_back( (*it2)->name());
1205  }
1206  }
1207  }
1208  }
1209  }
1210 
1211  return files.size();
1212 
1213 }
fileMap m_files
Definition: FileMgr.h:157
fileList m_oldFiles
Definition: FileMgr.h:164
int FileMgr::getFiles ( const Io::IoTech tech,
const Io::IoFlags flags,
std::vector< const Io::FileAttr * > &  files,
bool  onlyOpen = true 
) const
virtual

Implements IFileMgr.

Definition at line 1217 of file FileMgr.cpp.

1218  {
1219 
1220  files.clear();
1221 
1222  map<string,FileAttr*>::const_iterator itr;
1223  for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
1224  if (itr->second->tech() == tech || tech == UNKNOWN) {
1225  if ( itr->second->flags() == flags ) {
1226  files.push_back( (itr->second) );
1227  }
1228  }
1229  }
1230 
1231  if (!op) {
1232  std::list<FileAttr*>::const_iterator it2;
1233  for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
1234  if ( (*it2)->tech() == tech || tech == UNKNOWN) {
1235  if ( (*it2)->flags() == flags ) {
1236  files.push_back( *it2);
1237  }
1238  }
1239  }
1240  }
1241 
1242  return files.size();
1243 
1244 }
fileMap m_files
Definition: FileMgr.h:157
fileList m_oldFiles
Definition: FileMgr.h:164
virtual StatusCode FileMgr::getHandler ( const IoTech &  ,
FileHdlr  
) const
virtual
StatusCode FileMgr::getHandler ( const std::string &  fname,
Io::FileHdlr hdlr 
) const
virtual

Implements IFileMgr.

Definition at line 1466 of file FileMgr.cpp.

1466  {
1467 
1468  pair<fileMap::const_iterator,fileMap::const_iterator> fitr =
1469  m_files.equal_range(fname);
1470 
1471  if (fitr.first == fitr.second) {
1472  m_log << MSG::ERROR
1473  << "no file \"" << fname << "\" registered. Cannot determine tech"
1474  << endmsg;
1475  return StatusCode::FAILURE;
1476  }
1477 
1478  fileMap::const_iterator itr = fitr.first;
1479  IoTech tech = itr->second->tech();
1480 
1481  itr++;
1482  while( itr != fitr.second ) {
1483  if ( itr->second->tech() != tech ) {
1484  m_log << MSG::ERROR
1485  << "multiple technologies registered for file \"" << fname
1486  << "\". Cannot determine handler" << endmsg;
1487  return StatusCode::FAILURE;
1488  }
1489  itr++;
1490  }
1491 
1492  return getHandler(tech,hdlr);
1493 
1494 }
IoTech
Definition: IFileMgr.h:170
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream m_log
Definition: FileMgr.h:176
fileMap m_files
Definition: FileMgr.h:157
virtual StatusCode getHandler(const IoTech &, FileHdlr &) const
virtual const std::string & fname(const Io::Fd &) const
Definition: FileMgr.cpp:1311
int FileMgr::getLastError ( std::string &  err) const
virtual

Implements IFileMgr.

Definition at line 1437 of file FileMgr.cpp.

1437  {
1438 
1439  err = m_lastErrS;
1440 
1441  return m_lastErr;
1442 
1443 }
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
std::string m_lastErrS
Definition: FileMgr.h:171
int m_lastErr
Definition: FileMgr.h:172
void FileMgr::handle ( const Incident )
virtual

Inform that a new incident has occurred.

Implements IIncidentListener.

Definition at line 248 of file FileMgr.cpp.

248  {
249 
250 }
StatusCode FileMgr::hasHandler ( const IoTech ) const
virtual

Definition at line 321 of file FileMgr.cpp.

321  {
322 
323  map<IoTech,FileHdlr>::const_iterator itr = m_handlers.find(tech);
324  if (itr != m_handlers.end()) {
325  return StatusCode::SUCCESS;
326  } else {
327  return StatusCode::FAILURE;
328  }
329 
330 }
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:158
StatusCode FileMgr::initialize ( )
virtual

Initialization (from CONFIGURED to INITIALIZED).

Reimplemented from Service.

Definition at line 64 of file FileMgr.cpp.

64  {
65 
66  // Super ugly hack to make sure we have the OutputLevel set first, so we
67  // can see DEBUG printouts in update handlers.
68  IJobOptionsSvc* jos(0);
69  if( serviceLocator()->service( "JobOptionsSvc", jos, true ).isSuccess() ) {
70  const std::vector<const Property*> *props = jos->getProperties( name() );
71 
72  if (props != NULL) {
73  for ( std::vector<const Property*>::const_iterator cur = props->begin();
74  cur != props->end(); cur++) {
75  if ( (*cur)->name() == "OutputLevel" ) {
76  setProperty( **cur ).ignore();
78  break;
79  }
80  }
81  }
82  }
83 
86 
87  if (status.isFailure()) {
88 
89  ON_DEBUG
90  m_log << MSG::DEBUG << "Failed to initialize the base class (Service)"
91  << endmsg;
92  return status;
93  }
94 
96  m_log << MSG::VERBOSE << "Initializing FileMgr" << endmsg;
97 
98  if (m_loadRootHandler.value()) {
99 
100  // setup file handler for ROOT
101 
102  msgSvc()->setOutputLevel( "RootFileHandler", m_outputLevel.value());
104 
105  auto rfh = m_rfh; // used in the lambdas to avoid capturing 'this'
106  Io::FileHdlr hdlr(Io::ROOT,
107  [rfh](const std::string& n, const Io::IoFlags& f,
108  const std::string& desc, Io::Fd& fd,
109  void*& ptr) -> Io::open_t {
110  return rfh->openRootFile(n, f, desc, fd, ptr);
111  },
112  [rfh](void* ptr) -> Io::close_t {
113  return rfh->closeRootFile(ptr);
114  },
115  [rfh](void* ptr, const Io::IoFlags& f) -> Io::reopen_t {
116  return rfh->reopenRootFile(ptr, f);
117  });
118 
119  if (regHandler(hdlr).isFailure()) {
120  m_log << MSG::ERROR
121  << "unable to register ROOT file handler with FileMgr"
122  << endmsg;
123  }
124  }
125 
126  if (m_loadPosixHandler.value()) {
127 
128  // setup file handler for POSIX
129 
130  msgSvc()->setOutputLevel( "POSIXFileHandler", m_outputLevel.value());
131  m_pfh = new POSIXFileHandler(msgSvc());
132 
133  auto pfh = m_pfh; // used in the lambdas to avoid capturing 'this'
134  Io::FileHdlr hdlp(Io::POSIX,
135  [pfh](const std::string& n, const Io::IoFlags& f,
136  const std::string& desc, Io::Fd& fd,
137  void*& ptr) -> Io::open_t {
138  return pfh->openPOSIXFile(n, f, desc, fd, ptr);
139  },
140  [pfh](Io::Fd fd) -> Io::close_t {
141  return pfh->closePOSIXFile(fd);
142  },
143  [pfh](Io::Fd fd, const Io::IoFlags& f) -> Io::reopen_t {
144  return pfh->reopenPOSIXFile(fd, f);
145  });
146 
147  if (regHandler(hdlp).isFailure()) {
148  m_log << MSG::ERROR
149  << "unable to register ROOT file handler with FileMgr"
150  << endmsg;
151  }
152  }
153 
154 
155 
156  return StatusCode::SUCCESS;
157 
158 }
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:244
virtual StatusCode setProperty(const Property &p)
Set the property by property.
Definition: Service.cpp:340
int reopen_t
Definition: IFileMgr.h:280
int Fd
Definition: IFileMgr.h:197
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream m_log
Definition: FileMgr.h:176
int open_t
Definition: IFileMgr.h:278
virtual StatusCode regHandler(FileHdlr)
Definition: FileMgr.cpp:255
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:85
Main interface for the JobOptions service.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
const TYPE & value() const
explicit conversion
Definition: Property.h:355
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:329
RootFileHandler * m_rfh
Definition: FileMgr.h:174
BooleanProperty m_loadRootHandler
Definition: FileMgr.h:136
POSIXFileHandler * m_pfh
Definition: FileMgr.h:175
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: Service.cpp:72
BooleanProperty m_loadPosixHandler
Definition: FileMgr.h:136
StringProperty m_ssl_cert
Definition: FileMgr.h:137
void setLevel(int level)
Update outputlevel.
Definition: MsgStream.h:106
virtual Io::Fd fd(const std::string &) const
Definition: FileMgr.cpp:1345
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.
Definition: Service.h:143
#define ON_DEBUG
Definition: FileMgr.cpp:14
void ignore() const
Definition: StatusCode.h:107
StringProperty m_ssl_proxy
Definition: FileMgr.h:137
#define ON_VERBOSE
Definition: FileMgr.cpp:15
int close_t
Definition: IFileMgr.h:279
virtual void setOutputLevel(int new_level)=0
Set new global output level threshold.
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Service.cpp:334
bool FileMgr::isShareable ( const std::string &  filename,
const Io::IoFlags  
) const
private
void FileMgr::listActions ( ) const
virtual

Definition at line 1559 of file FileMgr.cpp.

1559  {
1560 
1561  m_log << MSG::INFO << "listing registered actions" << endl;
1562 
1563  actionMap::const_iterator itr;
1564 
1565  map<Io::IoTech, actionMap>::const_iterator iit;
1566  for (iit = m_actions.begin(); iit != m_actions.end(); ++iit) {
1567  Io::IoTech t = iit->first;
1568  const actionMap& m = iit->second;
1569 
1570  if (m.size() != 0) {
1571  m_log << " --- Tech: ";
1572  if (t == Io::UNKNOWN) {
1573  m_log << "ALL ---" << endl;
1574  } else {
1575  m_log << t << " ---" << endl;
1576  }
1577 
1578  actionMap::const_iterator iia;
1579  for (iia = m.begin() ; iia != m.end(); ++iia) {
1580  if (iia->second.size() != 0) {
1581  // for (list<bfcn_action_t>::const_iterator it2 = iia->second.begin();
1582  // it2 != iia->second.end(); ++it2) {
1583  for (list<bfcn_desc_t>::const_iterator it2 = iia->second.begin();
1584  it2 != iia->second.end(); ++it2) {
1585 
1586  m_log << " " << iia->first << " "
1587  << it2->second
1588  << endl;
1589  }
1590  }
1591  }
1592 
1593  }
1594  }
1595 
1596 
1597  m_log << endmsg;
1598 
1599 }
IoTech
Definition: IFileMgr.h:170
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream m_log
Definition: FileMgr.h:176
std::map< Io::Action, std::list< bfcn_desc_t > > actionMap
Definition: FileMgr.h:145
constexpr double m
Definition: SystemOfUnits.h:93
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:166
void FileMgr::listFiles ( ) const
virtual

Implements IFileMgr.

Definition at line 1414 of file FileMgr.cpp.

1414  {
1415 
1416  m_log << MSG::INFO << "listing registered files ["
1417  << (m_files.size() + m_oldFiles.size() )
1418  << "]:" << endl;
1419 
1420  fileMap::const_iterator itr;
1421  for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
1422  m_log << *(itr->second) << endl;
1423  }
1424 
1425  for (list<FileAttr*>::const_iterator it2=m_oldFiles.begin();
1426  it2 != m_oldFiles.end(); ++it2) {
1427  m_log << **it2 << endl;
1428  }
1429 
1430  m_log << endmsg;
1431 
1432 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream m_log
Definition: FileMgr.h:176
fileMap m_files
Definition: FileMgr.h:157
fileList m_oldFiles
Definition: FileMgr.h:164
void FileMgr::listHandlers ( ) const
virtual

Implements IFileMgr.

Definition at line 1499 of file FileMgr.cpp.

1499  {
1500 
1501  m_log << MSG::INFO
1502  << "Listing registered handlers:" << endl;
1503 
1504  map<IoTech,FileHdlr>::const_iterator itr;
1505  for (itr=m_handlers.begin(); itr != m_handlers.end(); ++itr) {
1506 
1507  m_log << " " << itr->first << endl;
1508  }
1509  m_log << endmsg;
1510 
1511 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream m_log
Definition: FileMgr.h:176
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:158
void FileMgr::listSuppression ( ) const
virtual

Definition at line 1742 of file FileMgr.cpp.

1742  {
1743 
1744  if (m_supMap.size() == 0) return;
1745 
1746  m_log << MSG::INFO << "listing suppressed file actions" << endl;
1747 
1748  supMap::const_iterator it2;
1749  for (it2=m_supMap.begin(); it2 != m_supMap.end(); ++it2) {
1750  m_log << " " << it2->first;
1751  if (get_bit(it2->second, Io::INVALID_ACTION)) {
1752  m_log << " ALL" << endl;
1753  } else {
1754  for (int i=0; i<Io::INVALID_ACTION; ++i) {
1755  if (get_bit(it2->second,i)) { m_log << " " << (Io::Action)i; }
1756  }
1757  m_log << endl;
1758  }
1759  }
1760 
1761  m_log << endmsg;
1762 
1763 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream m_log
Definition: FileMgr.h:176
supMap m_supMap
Definition: FileMgr.h:169
Action
Definition: IFileMgr.h:316
bool get_bit(const int &f, const unsigned int &b)
Definition: FileMgr.cpp:31
list i
Definition: ana.py:128
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 
)
virtual

Implements IFileMgr.

Definition at line 335 of file FileMgr.cpp.

338  {
339 
340  return open(tech, caller, fname, desc, flags, fd, ptr, sh);
341 
342 }
virtual 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)
Definition: FileMgr.cpp:335
virtual const std::string & fname(const Io::Fd &) const
Definition: FileMgr.cpp:1311
virtual Io::Fd fd(const std::string &) const
Definition: FileMgr.cpp:1345
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 
)
virtual

Implements IFileMgr.

Definition at line 346 of file FileMgr.cpp.

349  {
350 
351  void* dummy(0);
352  return open(tech, caller, fname, desc, flags, fd, dummy, sh);
353 
354 }
virtual 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)
Definition: FileMgr.cpp:335
virtual const std::string & fname(const Io::Fd &) const
Definition: FileMgr.cpp:1311
virtual Io::Fd fd(const std::string &) const
Definition: FileMgr.cpp:1345
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 
)
virtual

Implements IFileMgr.

Definition at line 358 of file FileMgr.cpp.

361  {
362 
363  Fd dummy(-1);
364  return open(tech, caller, fname, desc, flags, dummy, ptr, sh);
365 
366 }
virtual 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)
Definition: FileMgr.cpp:335
int Fd
Definition: IFileMgr.h:197
virtual const std::string & fname(const Io::Fd &) const
Definition: FileMgr.cpp:1311
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 
)
privatevirtual
StatusCode FileMgr::regAction ( Io::bfcn_action_t  bf,
const Io::Action a,
const std::string &  desc = "" 
)
virtual

Implements IFileMgr.

Definition at line 1516 of file FileMgr.cpp.

1516  {
1517 
1518  ON_DEBUG
1519  m_log << MSG::DEBUG << "registering " << a << " action "
1520  << System::typeinfoName(bf.target_type()) << endmsg;
1521 
1522  if (d == "") {
1523  m_actions[Io::UNKNOWN][a].push_back
1524  (make_pair(bf,System::typeinfoName(bf.target_type())));
1525  } else {
1526  m_actions[Io::UNKNOWN][a].push_back(make_pair(bf,d));
1527  }
1528 
1529 
1530  return StatusCode::SUCCESS;
1531 
1532 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
MsgStream m_log
Definition: FileMgr.h:176
#define ON_DEBUG
Definition: FileMgr.cpp:14
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:166
StatusCode FileMgr::regAction ( Io::bfcn_action_t  bf,
const Io::Action a,
const Io::IoTech t,
const std::string &  desc = "" 
)
virtual

Implements IFileMgr.

Definition at line 1537 of file FileMgr.cpp.

1538  {
1539 
1540  ON_DEBUG
1541  m_log << MSG::DEBUG << "registering " << a << " action "
1542  << System::typeinfoName(bf.target_type())
1543  << " for tech " << t << endmsg;
1544 
1545  if (d == "") {
1546  m_actions[t][a].push_back
1547  (make_pair(bf, System::typeinfoName(bf.target_type())));
1548  } else {
1549  m_actions[t][a].push_back(make_pair(bf,d));
1550  }
1551 
1552  return StatusCode::SUCCESS;
1553 
1554 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
MsgStream m_log
Definition: FileMgr.h:176
#define ON_DEBUG
Definition: FileMgr.cpp:14
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:166
StatusCode FileMgr::regHandler ( FileHdlr  fh)
virtual

Implements IFileMgr.

Definition at line 255 of file FileMgr.cpp.

255  {
256 
257  IoTech tech = fh.tech;
258 
259  if (m_handlers.find(tech) != m_handlers.end()) {
261  << "Handler for IoTech " << tech << " already registered. Ignoring."
262  << endmsg;
263  return StatusCode::SUCCESS;
264  }
265 
266  if ( ! fh.b_open_fcn ) {
267  m_log << MSG::ERROR
268  << "open handler for tech " << tech << " is NULL"
269  << endmsg;
270  return StatusCode::FAILURE;
271  }
272 
273  if ( ! fh.b_close_fcn && ! fh.b_closeP_fcn ) {
274  m_log << MSG::ERROR
275  << "no close handler for tech " << tech << " registered"
276  << endmsg;
277  return StatusCode::FAILURE;
278  }
279 
280  if ( ! fh.b_reopen_fcn && ! fh.b_reopenP_fcn) {
281  m_log << MSG::ERROR
282  << "no reopen handler for tech " << tech << " registered"
283  << endmsg;
284  return StatusCode::FAILURE;
285  }
286 
287 
288  ON_DEBUG
289  m_log << MSG::DEBUG
290  << "Successfully registered handler for tech \"" << tech << "\""
291  << endmsg;
292 
293  m_handlers[tech] = fh;
294 
295  return StatusCode::SUCCESS;
296 
297 }
IoTech
Definition: IFileMgr.h:170
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bfcn_reopen_t b_reopen_fcn
Definition: IFileMgr.h:295
MsgStream m_log
Definition: FileMgr.h:176
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:158
bfcn_close_t b_close_fcn
Definition: IFileMgr.h:293
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:294
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:296
bfcn_open_t b_open_fcn
Definition: IFileMgr.h:292
#define ON_DEBUG
Definition: FileMgr.cpp:14
IoTech tech
Definition: IFileMgr.h:290
virtual Io::reopen_t FileMgr::reopen ( const Fd  ,
const IoFlags ,
const std::string &  caller 
)
virtual
reopen_t FileMgr::reopen ( void *  vp,
const IoFlags flags,
const std::string &  caller 
)
virtual

Implements IFileMgr.

Definition at line 907 of file FileMgr.cpp.

907  {
908  ON_VERBOSE
909  m_log << MSG::VERBOSE << "reopen(" << vp << "," << flags
910  << "," << caller << ")"
911  << endmsg;
912 
913  reopen_t r = -1;
914 
915  fileMap::iterator itr;
916  for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
917  if (itr->second->fptr() == vp) {
918  break;
919  }
920  }
921 
922  if (itr == m_files.end()) {
923  m_log << MSG::ERROR
924  << "unregistered file ptr \"" << vp
925  << "\" when calling reopen()"
926  << endmsg;
927  return r;
928  }
929 
930  FileAttr *fa = itr->second;
931  FileHdlr fh;
932  IoTech tech = fa->tech();
933 
934  if (getHandler(tech,fh).isFailure()) {
935  return r;
936  }
937 
938  if ( ! fh.b_reopenP_fcn ) {
939  m_log << MSG::ERROR << "no reopen(" << tech << ",void*) function registered"
940  << endmsg;
941  return -1;
942  }
943 
944  try {
945  r = fh.b_reopenP_fcn(vp,flags);
946  } catch (const boost::bad_function_call& err) {
947  m_log << MSG::ERROR << "when calling reopen handler for " << tech
948  << " on file " << fa->name() << " with flags "
949  << flags
950  << " caught " << err.what() << endmsg;
951  return -1;
952  } catch (...) {
953  m_log << MSG::ERROR << "when calling reopen handler for " << tech
954  << " on file " << fa->name() << " with flags "
955  << flags
956  << " caught an unknown exception." << endmsg;
957  return -1;
958  }
959 
960  if (r < 0) {
962  << "reopen of file with ptr \"" << vp
963  << "\", name: \"" << fa->name()
964  << "\", tech: \"" << tech
965  << "\", flags: \"" << flags << "\" failed"
966  << endmsg;
967 
968  execAction(fa, caller, Io::REOPEN_ERR ).ignore();
969 
970  return r;
971 
972  }
973 
974  fa->isOpen(true);
975  fa->flags(flags);
976 
977  // exec all callbacks
978  if (execAction(fa, caller, Io::REOPEN).isFailure()) {
980  << "at least one reopen callback action failed"
981  << endmsg;
982  }
983 
984  return r;
985 
986 }
IoTech
Definition: IFileMgr.h:170
int reopen_t
Definition: IFileMgr.h:280
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream m_log
Definition: FileMgr.h:176
fileMap m_files
Definition: FileMgr.h:157
bool isOpen() const
Definition: IFileMgr.h:216
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1604
virtual StatusCode getHandler(const IoTech &, FileHdlr &) const
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
const std::string & name() const
Definition: IFileMgr.h:210
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:296
IoTech tech() const
Definition: IFileMgr.h:212
void ignore() const
Definition: StatusCode.h:107
IoFlags flags() const
Definition: IFileMgr.h:213
#define ON_VERBOSE
Definition: FileMgr.cpp:15
void FileMgr::suppressAction ( const std::string &  f)
virtual

Implements IFileMgr.

Definition at line 1717 of file FileMgr.cpp.

1717  {
1718 
1720 
1721 }
virtual void suppressAction(const std::string &)
Definition: FileMgr.cpp:1717
void FileMgr::suppressAction ( const std::string &  f,
const Io::Action a 
)
virtual

Implements IFileMgr.

Definition at line 1726 of file FileMgr.cpp.

1726  {
1727 
1728  supMap::iterator it2 = m_supMap.find(f);
1729  if (it2 == m_supMap.end()) {
1730  int b(0);
1731  set_bit(b,a);
1732  m_supMap[f] = b;
1733  } else {
1734  set_bit(it2->second, a);
1735  }
1736 
1737 }
supMap m_supMap
Definition: FileMgr.h:169
void set_bit(int &f, const unsigned int &b)
Definition: FileMgr.cpp:27

Member Data Documentation

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

Definition at line 166 of file FileMgr.h.

std::vector<FileAttr*> FileMgr::m_attr
private

Definition at line 161 of file FileMgr.h.

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

Definition at line 159 of file FileMgr.h.

fileMap FileMgr::m_files
private

Definition at line 157 of file FileMgr.h.

std::map<void*, FileAttr*> FileMgr::m_fptr
private

Definition at line 160 of file FileMgr.h.

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

Definition at line 158 of file FileMgr.h.

int FileMgr::m_lastErr
private

Definition at line 172 of file FileMgr.h.

std::string FileMgr::m_lastErrS
private

Definition at line 171 of file FileMgr.h.

BooleanProperty FileMgr::m_loadPosixHandler
private

Definition at line 136 of file FileMgr.h.

BooleanProperty FileMgr::m_loadRootHandler
private

Definition at line 136 of file FileMgr.h.

MsgStream FileMgr::m_log
mutableprivate

Definition at line 176 of file FileMgr.h.

StringProperty FileMgr::m_logfile
private

Definition at line 135 of file FileMgr.h.

fileList FileMgr::m_oldFiles
private

Definition at line 164 of file FileMgr.h.

POSIXFileHandler* FileMgr::m_pfh
private

Definition at line 175 of file FileMgr.h.

BooleanProperty FileMgr::m_printSummary
private

Definition at line 136 of file FileMgr.h.

RootFileHandler* FileMgr::m_rfh
private

Definition at line 174 of file FileMgr.h.

StringProperty FileMgr::m_ssl_cert
private

Definition at line 137 of file FileMgr.h.

StringProperty FileMgr::m_ssl_proxy
private

Definition at line 137 of file FileMgr.h.

supMap FileMgr::m_supMap
private

Definition at line 169 of file FileMgr.h.


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