Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
FileMgr Class Reference

#include <FileMgr.h>

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

Public Member Functions

 FileMgr (const std::string &name, ISvcLocator *svc)
 
virtual ~FileMgr ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
virtual void handle (const Incident &)
 
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::stringfname (const Io::Fd &) const
 
virtual const std::stringfname (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.
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends2 (A1 a1)
 Templated constructor with 1 argument.
 
 extends2 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::stringgetInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends2 ()
 Virtual destructor.
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::stringname () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode reinitialize ()
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
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.
 
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.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- 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.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from extend_interfaces2< I1, I2 >
virtual ~extend_interfaces2 ()
 Virtual destructor.
 

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 &)
 
StatusCode execActs (Io::FileAttr *, const std::string &, const Io::Action &, actionMap &m)
 
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.
 
typedef extend_interfaces2
< IFileMgr, IIncidentListener
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor.
 
int outputLevel () const
 get the Service's output level
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level.
 
Gaudi::StateMachine::State m_state
 Service state.
 
Gaudi::StateMachine::State m_targetState
 Service state.
 

Detailed Description

Definition at line 32 of file FileMgr.h.

Member Typedef Documentation

Definition at line 145 of file FileMgr.h.

Definition at line 144 of file FileMgr.h.

Definition at line 163 of file FileMgr.h.

Definition at line 155 of file FileMgr.h.

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.

: base_class( name, svc ),m_rfh(0), m_pfh(0),
{
declareProperty("LogFile",m_logfile="");
declareProperty("PrintSummary",m_printSummary=false);
declareProperty("LoadROOTHandler", m_loadRootHandler=true);
declareProperty("LoadPOSIXHandler", m_loadPosixHandler=true);
declareProperty("TSSL_UserProxy", m_ssl_proxy="X509");
declareProperty("TSSL_CertDir", m_ssl_cert="X509");
m_lastErrS = "";
}
FileMgr::~FileMgr ( )
virtual

Definition at line 57 of file FileMgr.cpp.

{
}

Member Function Documentation

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

Definition at line 1673 of file FileMgr.cpp.

{
m_log << MSG::VERBOSE << "accessMatch old: " << fold
<< " new: " << fnew
<< endmsg;
if ( ((fold == Io::READ) && (fnew == Io::READ)) ||
((fold & Io::WRITE) != 0 && (fnew & Io::WRITE) != 0) ||
((fold & Io::RDWR) != 0 && (fnew & Io::RDWR) != 0) ) {
return true;
} else {
return false;
}
}
virtual Io::close_t FileMgr::close ( const Fd  ,
const std::string caller 
)
virtual
close_t FileMgr::close ( void *  vp,
const std::string caller 
)
virtual

Definition at line 668 of file FileMgr.cpp.

{
// return codes:
// < 0 : error condition
// 0 : actual close of one file
// > 0 : shared file, removed from list, no actual close, returns
// number of shared files still open.
m_log << MSG::VERBOSE << "close(" << vp << ")"
<< endmsg;
close_t r = -1;
for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->fptr() == vp) {
break;
}
}
if (itr == m_files.end()) {
m_log << MSG::ERROR << "unknown file ptr \"" << vp
<< "\" when calling close()"
<< endmsg;
return r;
}
IoTech tech = itr->second->tech();
if (getHandler(tech,fh).isFailure()) {
return r;
}
if (fh.b_closeP_fcn.empty()) {
m_log << MSG::ERROR << "no close(" << tech << ",void*) function registered"
<< endmsg;
return -1;
}
FileAttr *fa = itr->second;
// find how many times this file is open
int i(0);
for (fileMap::const_iterator it=fitr.first; it != fitr.second; ++it) {
if (it->second->fptr() == vp) {
i++;
}
}
m_log << MSG::VERBOSE << " ref count: " << i
<< endmsg;
if (i > 1 && fa->isShared()) {
// file open multiple times in shared access. don't do the actual close
m_log << MSG::DEBUG << "closing file " << fa->name() << " opened "
<< i << " times with fptr " << vp << endmsg;
m_files.erase(itr);
r = i-1;
} else if (i == 1 || (i>1 && !fa->isShared()) ) {
m_log << MSG::DEBUG << "closing: " << *fa << endmsg;
try {
r = fh.b_closeP_fcn(vp);
} catch (const boost::bad_function_call& err) {
m_log << MSG::ERROR << "when calling close handler for " << tech
<< " on file " << fa->name()
<< " caught " << err.what() << endmsg;
execAction(fa, caller, CLOSE_ERR ).ignore();
return -1;
} catch (...) {
m_log << MSG::ERROR << "when calling close handler for " << tech
<< " on file " << fa->name()
<< " caught an unknown exception." << endmsg;
execAction(fa, caller, CLOSE_ERR ).ignore();
return -1;
}
if (r < 0) {
<< "close of file with ptr \"" << vp
<< "\", name: \"" << fa->name()
<< "\", tech: \"" << tech << "\" failed"
<< endmsg;
return r;
}
m_files.erase(itr);
} else {
// this should never happen!
<< "ref count: " << i << " < 0 when closing " << fa
<< ". This should never happen"
<< endmsg;
return -1;
}
fa->fd(-1);
fa->flags(INVALID);
fa->isOpen(false);
fa->fptr(0);
// exec all callbacks
if (execAction(fa, caller, CLOSE).isFailure()) {
<< "at least one close callback action failed"
<< endmsg;
}
return r;
}
StatusCode FileMgr::deregHandler ( const IoTech )
virtual

Definition at line 284 of file FileMgr.cpp.

{
FileHdlr hdlr;
if (itr == m_handlers.end()) {
m_log << MSG::ERROR << "Can't de-register tech " << tech
<< " as it hasn't been registered!"
<< endmsg;
} else {
}
}
StatusCode FileMgr::execAction ( Io::FileAttr fa,
const std::string caller,
const Io::Action a 
)
private

Definition at line 1588 of file FileMgr.cpp.

{
Io::IoTech tech = fa->tech();
if (m_actions[Io::UNKNOWN].size() != 0) {
s1 = execActs(fa, caller, a, m);
}
if (m_actions[tech].size() != 0) {
actionMap &m = m_actions[tech];
s2 = execActs(fa, caller, a, m);
}
if (s1.isFailure() || s2.isFailure()) {
} else {
}
}
StatusCode FileMgr::execActs ( Io::FileAttr fa,
const std::string caller,
const Io::Action a,
actionMap m 
)
private

Definition at line 1616 of file FileMgr.cpp.

{
if (m[a].size() == 0) {
}
<< "executing " << m[a].size() << " " << a
<< " actions on "
<< *fa << " from "
<< caller
<< endmsg;
bool fail(false);
if (it2 != m_supMap.end()) {
if (get_bit(it2->second,a) || get_bit(it2->second,Io::INVALID_ACTION)) {
m_log << MSG::DEBUG << " --> suppressing callback action for "
<< a
<< endmsg;
}
}
for (list<bfcn_desc_t>::iterator itr = m[a].begin();
itr != m[a].end(); ++itr) {
m_log << MSG::DEBUG << "executing "
<< itr->second << endmsg;
if ( (((itr->first))(fa,caller)).isFailure() ) {
m_log << MSG::WARNING << "execution of "
<< itr->second << " on " << *fa
<< " failed during " << a << " action"
<< endmsg;
fail = true;
}
}
if (fail) {
} else {
}
}
Io::Fd FileMgr::fd ( const std::string fname) const
virtual

Definition at line 1327 of file FileMgr.cpp.

{
for (itr=fitr.first; itr != fitr.second; ++itr) {
if (itr->second->fd() != -1) {
return itr->second->fd();
}
}
return -1;
}
Io::Fd FileMgr::fd ( void *  fptr) const
virtual

Definition at line 1346 of file FileMgr.cpp.

{
for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->fptr() == fptr) {
return itr->second->fd();
}
}
return -1;
}
StatusCode FileMgr::finalize ( )
virtual

Reimplemented from Service.

Definition at line 145 of file FileMgr.cpp.

{
m_log << MSG::VERBOSE << "FileMgr::finalize()" << endmsg;
}
if (m_files.size() > 0) {
<< "At finalize, the following files remained open:"
<< endl;
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
m_log << *(itr->second) << endl;
}
}
if (m_logfile.value() != "") {
ofs.open(m_logfile.value().c_str());
if (!ofs) {
m_log << MSG::ERROR << "Unable to open output file \"" << m_logfile.value()
<< "\" for writing"
<< endmsg;
} else {
m_log << MSG::DEBUG << "Saving log to \"" << m_logfile.value() << "\""
<< endmsg;
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
ofs << itr->second->name() << " " << itr->second->tech() << " "
<< itr->second->desc() << " " << itr->second->iflags() << endl;
}
for (it2=m_oldFiles.begin(); it2 != m_oldFiles.end(); ++it2) {
fs.insert(**it2);
}
for (it3=fs.begin(); it3!=fs.end(); ++it3) {
ofs << (it3)->name() << " " << (it3)->tech() << " " << (it3)->desc()
<< " " << (it3)->iflags()
<< ( (it3->isShared()) ? " SHARED" : "" )
<< endl;
}
ofs.close();
}
}
// cleanup FileAttrs
++itr) {
delete(*itr);
}
delete m_rfh;
delete m_pfh;
if ( status.isSuccess() )
m_log << MSG::DEBUG << "Service finalised successfully" << endmsg;
return status;
}
const std::string & FileMgr::fname ( const Io::Fd fd) const
virtual

Definition at line 1293 of file FileMgr.cpp.

{
for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->fd() == fd) {
return itr->second->name();
}
}
static const std::string s_empty = "";
return s_empty;
}
const std::string & FileMgr::fname ( void *  vp) const
virtual

Definition at line 1310 of file FileMgr.cpp.

{
for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->fptr() == vp) {
return itr->second->name();
}
}
static const std::string s_empty = "";
return s_empty;
}
void * FileMgr::fptr ( const std::string fname) const
virtual

Definition at line 1362 of file FileMgr.cpp.

{
for (itr=fitr.first; itr != fitr.second; ++itr) {
if (itr->second->fptr() != 0) {
return itr->second->fptr();
}
}
return 0;
}
void * FileMgr::fptr ( const Io::Fd fd) const
virtual

Definition at line 1380 of file FileMgr.cpp.

{
for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->fd() == fd) {
return itr->second->fptr();
}
}
return 0;
}
virtual int FileMgr::getFd ( std::vector< Fd > &  ) const
virtual
int FileMgr::getFd ( const Io::IoTech tech,
std::vector< Io::Fd > &  fd 
) const
virtual

Definition at line 1251 of file FileMgr.cpp.

{
if (tech == UNKNOWN) {
return getFd( fd );
}
fd.clear();
for (itr=m_descriptors.begin(); itr != m_descriptors.end(); ++itr) {
if (itr->second->tech() == tech) {
fd.push_back(itr->first);
}
}
return fd.size();
}
int FileMgr::getFd ( const Io::IoTech tech,
const Io::IoFlags flags,
std::vector< Io::Fd > &  fd 
) const
virtual

Definition at line 1274 of file FileMgr.cpp.

{
fd.clear();
for (itr=m_descriptors.begin(); itr != m_descriptors.end(); ++itr) {
if (itr->second->tech() == tech || tech == UNKNOWN) {
if ( itr->second->flags() == flags ) {
fd.push_back(itr->first);
}
}
}
return fd.size();
}
int FileMgr::getFileAttr ( const std::string fname,
std::vector< const FileAttr * > &  fa 
) const
virtual

Definition at line 973 of file FileMgr.cpp.

{
fa.clear();
for (itr=fitr.first; itr != fitr.second; ++itr) {
fa.push_back( (itr->second) );
}
for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
if ( (*it2)->name() == fname ) {
fa.push_back( *it2 );
}
}
return fa.size();
}
virtual StatusCode FileMgr::getFileAttr ( const Fd  ,
const FileAttr *&   
) const
virtual
StatusCode FileMgr::getFileAttr ( void *  vp,
const FileAttr *&  fa 
) const
virtual

Definition at line 1024 of file FileMgr.cpp.

{
for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->fptr() == vp) {
fa = (itr->second);
}
}
for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
if ( (*it2)->fptr() == vp ) {
fa = *it2;
}
}
}
int FileMgr::getFiles ( std::vector< std::string > &  files,
bool  onlyOpen = true 
) const
virtual

Definition at line 1049 of file FileMgr.cpp.

{
files.clear();
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
if (find( files.begin(), files.end(), itr->first) == files.end()) {
files.push_back(itr->first);
}
}
if (!op) {
for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
if (find(files.begin(), files.end(), (*it2)->name()) == files.end()) {
files.push_back( (*it2)->name());
}
}
}
return files.size();
}
int FileMgr::getFiles ( std::vector< const Io::FileAttr * > &  files,
bool  onlyOpen = true 
) const
virtual

Definition at line 1076 of file FileMgr.cpp.

{
files.clear();
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
files.push_back( (itr->second) );
}
if (!op) {
for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
files.push_back( *it2 );
}
}
return files.size();
}
int FileMgr::getFiles ( const Io::IoTech tech,
std::vector< std::string > &  files,
bool  onlyOpen = true 
) const
virtual

Definition at line 1099 of file FileMgr.cpp.

{
if (tech == UNKNOWN) {
return getFiles(files,op);
}
files.clear();
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->tech() == tech &&
find(files.begin(),files.end(),itr->first) == files.end()) {
files.push_back(itr->first);
}
}
if (!op) {
for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
if ( (*it2)->tech() == tech &&
find(files.begin(), files.end(), (*it2)->name()) == files.end()) {
files.push_back( (*it2)->name());
}
}
}
return files.size();
}
int FileMgr::getFiles ( const Io::IoTech tech,
std::vector< const Io::FileAttr * > &  files,
bool  onlyOpen = true 
) const
virtual

Definition at line 1132 of file FileMgr.cpp.

{
if (tech == UNKNOWN) {
return getFiles(files,op);
}
files.clear();
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->tech() == tech) {
files.push_back( (itr->second) );
}
}
if (!op) {
for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
if ( (*it2)->tech() == tech) {
files.push_back( *it2 );
}
}
}
return files.size();
}
int FileMgr::getFiles ( const Io::IoTech tech,
const Io::IoFlags flags,
std::vector< std::string > &  files,
bool  onlyOpen = true 
) const
virtual

Definition at line 1164 of file FileMgr.cpp.

{
files.clear();
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->tech() == tech || tech == UNKNOWN) {
if ( itr->second->flags() == flags ) {
if (find( files.begin(), files.end(), itr->first ) == files.end()) {
files.push_back(itr->first);
}
}
}
}
if (!op) {
for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
if ( (*it2)->tech() == tech || tech == UNKNOWN) {
if ( (*it2)->flags() == flags ) {
if (find(files.begin(), files.end(), (*it2)->name()) == files.end()){
files.push_back( (*it2)->name());
}
}
}
}
}
return files.size();
}
int FileMgr::getFiles ( const Io::IoTech tech,
const Io::IoFlags flags,
std::vector< const Io::FileAttr * > &  files,
bool  onlyOpen = true 
) const
virtual

Definition at line 1199 of file FileMgr.cpp.

{
files.clear();
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->tech() == tech || tech == UNKNOWN) {
if ( itr->second->flags() == flags ) {
files.push_back( (itr->second) );
}
}
}
if (!op) {
for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
if ( (*it2)->tech() == tech || tech == UNKNOWN) {
if ( (*it2)->flags() == flags ) {
files.push_back( *it2);
}
}
}
}
return files.size();
}
virtual StatusCode FileMgr::getHandler ( const IoTech &  ,
FileHdlr  
) const
virtual
StatusCode FileMgr::getHandler ( const std::string fname,
Io::FileHdlr hdlr 
) const
virtual

Definition at line 1448 of file FileMgr.cpp.

{
if (fitr.first == fitr.second) {
<< "no file \"" << fname << "\" registered. Cannot determine tech"
<< endmsg;
}
IoTech tech = itr->second->tech();
itr++;
while( itr != fitr.second ) {
if ( itr->second->tech() != tech ) {
<< "multiple technologies registered for file \"" << fname
<< "\". Cannot determine handler" << endmsg;
}
itr++;
}
return getHandler(tech,hdlr);
}
int FileMgr::getLastError ( std::string err) const
virtual

Definition at line 1419 of file FileMgr.cpp.

{
return m_lastErr;
}
void FileMgr::handle ( const Incident )
virtual

Definition at line 230 of file FileMgr.cpp.

{
}
StatusCode FileMgr::hasHandler ( const IoTech ) const
virtual

Definition at line 303 of file FileMgr.cpp.

{
if (itr != m_handlers.end()) {
} else {
}
}
StatusCode FileMgr::initialize ( )
virtual

Reimplemented from Service.

Definition at line 64 of file FileMgr.cpp.

{
// Super ugly hack to make sure we have the OutputLevel set first, so we
// can see DEBUG printouts in update handlers.
IJobOptionsSvc* jos(0);
if( serviceLocator()->service( "JobOptionsSvc", jos, true ).isSuccess() ) {
const std::vector<const Property*> *props = jos->getProperties( name() );
if (props != NULL) {
cur != props->end(); cur++) {
if ( (*cur)->name() == "OutputLevel" ) {
setProperty( **cur ).ignore();
break;
}
}
}
}
if (status.isFailure()) {
m_log << MSG::DEBUG << "Failed to initialize the base class (Service)"
<< endmsg;
return status;
}
m_log << MSG::VERBOSE << "Initializing FileMgr" << endmsg;
// setup file handler for ROOT
msgSvc()->setOutputLevel( "RootFileHandler", m_outputLevel.value());
boost::bind( &RootFileHandler::openRootFile, m_rfh, _1,_2,_3,_4,_5),
if (regHandler(hdlr).isFailure()) {
<< "unable to register ROOT file handler with FileMgr"
<< endmsg;
}
}
// setup file handler for POSIX
msgSvc()->setOutputLevel( "POSIXFileHandler", m_outputLevel.value());
boost::bind( &POSIXFileHandler::openPOSIXFile, m_pfh, _1,_2,_3,_4,_5),
if (regHandler(hdlp).isFailure()) {
<< "unable to register ROOT file handler with FileMgr"
<< endmsg;
}
}
}
bool FileMgr::isShareable ( const std::string filename,
const Io::IoFlags  
) const
private
void FileMgr::listActions ( ) const
virtual

Definition at line 1541 of file FileMgr.cpp.

{
m_log << MSG::INFO << "listing registered actions" << endl;
typedef StatusCode (*ptf)(const Io::FileAttr&, const std::string&);
for (iit = m_actions.begin(); iit != m_actions.end(); ++iit) {
Io::IoTech t = iit->first;
const actionMap& m = iit->second;
if (m.size() != 0) {
m_log << " --- Tech: ";
if (t == Io::UNKNOWN) {
m_log << "ALL ---" << endl;
} else {
m_log << t << " ---" << endl;
}
for (iia = m.begin() ; iia != m.end(); ++iia) {
if (iia->second.size() != 0) {
// for (list<bfcn_action_t>::const_iterator it2 = iia->second.begin();
// it2 != iia->second.end(); ++it2) {
for (list<bfcn_desc_t>::const_iterator it2 = iia->second.begin();
it2 != iia->second.end(); ++it2) {
m_log << " " << iia->first << " "
<< it2->second
<< endl;
}
}
}
}
}
}
void FileMgr::listFiles ( ) const
virtual

Definition at line 1396 of file FileMgr.cpp.

{
m_log << MSG::INFO << "listing registered files ["
<< "]:" << endl;
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
m_log << *(itr->second) << endl;
}
it2 != m_oldFiles.end(); ++it2) {
m_log << **it2 << endl;
}
}
void FileMgr::listHandlers ( ) const
virtual

Definition at line 1481 of file FileMgr.cpp.

{
<< "Listing registered handlers:" << endl;
for (itr=m_handlers.begin(); itr != m_handlers.end(); ++itr) {
m_log << " " << itr->first << endl;
}
}
void FileMgr::listSuppression ( ) const
virtual

Definition at line 1720 of file FileMgr.cpp.

{
if (m_supMap.size() == 0) return;
m_log << MSG::INFO << "listing suppressed file actions" << endl;
for (it2=m_supMap.begin(); it2 != m_supMap.end(); ++it2) {
m_log << " " << it2->first;
if (get_bit(it2->second, Io::INVALID_ACTION)) {
m_log << " ALL" << endl;
} else {
for (int i=0; i<Io::INVALID_ACTION; ++i) {
if (get_bit(it2->second,i)) { m_log << " " << (Io::Action)i; }
}
m_log << endl;
}
}
}
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

Definition at line 317 of file FileMgr.cpp.

{
return open(tech, caller, fname, desc, flags, fd, ptr, sh);
}
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

Definition at line 328 of file FileMgr.cpp.

{
void* dummy(0);
return open(tech, caller, fname, desc, flags, fd, dummy, sh);
}
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

Definition at line 340 of file FileMgr.cpp.

{
Fd dummy(-1);
return open(tech, caller, fname, desc, flags, dummy, ptr, sh);
}
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

Definition at line 1498 of file FileMgr.cpp.

{
m_log << MSG::DEBUG << "registering " << a << " action "
<< System::typeinfoName(bf.target_type()) << endmsg;
if (d == "") {
m_actions[Io::UNKNOWN][a].push_back
(make_pair(bf,System::typeinfoName(bf.target_type())));
} else {
m_actions[Io::UNKNOWN][a].push_back(make_pair(bf,d));
}
}
StatusCode FileMgr::regAction ( Io::bfcn_action_t  bf,
const Io::Action a,
const Io::IoTech t,
const std::string desc = "" 
)
virtual

Definition at line 1519 of file FileMgr.cpp.

{
m_log << MSG::DEBUG << "registering " << a << " action "
<< System::typeinfoName(bf.target_type())
<< " for tech " << t << endmsg;
if (d == "") {
m_actions[t][a].push_back
(make_pair(bf, System::typeinfoName(bf.target_type())));
} else {
m_actions[t][a].push_back(make_pair(bf,d));
}
}
StatusCode FileMgr::regHandler ( FileHdlr  fh)
virtual

Definition at line 237 of file FileMgr.cpp.

{
IoTech tech = fh.tech;
if (m_handlers.find(tech) != m_handlers.end()) {
<< "Handler for IoTech " << tech << " already registered. Ignoring."
<< endmsg;
}
if (fh.b_open_fcn.empty()) {
<< "open handler for tech " << tech << " is NULL"
<< endmsg;
}
if (fh.b_close_fcn.empty() && fh.b_closeP_fcn.empty()) {
<< "no close handler for tech " << tech << " registered"
<< endmsg;
}
if (fh.b_reopen_fcn.empty() && fh.b_reopenP_fcn.empty()) {
<< "no reopen handler for tech " << tech << " registered"
<< endmsg;
}
<< "Successfully registered handler for tech \"" << tech << "\""
<< endmsg;
m_handlers[tech] = fh;
}
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

Definition at line 889 of file FileMgr.cpp.

{
m_log << MSG::VERBOSE << "reopen(" << vp << "," << flags
<< "," << caller << ")"
<< endmsg;
reopen_t r = -1;
for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->fptr() == vp) {
break;
}
}
if (itr == m_files.end()) {
<< "unregistered file ptr \"" << vp
<< "\" when calling reopen()"
<< endmsg;
return r;
}
FileAttr *fa = itr->second;
IoTech tech = fa->tech();
if (getHandler(tech,fh).isFailure()) {
return r;
}
if (fh.b_reopenP_fcn.empty()) {
m_log << MSG::ERROR << "no reopen(" << tech << ",void*) function registered"
<< endmsg;
return -1;
}
try {
r = fh.b_reopenP_fcn(vp,flags);
} catch (const boost::bad_function_call& err) {
m_log << MSG::ERROR << "when calling reopen handler for " << tech
<< " on file " << fa->name() << " with flags "
<< flags
<< " caught " << err.what() << endmsg;
return -1;
} catch (...) {
m_log << MSG::ERROR << "when calling reopen handler for " << tech
<< " on file " << fa->name() << " with flags "
<< flags
<< " caught an unknown exception." << endmsg;
return -1;
}
if (r < 0) {
<< "reopen of file with ptr \"" << vp
<< "\", name: \"" << fa->name()
<< "\", tech: \"" << tech
<< "\", flags: \"" << flags << "\" failed"
<< endmsg;
execAction(fa, caller, Io::REOPEN_ERR ).ignore();
return r;
}
fa->isOpen(true);
fa->flags(flags);
// exec all callbacks
if (execAction(fa, caller, Io::REOPEN).isFailure()) {
<< "at least one reopen callback action failed"
<< endmsg;
}
return r;
}
void FileMgr::suppressAction ( const std::string f)
virtual

Definition at line 1695 of file FileMgr.cpp.

void FileMgr::suppressAction ( const std::string f,
const Io::Action a 
)
virtual

Definition at line 1704 of file FileMgr.cpp.

{
if (it2 == m_supMap.end()) {
int b(0);
set_bit(b,a);
m_supMap[f] = b;
} else {
set_bit(it2->second, a);
}
}

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:

Generated at Wed Dec 4 2013 14:33:15 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004