| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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:
[legend]
Collaboration diagram for FileMgr:
[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::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.
| 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::string > | getInterfaceNames () 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::string & | name () 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 Property & | getProperty (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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property.
Property * | declareRemoteProperty (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.
MsgStream & | msgStream () const
| Return an uninitialized MsgStream.
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts.
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL)
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR)
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR)
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING)
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO)
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG)
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & | msg () 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, FileHdlr > | m_handlers
std::map< Fd, FileAttr * > | m_descriptors
std::map< void *, FileAttr * > | m_fptr
std::vector< FileAttr * > | m_attr
fileList | m_oldFiles
std::map< IoTech, actionMap > | m_actions
supMap | m_supMap
std::string | m_lastErrS
int | m_lastErr
RootFileHandler * | m_rfh
POSIXFileHandler * | m_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

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.

: base_class( name, svc ),m_rfh(0), m_pfh(0),
m_log(msgSvc(), name )
{
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.

{
ON_VERBOSE
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.
ON_VERBOSE
m_log << MSG::VERBOSE << "close(" << vp << ")"
<< endmsg;
close_t r = -1;
fileMap::iterator itr;
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();
FileHdlr fh;
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
pair<fileMap::const_iterator, fileMap::const_iterator> fitr =
m_files.equal_range(fa->name());
int i(0);
for (fileMap::const_iterator it=fitr.first; it != fitr.second; ++it) {
if (it->second->fptr() == vp) {
i++;
}
}
ON_VERBOSE
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
ON_DEBUG
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()) ) {
ON_DEBUG
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) {
m_log << MSG::WARNING
<< "close of file with ptr \"" << vp
<< "\", name: \"" << fa->name()
<< "\", tech: \"" << tech << "\" failed"
<< endmsg;
return r;
}
m_files.erase(itr);
} else {
// this should never happen!
m_log << MSG::ERROR
<< "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);
m_oldFiles.push_back( fa );
// exec all callbacks
if (execAction(fa, caller, CLOSE).isFailure()) {
m_log << MSG::WARNING
<< "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;
map<IoTech,FileHdlr>::iterator itr = m_handlers.find(tech);
if (itr == m_handlers.end()) {
m_log << MSG::ERROR << "Can't de-register tech " << tech
<< " as it hasn't been registered!"
<< endmsg;
return StatusCode::FAILURE;
} else {
m_handlers.erase(itr);
}
return StatusCode::SUCCESS;
}

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();
StatusCode s1,s2;
if (m_actions[Io::UNKNOWN].size() != 0) {
actionMap &m = m_actions[Io::UNKNOWN];
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()) {
return StatusCode::FAILURE;
} else {
return StatusCode::SUCCESS;
}
}

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) {
return StatusCode::SUCCESS;
}
ON_DEBUG
m_log << MSG::DEBUG
<< "executing " << m[a].size() << " " << a
<< " actions on "
<< *fa << " from "
<< caller
<< endmsg;
bool fail(false);
supMap::const_iterator it2 = m_supMap.find(fa->name());
if (it2 != m_supMap.end()) {
if (get_bit(it2->second,a) || get_bit(it2->second,Io::INVALID_ACTION)) {
ON_DEBUG
m_log << MSG::DEBUG << " --> suppressing callback action for "
<< a
<< endmsg;
return StatusCode::SUCCESS;
}
}
for (list<bfcn_desc_t>::iterator itr = m[a].begin();
itr != m[a].end(); ++itr) {
ON_DEBUG
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) {
return StatusCode::FAILURE;
} else {
return StatusCode::SUCCESS;
}
}

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

Definition at line 1327 of file FileMgr.cpp.

{
pair<fileMap::const_iterator,fileMap::const_iterator> fitr =
m_files.equal_range(fname);
fileMap::const_iterator itr;
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.

{
fileMap::const_iterator itr;
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.

{
ON_VERBOSE
m_log << MSG::VERBOSE << "FileMgr::finalize()" << endmsg;
if (m_printSummary || outputLevel() <= MSG::DEBUG) {
listHandlers();
listFiles();
listActions();
listSuppression();
}
if (m_files.size() > 0) {
m_log << MSG::WARNING
<< "At finalize, the following files remained open:"
<< endl;
map<string,FileAttr*>::const_iterator itr;
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
m_log << *(itr->second) << endl;
}
m_log << endmsg;
}
if (m_logfile.value() != "") {
std::ofstream ofs;
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 {
ON_DEBUG
m_log << MSG::DEBUG << "Saving log to \"" << m_logfile.value() << "\""
<< endmsg;
fileMap::const_iterator itr;
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
ofs << itr->second->name() << " " << itr->second->tech() << " "
<< itr->second->desc() << " " << itr->second->iflags() << endl;
}
set<FileAttr> fs;
set<FileAttr>::const_iterator it3;
list<FileAttr*>::const_iterator it2;
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
for (vector<FileAttr*>::iterator itr = m_attr.begin(); itr != m_attr.end();
++itr) {
delete(*itr);
}
m_attr.clear();
delete m_rfh;
delete m_pfh;
StatusCode status = Service::finalize();
ON_DEBUG
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.

{
fileMap::const_iterator itr;
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.

{
fileMap::const_iterator itr;
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.

{
pair<fileMap::const_iterator,fileMap::const_iterator> fitr =
m_files.equal_range(fname);
fileMap::const_iterator itr;
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.

{
fileMap::const_iterator itr;
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();
map<Fd,FileAttr*>::const_iterator itr;
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();
map<Fd,FileAttr*>::const_iterator itr;
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();
pair<fileMap::const_iterator,fileMap::const_iterator> fitr =
m_files.equal_range(fname);
fileMap::const_iterator itr;
for (itr=fitr.first; itr != fitr.second; ++itr) {
fa.push_back( (itr->second) );
}
fileList::const_iterator it2;
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.

{
fileMap::const_iterator itr;
for (itr = m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->fptr() == vp) {
fa = (itr->second);
return StatusCode::SUCCESS;
}
}
fileList::const_iterator it2;
for (it2=m_oldFiles.begin(); it2!=m_oldFiles.end(); ++it2) {
if ( (*it2)->fptr() == vp ) {
fa = *it2;
return StatusCode::SUCCESS;
}
}
return StatusCode::FAILURE;
}

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

Definition at line 1049 of file FileMgr.cpp.

{
files.clear();
map<string,FileAttr*>::const_iterator itr;
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) {
std::list<FileAttr*>::const_iterator it2;
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();
map<string,FileAttr*>::const_iterator itr;
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
files.push_back( (itr->second) );
}
if (!op) {
std::list<FileAttr*>::const_iterator it2;
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();
map<string,FileAttr*>::const_iterator itr;
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) {
std::list<FileAttr*>::const_iterator it2;
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();
map<string,FileAttr*>::const_iterator itr;
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
if (itr->second->tech() == tech) {
files.push_back( (itr->second) );
}
}
if (!op) {
std::list<FileAttr*>::const_iterator it2;
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();
map<string,FileAttr*>::const_iterator itr;
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) {
std::list<FileAttr*>::const_iterator it2;
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();
map<string,FileAttr*>::const_iterator itr;
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) {
std::list<FileAttr*>::const_iterator it2;
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.

{
pair<fileMap::const_iterator,fileMap::const_iterator> fitr =
m_files.equal_range(fname);
if (fitr.first == fitr.second) {
m_log << MSG::ERROR
<< "no file \"" << fname << "\" registered. Cannot determine tech"
<< endmsg;
return StatusCode::FAILURE;
}
fileMap::const_iterator itr = fitr.first;
IoTech tech = itr->second->tech();
itr++;
while( itr != fitr.second ) {
if ( itr->second->tech() != tech ) {
m_log << MSG::ERROR
<< "multiple technologies registered for file \"" << fname
<< "\". Cannot determine handler" << endmsg;
return StatusCode::FAILURE;
}
itr++;
}
return getHandler(tech,hdlr);
}

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

Definition at line 1419 of file FileMgr.cpp.

{
err = m_lastErrS;
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.

{
map<IoTech,FileHdlr>::const_iterator itr = m_handlers.find(tech);
if (itr != m_handlers.end()) {
return StatusCode::SUCCESS;
} else {
return StatusCode::FAILURE;
}
}

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) {
for ( std::vector<const Property*>::const_iterator cur = props->begin();
cur != props->end(); cur++) {
if ( (*cur)->name() == "OutputLevel" ) {
setProperty( **cur ).ignore();
m_log.setLevel( m_outputLevel.value() );
break;
}
}
}
}
StatusCode status = Service::initialize();
m_log.setLevel( m_outputLevel.value() );
if (status.isFailure()) {
ON_DEBUG
m_log << MSG::DEBUG << "Failed to initialize the base class (Service)"
<< endmsg;
return status;
}
ON_VERBOSE
m_log << MSG::VERBOSE << "Initializing FileMgr" << endmsg;
if (m_loadRootHandler.value()) {
// setup file handler for ROOT
msgSvc()->setOutputLevel( "RootFileHandler", m_outputLevel.value());
m_rfh = new RootFileHandler(msgSvc(), m_ssl_proxy, m_ssl_cert);
Io::FileHdlr hdlr(Io::ROOT,
boost::bind( &RootFileHandler::openRootFile, m_rfh, _1,_2,_3,_4,_5),
(Io::bfcn_closeP_t) boost::bind( &RootFileHandler::closeRootFile, m_rfh, _1),
(Io::bfcn_reopenP_t) boost::bind( &RootFileHandler::reopenRootFile, m_rfh, _1,_2) );
if (regHandler(hdlr).isFailure()) {
m_log << MSG::ERROR
<< "unable to register ROOT file handler with FileMgr"
<< endmsg;
}
}
if (m_loadPosixHandler.value()) {
// setup file handler for POSIX
msgSvc()->setOutputLevel( "POSIXFileHandler", m_outputLevel.value());
m_pfh = new POSIXFileHandler(msgSvc());
Io::FileHdlr hdlp(Io::POSIX,
boost::bind( &POSIXFileHandler::openPOSIXFile, m_pfh, _1,_2,_3,_4,_5),
(Io::bfcn_close_t) boost::bind( &POSIXFileHandler::closePOSIXFile, m_pfh, _1),
(Io::bfcn_reopen_t) boost::bind( &POSIXFileHandler::reopenPOSIXFile, m_pfh, _1,_2) );
if (regHandler(hdlp).isFailure()) {
m_log << MSG::ERROR
<< "unable to register ROOT file handler with FileMgr"
<< endmsg;
}
}
return StatusCode::SUCCESS;
}

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;
actionMap::const_iterator itr;
typedef StatusCode (*ptf)(const Io::FileAttr&, const std::string&);
map<Io::IoTech, actionMap>::const_iterator iit;
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;
}
actionMap::const_iterator iia;
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;
}
}
}
}
}
m_log << endmsg;
}

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

Definition at line 1396 of file FileMgr.cpp.

{
m_log << MSG::INFO << "listing registered files ["
<< (m_files.size() + m_oldFiles.size() )
<< "]:" << endl;
fileMap::const_iterator itr;
for (itr=m_files.begin(); itr != m_files.end(); ++itr) {
m_log << *(itr->second) << endl;
}
for (list<FileAttr*>::const_iterator it2=m_oldFiles.begin();
it2 != m_oldFiles.end(); ++it2) {
m_log << **it2 << endl;
}
m_log << endmsg;
}

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

Definition at line 1481 of file FileMgr.cpp.

{
m_log << MSG::INFO
<< "Listing registered handlers:" << endl;
map<IoTech,FileHdlr>::const_iterator itr;
for (itr=m_handlers.begin(); itr != m_handlers.end(); ++itr) {
m_log << " " << itr->first << endl;
}
m_log << endmsg;
}

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;
supMap::const_iterator it2;
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;
}
}
m_log << endmsg;
}

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
| ) |  |
| private virtual

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.

{
ON_DEBUG
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));
}
return StatusCode::SUCCESS;
}

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.

{
ON_DEBUG
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));
}
return StatusCode::SUCCESS;
}

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()) {
m_log << MSG::WARNING
<< "Handler for IoTech " << tech << " already registered. Ignoring."
<< endmsg;
return StatusCode::SUCCESS;
}
if (fh.b_open_fcn.empty()) {
m_log << MSG::ERROR
<< "open handler for tech " << tech << " is NULL"
<< endmsg;
return StatusCode::FAILURE;
}
if (fh.b_close_fcn.empty() && fh.b_closeP_fcn.empty()) {
m_log << MSG::ERROR
<< "no close handler for tech " << tech << " registered"
<< endmsg;
return StatusCode::FAILURE;
}
if (fh.b_reopen_fcn.empty() && fh.b_reopenP_fcn.empty()) {
m_log << MSG::ERROR
<< "no reopen handler for tech " << tech << " registered"
<< endmsg;
return StatusCode::FAILURE;
}
ON_DEBUG
m_log << MSG::DEBUG
<< "Successfully registered handler for tech \"" << tech << "\""
<< endmsg;
m_handlers[tech] = fh;
return StatusCode::SUCCESS;
}

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.

{
ON_VERBOSE
m_log << MSG::VERBOSE << "reopen(" << vp << "," << flags
<< "," << caller << ")"
<< endmsg;
reopen_t r = -1;
fileMap::iterator itr;
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
<< "unregistered file ptr \"" << vp
<< "\" when calling reopen()"
<< endmsg;
return r;
}
FileAttr *fa = itr->second;
FileHdlr fh;
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) {
m_log << MSG::WARNING
<< "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()) {
m_log << MSG::WARNING
<< "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.

{
return suppressAction(f,Io::INVALID_ACTION);
}

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

Definition at line 1704 of file FileMgr.cpp.

{
supMap::iterator it2 = m_supMap.find(f);
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
| mutable private

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:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiSvc/src/FileMgr/FileMgr.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiSvc/src/FileMgr/FileMgr.cpp