| The Gaudi Framework v27r1

- 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 (const std::string &name, ISvcLocator *svcloc)
| Standard constructor. More...
| ~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...
StatusCode | setProperty (const Property &p) override
StatusCode | setProperty (const std::string &s) override
StatusCode | setProperty (const std::string &n, const std::string &v) override
StatusCode | getProperty (Property *p) const override
const Property & | getProperty (const std::string &name) const override
StatusCode | getProperty (const std::string &n, std::string &v) const override
const std::vector< Property * > & | getProperties () const override
bool | hasProperty (const std::string &name) const override
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value 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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties. 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 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
std::vector< std::string > | m_urlHandlersNames = { { "FileReadTool" } }
| Names of the handlers to use. More...
std::vector< std::string > | m_protocols
| Protocols registered. More...
std::string | m_fallBackProtocol
| Protocol to use in case there is not a specific tool to handle the URL. More...
GaudiUtils::HashMap< std::string, 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 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 CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
IntegerProperty | m_outputLevel = MSG::NIL
| Service output level. More...
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. 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 | ( | const std::string & | name,
|  | ISvcLocator * | svcloc
| ) |  |

Standard constructor.

Definition at line 10 of file VFSSvc.cpp.

10 :
11 base_class(name,svc)
12 {
13 declareProperty("FileAccessTools",m_urlHandlersNames,
14 "List of tools implementing the IFileAccess interface.");
15
16 declareProperty("FallBackProtocol",m_fallBackProtocol = "file",
17 "URL prefix to use if the prefix is not present.");
18 }
extends< Service, IFileAccess >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
VFSSvc::m_fallBackProtocol
std::string m_fallBackProtocol
Protocol to use in case there is not a specific tool to handle the URL.
Definition: VFSSvc.h:54
Service::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
VFSSvc::m_urlHandlersNames
std::vector< std::string > m_urlHandlersNames
Names of the handlers to use.
Definition: VFSSvc.h:48

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

Destructor.

## Member Function Documentation

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

Finalize Service.

Definition at line 63 of file VFSSvc.cpp.

63 {
64 m_urlHandlers.clear(); // clear the map
65 m_protocols.clear();
66
67 if (m_toolSvc) {
68 // release the acquired tools (from the last acquired one)
69 while ( !m_acquiredTools.empty() ){
70 m_toolSvc->releaseTool(m_acquiredTools.back()).ignore();
71 m_acquiredTools.pop_back();
72 }
73 m_toolSvc.reset() ; // release the tool service
74 }
75 return Service::finalize();
76 }
VFSSvc::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Handle to the tool service.
Definition: VFSSvc.h:60
std::vector::empty
T empty(T...args)
VFSSvc::m_protocols
std::vector< std::string > m_protocols
Protocols registered.
Definition: VFSSvc.h:51
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:193
VFSSvc::m_urlHandlers
GaudiUtils::HashMap< std::string, IFileAccess * > m_urlHandlers
Map of the tools handling the known protocols.
Definition: VFSSvc.h:57
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:63
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

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

Initialize Service.

Definition at line 20 of file VFSSvc.cpp.

20 {
21 StatusCode sc = Service::initialize();
22 if (sc.isFailure()) return sc;
23
24
25 m_toolSvc = serviceLocator()->service("ToolSvc");
26 if (!m_toolSvc){
27 error() << "Cannot locate ToolSvc" << endmsg;
28 return StatusCode::FAILURE;
29 }
30
31 IAlgTool *tool;
32 for(const auto& i : m_urlHandlersNames) {
33 // retrieve the tool and the pointer to the interface
34 sc = m_toolSvc->retrieve(i,IAlgTool::interfaceID(),tool,nullptr,true);
35 if (sc.isFailure()){
36 error() << "Cannot get tool " << i << endmsg;
37 return sc;
38 }
39 m_acquiredTools.push_back(tool); // this is one tool that we will have to release
40 auto hndlr = SmartIF<IFileAccess>(tool);
41 if (!hndlr){
42 error() << i << " does not implement IFileAccess" << endmsg;
43 return StatusCode::FAILURE;
44 }
45 // We do not need to increase the reference count for the IFileAccess interface
46 // because we hold the tool by its IAlgTool interface.
47 // loop over the list of supported protocols and add them to the map (for quick access)
48 for ( const auto& prot : hndlr->protocols() ) m_urlHandlers[prot] = hndlr.get();
49 }
50
51 // Now let's check if we can handle the fallback protocol
52 if ( m_urlHandlers.find(m_fallBackProtocol) == m_urlHandlers.end() ) {
53 error() << "No handler specified for fallback protocol prefix "
54 << m_fallBackProtocol << endmsg;
55 return StatusCode::FAILURE;
56 }
57
58 // Note: the list of handled protocols will be filled only if requested
59
60 return sc;
61 }
VFSSvc::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Handle to the tool service.
Definition: VFSSvc.h:60
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:68
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 >
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
VFSSvc::m_fallBackProtocol
std::string m_fallBackProtocol
Protocol to use in case there is not a specific tool to handle the URL.
Definition: VFSSvc.h:54
VFSSvc::m_urlHandlers
GaudiUtils::HashMap< std::string, IFileAccess * > m_urlHandlers
Map of the tools handling the known protocols.
Definition: VFSSvc.h:57
merge_files.sc
int sc
Definition: merge_files.py:167
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
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:118
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
StatusCode::FAILURE
Definition: StatusCode.h:29
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
ana.prot
prot
Definition: ana.py:53
VFSSvc::m_acquiredTools
std::vector< IAlgTool * > m_acquiredTools
List of acquired tools (needed to release them).
Definition: VFSSvc.h:63
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
ana.i
list i
Definition: ana.py:128
IInterface::interfaceID
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Definition: IInterface.h:243
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
VFSSvc::m_urlHandlersNames
std::vector< std::string > m_urlHandlersNames
Names of the handlers to use.
Definition: VFSSvc.h:48

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

See also
  IFileAccess::open

Definition at line 78 of file VFSSvc.cpp.

78 {
79
80 // get the url prefix endpos
81 auto pos = url.find("://");
82
83 if (std::string::npos == pos) { // no url prefix
84 return m_urlHandlers[m_fallBackProtocol]->open(url);
85 }
86
87 std::string url_prefix(url,0,pos);
88 if ( m_urlHandlers.find(url_prefix) == m_urlHandlers.end() ) {
89 // if we do not have a handler for the URL prefix,
90 // use the fall back one and pass only the path
91 return m_urlHandlers[m_fallBackProtocol]->open(url.substr(pos+3));
92 }
93 return m_urlHandlers[url_prefix]->open(url);
94 }
VFSSvc::m_fallBackProtocol
std::string m_fallBackProtocol
Protocol to use in case there is not a specific tool to handle the URL.
Definition: VFSSvc.h:54
VFSSvc::m_urlHandlers
GaudiUtils::HashMap< std::string, IFileAccess * > m_urlHandlers
Map of the tools handling the known protocols.
Definition: VFSSvc.h:57
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
std::string::find
T find(T...args)
std::string::substr
T substr(T...args)

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

See also
  IFileAccess::protocols

Definition at line 106 of file VFSSvc.cpp.

107 {
108 if (m_protocols.empty()){
109 // prepare the list of handled protocols
110 std::transform( m_urlHandlers.begin(),m_urlHandlers.end(),
111 std::back_inserter(const_cast<VFSSvc*>(this)->m_protocols),
112 select1st );
113 }
114 return m_protocols;
115 }
std::vector::empty
T empty(T...args)
VFSSvc::m_protocols
std::vector< std::string > m_protocols
Protocols registered.
Definition: VFSSvc.h:51
select1st
constexpr struct select1st_t select1st
VFSSvc::m_urlHandlers
GaudiUtils::HashMap< std::string, IFileAccess * > m_urlHandlers
Map of the tools handling the known protocols.
Definition: VFSSvc.h:57
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)

## Member Data Documentation

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

List of acquired tools (needed to release them).

Definition at line 63 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 54 of file VFSSvc.h.

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

Protocols registered.

Definition at line 51 of file VFSSvc.h.

SmartIF<IToolSvc> VFSSvc::m_toolSvc
| private

Handle to the tool service.

Definition at line 60 of file VFSSvc.h.

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

Map of the tools handling the known protocols.

Definition at line 57 of file VFSSvc.h.

std::vector<std::string> VFSSvc::m_urlHandlersNames = { { "FileReadTool" } }
| private

Names of the handlers to use.

Definition at line 48 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