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 | Protected Member Functions | Private Attributes | Friends | List of all members
VFSSvc Class Reference

Simple service that allows to read files independently from the storage. More...

#include <VFSSvc.h>

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

Public Member Functions

virtual StatusCode initialize ()
 Initialize Service.
 
virtual StatusCode finalize ()
 Finalize Service.
 
virtual std::auto_ptr
< std::istream
open (const std::string &url)
 
virtual const std::vector
< std::string > & 
protocols () const
 
- Public Member Functions inherited from extends1< Service, IFileAccess >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends1 (A1 a1)
 Templated constructor with 1 argument.
 
 extends1 ()
 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 ~extends1 ()
 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_interfaces1< IFileAccess >
virtual ~extend_interfaces1 ()
 Virtual destructor.
 
- Public Member Functions inherited from IFileAccess
 DeclareInterfaceID (IFileAccess, 2, 0)
 InterfaceID.
 
virtual ~IFileAccess ()
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance.
 
virtual unsigned long release ()=0
 Release Interface instance.
 
virtual unsigned long refCount () const =0
 Current reference count.
 
virtual ~IInterface ()
 Virtual destructor.
 

Protected Member Functions

 VFSSvc (const std::string &name, ISvcLocator *svcloc)
 Standard constructor.
 
virtual ~VFSSvc ()
 Destructor.
 

Private Attributes

std::vector< std::stringm_urlHandlersNames
 Names of the handlers to use.
 
std::vector< std::stringm_protocols
 Protocols registered.
 
std::string m_fallBackProtocol
 Protocol to use in case there is not a specific tool to handle the URL.
 
GaudiUtils::HashMap
< std::string, IFileAccess * > 
m_urlHandlers
 Map of the tools handling the known protocols.
 
SmartIF< IToolSvcm_toolSvc
 Handle to the tool service.
 
std::list< IAlgTool * > m_acquiredTools
 List of acquired tools (needed to release them).
 

Friends

class SvcFactory< VFSSvc >
 

Additional Inherited Members

- Public Types inherited from extends1< Service, IFileAccess >
typedef extends1 base_class
 Typedef to this class.
 
typedef extend_interfaces1
< IFileAccess
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface.
 
- 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

Simple service that allows to read files independently from the storage.

The service uses tools to resolve URLs and serve the files as input streams. The basic implementations read from the filesystem, and simple extensions allow to read from databases, web...

Author
Marco Clemencic
Date
2008-01-18

Definition at line 28 of file VFSSvc.h.

Constructor & Destructor Documentation

VFSSvc::VFSSvc ( const std::string name,
ISvcLocator svcloc 
)
protected

Standard constructor.

Definition at line 11 of file VFSSvc.cpp.

:
m_urlHandlersNames.push_back("FileReadTool");
"List of tools implementing the IFileAccess interface.");
declareProperty("FallBackProtocol",m_fallBackProtocol = "file",
"URL prefix to use if the prefix is not present.");
}
VFSSvc::~VFSSvc ( )
protectedvirtual

Destructor.

Definition at line 23 of file VFSSvc.cpp.

{}

Member Function Documentation

StatusCode VFSSvc::finalize ( )
virtual

Finalize Service.

Reimplemented from Service.

Definition at line 77 of file VFSSvc.cpp.

{
m_urlHandlers.clear(); // clear the map
if (m_toolSvc) {
// release the acquired tools (from the last acquired one)
m_toolSvc->releaseTool(*m_acquiredTools.begin()).ignore();
}
m_toolSvc->release(); // release the tool service
m_toolSvc = 0;
}
}
StatusCode VFSSvc::initialize ( )
virtual

Initialize Service.

Reimplemented from Service.

Definition at line 25 of file VFSSvc.cpp.

{
if (sc.isFailure()){
return sc;
}
m_toolSvc = serviceLocator()->service("ToolSvc");
if (!m_toolSvc.isValid()){
log << MSG::ERROR << "Cannot locate ToolSvc" << endmsg;
}
IAlgTool *tool;
IFileAccess *hndlr;
// retrieve the tool and the pointer to the interface
sc = m_toolSvc->retrieve(*i,IAlgTool::interfaceID(),tool,0,true);
if (sc.isFailure()){
log << MSG::ERROR << "Cannot get tool " << *i << endmsg;
return sc;
}
m_acquiredTools.push_front(tool); // this is one tool that we will have to release
sc = tool->queryInterface(IFileAccess::interfaceID(),pp_cast<void>(&hndlr));
if (sc.isFailure()){
log << MSG::ERROR << *i << " does not implement IFileAccess" << endmsg;
return sc;
}
// We do not need to increase the reference count for the IFileAccess interface
// because we hold the tool by its IAlgTool interface.
hndlr->release();
// loop over the list of supported protocols and add them to the map (for quick access)
prot != hndlr->protocols().end(); ++prot ){
m_urlHandlers[*prot] = hndlr;
}
}
// Now let's check if we can handle the fallback protocol
log << MSG::ERROR << "No handler specified for fallback protocol prefix "
}
// Note: the list of handled protocols will be filled only if requested
return sc;
}
std::auto_ptr< std::istream > VFSSvc::open ( const std::string url)
virtual
See Also
IFileAccess::open

Implements IFileAccess.

Definition at line 93 of file VFSSvc.cpp.

{
// get the url prefix endpos
std::string::size_type pos = url.find("://");
if (std::string::npos == pos) { // no url prefix
return m_urlHandlers[m_fallBackProtocol]->open(url);
}
std::string url_prefix(url,0,pos);
if ( m_urlHandlers.find(url_prefix) == m_urlHandlers.end() ) {
// if we do not have a handler for the URL prefix,
// use the fall back one and pass only the path
return m_urlHandlers[m_fallBackProtocol]->open(url.substr(pos+3));
}
return m_urlHandlers[url_prefix]->open(url);
}
const std::vector< std::string > & VFSSvc::protocols ( ) const
virtual
See Also
IFileAccess::protocols

Implements IFileAccess.

Definition at line 128 of file VFSSvc.cpp.

{
// prepare the list of handled protocols
append_key<std::vector<std::string> >(const_cast<VFSSvc*>(this)->m_protocols));
}
return m_protocols;
}

Friends And Related Function Documentation

friend class SvcFactory< VFSSvc >
friend

Definition at line 50 of file VFSSvc.h.

Member Data Documentation

std::list<IAlgTool*> VFSSvc::m_acquiredTools
private

List of acquired tools (needed to release them).

Definition at line 68 of file VFSSvc.h.

std::string VFSSvc::m_fallBackProtocol
private

Protocol to use in case there is not a specific tool to handle the URL.

Definition at line 59 of file VFSSvc.h.

std::vector<std::string> VFSSvc::m_protocols
private

Protocols registered.

Definition at line 56 of file VFSSvc.h.

SmartIF<IToolSvc> VFSSvc::m_toolSvc
private

Handle to the tool service.

Definition at line 65 of file VFSSvc.h.

GaudiUtils::HashMap<std::string,IFileAccess*> VFSSvc::m_urlHandlers
private

Map of the tools handling the known protocols.

Definition at line 62 of file VFSSvc.h.

std::vector<std::string> VFSSvc::m_urlHandlersNames
private

Names of the handlers to use.

Definition at line 53 of file VFSSvc.h.


The documentation for this class was generated from the following files:
Generated at Wed Dec 4 2013 14:33:20 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004