| The Gaudi Framework v28r2p1 (f1a77ff4)

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

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

Public Member Functions | Private Attributes | List of all members
VFSSvc Class Reference

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

`#include <src/component/VFSSvc.h>`

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

## Public Member Functions
StatusCode | initialize () override
| Initialize Service. More...
StatusCode | finalize () override
| Finalize Service. More...
std::unique_ptr< std::istream > | open (const std::string &url) override
const std::vector< std::string > & | protocols () const override
| ~VFSSvc () override=default
| Destructor. More...
Public Member Functions inherited from extends< Service, IFileAccess >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
StatusCode | configure () override
StatusCode | initialize () override
StatusCode | start () override
StatusCode | stop () override
StatusCode | finalize () override
StatusCode | terminate () override
Gaudi::StateMachine::State | FSMState () const override
Gaudi::StateMachine::State | targetFSMState () const override
StatusCode | reinitialize () override
StatusCode | restart () override
StatusCode | sysInitialize () override
| Initialize Service. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
template<class T >
StatusCode | declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Private tool. More...
template<class T >
StatusCode | declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Public tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| PropertyHolder ()=default
| ~PropertyHolder () override=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
| Helper to wrap a regular data member and use it as a regular property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces... >
| ~extend_interfaces () override=default
| Virtual destructor. More...

## Private Attributes
Gaudi::Property< std::vector< std::string > > | m_urlHandlersNames
Gaudi::Property< std::string > | m_fallBackProtocol
std::vector< std::string > | m_protocols
| Protocols registered. More...
GaudiUtils::HashMap< std::string, std::vector< IFileAccess * > > | m_urlHandlers
| Map of the tools handling the known protocols. More...
SmartIF< IToolSvc > | m_toolSvc
| Handle to the tool service. More...
std::vector< IAlgTool * > | m_acquiredTools
| List of acquired tools (needed to release them). More...

## Additional Inherited Members
Public Types inherited from extends< Service, IFileAccess >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces... >
| Typedef to the base of this class. More...
Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces... >
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
| take union of the ext_iids of all Interfaces... More...
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::Property< int > | m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
Gaudi::Property< bool > | m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
Gaudi::Property< bool > | m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
Gaudi::Property< bool > | m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
Gaudi::Property< bool > | m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
Gaudi::Property< bool > | m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
Gaudi::Property< bool > | m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
Gaudi::Property< bool > | m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service. More...

## 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 26 of file VFSSvc.h.

## Constructor & Destructor Documentation

VFSSvc::~VFSSvc | ( |  | ) |
| override default

Destructor.

## Member Function Documentation

StatusCode VFSSvc::finalize | ( |  | ) |
| override

Finalize Service.

Definition at line 53 of file VFSSvc.cpp.

53 {
54 m_urlHandlers.clear(); // clear the map
55 m_protocols.clear();
56
57 if (m_toolSvc) {
58 // release the acquired tools (from the last acquired one)
59 while ( !m_acquiredTools.empty() ){
60 m_toolSvc->releaseTool(m_acquiredTools.back()).ignore();
61 m_acquiredTools.pop_back();
62 }
63 m_toolSvc.reset() ; // release the tool service
64 }
65 return Service::finalize();
66 }
VFSSvc::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Handle to the tool service.
Definition: VFSSvc.h:58
std::vector::empty
T empty(T...args)
VFSSvc::m_protocols
std::vector< std::string > m_protocols
Protocols registered.
Definition: VFSSvc.h:52
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:174
std::vector::pop_back
T pop_back(T...args)
std::vector::clear
T clear(T...args)
VFSSvc::m_acquiredTools
std::vector< IAlgTool * > m_acquiredTools
List of acquired tools (needed to release them).
Definition: VFSSvc.h:61
std::vector::back
T back(T...args)
GaudiUtils::Map::clear
void clear()
Definition: Map.h:178
IToolSvc::releaseTool
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
VFSSvc::m_urlHandlers
GaudiUtils::HashMap< std::string, std::vector< IFileAccess * > > m_urlHandlers
Map of the tools handling the known protocols.
Definition: VFSSvc.h:55

StatusCode VFSSvc::initialize | ( |  | ) |
| override

Initialize Service.

Definition at line 10 of file VFSSvc.cpp.

10 {
11 StatusCode sc = Service::initialize();
12 if (sc.isFailure()) return sc;
13
14
15 m_toolSvc = serviceLocator()->service("ToolSvc");
16 if (!m_toolSvc){
17 error() << "Cannot locate ToolSvc" << endmsg;
18 return StatusCode::FAILURE;
19 }
20
21 IAlgTool *tool;
22 for(const auto& i : m_urlHandlersNames) {
23 // retrieve the tool and the pointer to the interface
24 sc = m_toolSvc->retrieve(i, IAlgTool::interfaceID(), tool, nullptr, true);
25 if (sc.isFailure()){
26 error() << "Cannot get tool " << i << endmsg;
27 return sc;
28 }
29 m_acquiredTools.push_back(tool); // this is one tool that we will have to release
30 auto hndlr = SmartIF<IFileAccess>(tool);
31 if (!hndlr){
32 error() << i << " does not implement IFileAccess" << endmsg;
33 return StatusCode::FAILURE;
34 }
35 // We do not need to increase the reference count for the IFileAccess interface
36 // because we hold the tool by its IAlgTool interface.
37 // loop over the list of supported protocols and add them to the map (for quick access)
38 for ( const auto& prot : hndlr->protocols() ) m_urlHandlers[prot].emplace_back( hndlr.get() );
39 }
40
41 // Now let's check if we can handle the fallback protocol
42 if ( m_urlHandlers.find(m_fallBackProtocol) == m_urlHandlers.end() ) {
43 error() << "No handler specified for fallback protocol prefix "
44 << m_fallBackProtocol.value() << endmsg;
45 return StatusCode::FAILURE;
46 }
47
48 // Note: the list of handled protocols will be filled only if requested
49
50 return sc;
51 }
VFSSvc::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Handle to the tool service.
Definition: VFSSvc.h:58
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
IToolSvc::retrieve
virtual StatusCode retrieve(const std::string &type, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent=0, bool createIf=true)=0
Retrieve tool with tool dependent part of the name automatically assigned.
SmartIF< IFileAccess >
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
std::vector::push_back
T push_back(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
VFSSvc::m_fallBackProtocol
Gaudi::Property< std::string > m_fallBackProtocol
Definition: VFSSvc.h:48
VFSSvc::m_urlHandlersNames
Gaudi::Property< std::vector< std::string > > m_urlHandlersNames
Definition: VFSSvc.h:46
VFSSvc::m_acquiredTools
std::vector< IAlgTool * > m_acquiredTools
List of acquired tools (needed to release them).
Definition: VFSSvc.h:61
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
IInterface::interfaceID
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Definition: IInterface.h:243
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
VFSSvc::m_urlHandlers
GaudiUtils::HashMap< std::string, std::vector< IFileAccess * > > m_urlHandlers
Map of the tools handling the known protocols.
Definition: VFSSvc.h:55

std::unique_ptr< std::istream > VFSSvc::open | ( | const std::string & | url | ) |
| override

See also
  IFileAccess::open

Definition at line 68 of file VFSSvc.cpp.

68 {
69 // get the url prefix endpos
70 auto pos = url.find("://");
71
72 if (std::string::npos == pos) {
73 // no url prefix, try fallback protocol
74 return VFSSvc::open(m_fallBackProtocol + "://" + url);
75 }
76
77 const std::string url_prefix(url, 0, pos);
78 const auto handlers = m_urlHandlers.find(url_prefix);
79 if ( handlers == m_urlHandlers.end() ) {
80 // if we do not have a handler for the URL prefix,
81 // use the fall back one
82 return VFSSvc::open(m_fallBackProtocol + url.substr(pos));
83 }
84
85 std::unique_ptr<std::istream> out; // this might help RVO
86 // try the hendlers for the protocol one after the other until one succeds
87 for( auto hndlr: handlers->second ) {
88 out = hndlr->open(url);
89 if ( out ) break;
90 }
91 return out;
92 }
VFSSvc::open
std::unique_ptr< std::istream > open(const std::string &url) override
Definition: VFSSvc.cpp:68
std::string
STL class.
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
VFSSvc::m_fallBackProtocol
Gaudi::Property< std::string > m_fallBackProtocol
Definition: VFSSvc.h:48
std::string::find
T find(T...args)
std::unique_ptr
STL class.
std::string::substr
T substr(T...args)
VFSSvc::m_urlHandlers
GaudiUtils::HashMap< std::string, std::vector< IFileAccess * > > m_urlHandlers
Map of the tools handling the known protocols.
Definition: VFSSvc.h:55

const std::vector< std::string > & VFSSvc::protocols | ( |  | ) | const
| override

See also
  IFileAccess::protocols

Definition at line 104 of file VFSSvc.cpp.

105 {
106 if (m_protocols.empty()){
107 // prepare the list of handled protocols
108 std::transform( m_urlHandlers.begin(),m_urlHandlers.end(),
109 std::back_inserter(const_cast<VFSSvc*>(this)->m_protocols),
110 select1st );
111 }
112 return m_protocols;
113 }
std::vector::empty
T empty(T...args)
VFSSvc::m_protocols
std::vector< std::string > m_protocols
Protocols registered.
Definition: VFSSvc.h:52
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
GaudiUtils::Map::begin
iterator begin()
Definition: Map.h:131
std::back_inserter
T back_inserter(T...args)
std::transform
T transform(T...args)
VFSSvc::m_urlHandlers
GaudiUtils::HashMap< std::string, std::vector< IFileAccess * > > m_urlHandlers
Map of the tools handling the known protocols.
Definition: VFSSvc.h:55

## Member Data Documentation

std::vector<IAlgTool*> VFSSvc::m_acquiredTools
| private

List of acquired tools (needed to release them).

Definition at line 61 of file VFSSvc.h.

Gaudi::Property<std::string> VFSSvc::m_fallBackProtocol
| private

Initial value:
{this, "FallBackProtocol", "file",
"URL prefix to use if the prefix is not present."}

Definition at line 48 of file VFSSvc.h.

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

Protocols registered.

Definition at line 52 of file VFSSvc.h.

SmartIF<IToolSvc> VFSSvc::m_toolSvc
| private

Handle to the tool service.

Definition at line 58 of file VFSSvc.h.

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

Map of the tools handling the known protocols.

Definition at line 55 of file VFSSvc.h.

Gaudi::Property<std::vector<std::string> > VFSSvc::m_urlHandlersNames
| private

Initial value:
{
this, "FileAccessTools", {{"FileReadTool"}}, "List of tools implementing the IFileAccess interface."}

Definition at line 46 of file VFSSvc.h.

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

- GaudiUtils/src/component/VFSSvc.h
- GaudiUtils/src/component/VFSSvc.cpp