The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
IFileAccess Class Referenceabstract

Abstract interface for a service or tool implementing a read access to files. More...

#include <GaudiKernel/IFileAccess.h>

Inheritance diagram for IFileAccess:
Collaboration diagram for IFileAccess:

Public Member Functions

 DeclareInterfaceID (IFileAccess, 3, 1)
 InterfaceID.
 
virtual std::unique_ptr< std::istream > open (std::string const &url)=0
 Find the URL and returns a unique_ptr to an input stream interface of an object that can be used to read from the file the URL is pointing to.
 
virtual std::optional< std::string > read (std::string const &url)
 Find the URL and returns an optional<string> to the content of the file the URL is pointing to.
 
virtual const std::vector< std::string > & protocols () const =0
 Protocols supported by the instance.
 
- Public Member Functions inherited from IInterface
template<Gaudi::IsInterface TARGET>
TARGET * cast ()
 
template<Gaudi::IsInterface TARGET>
TARGET const * cast () const
 
template<typename TARGET>
requires ( !Gaudi::IsInterface<TARGET> )
TARGET * cast ()
 
template<typename TARGET>
requires ( !Gaudi::IsInterface<TARGET> )
TARGET const * cast () const
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces.
 
virtual unsigned long addRef () const =0
 Increment the reference count of Interface instance.
 
virtual unsigned long release () const =0
 Release Interface instance.
 
virtual unsigned long refCount () const =0
 Current reference count.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance.
 
virtual ~IInterface ()=default
 Virtual destructor.
 
virtual void const * i_cast (const InterfaceID &) const =0
 
void * i_cast (const InterfaceID &iid)
 

Additional Inherited Members

- Public Types inherited from IInterface
enum class  Status : StatusCode::code_t {
  FAILURE = 0 , SUCCESS = 1 , NO_INTERFACE , VERSMISMATCH ,
  LAST_ERROR
}
 Return status. More...
 
using iid = Gaudi::InterfaceId<IInterface, 0, 0>
 Interface ID.
 
using ext_iids = Gaudi::interface_list<iid>
 Extra interfaces.
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface.
 
- Protected Member Functions inherited from IInterface
virtual unsigned long decRef () const =0
 Decrement reference count and return the new reference count.
 

Detailed Description

Abstract interface for a service or tool implementing a read access to files.

Author
Marco Clemencic
Date
2008-01-18

Definition at line 27 of file IFileAccess.h.

Member Function Documentation

◆ DeclareInterfaceID()

IFileAccess::DeclareInterfaceID ( IFileAccess ,
3 ,
1  )

◆ open()

virtual std::unique_ptr< std::istream > IFileAccess::open ( std::string const & url)
pure virtual

Find the URL and returns a unique_ptr to an input stream interface of an object that can be used to read from the file the URL is pointing to.

Returns an empty pointer if the URL cannot be resolved.

◆ protocols()

virtual const std::vector< std::string > & IFileAccess::protocols ( ) const
pure virtual

Protocols supported by the instance.

◆ read()

virtual std::optional< std::string > IFileAccess::read ( std::string const & url)
inlinevirtual

Find the URL and returns an optional<string> to the content of the file the URL is pointing to.

Returns an 'unengaged' optional if the URL cannot be resolved.

Definition at line 40 of file IFileAccess.h.

40 {
41 auto is = open( url );
42 if ( !is || !is->good() ) return std::nullopt;
43 return std::string{ std::istreambuf_iterator<char>{ *is }, std::istreambuf_iterator<char>{} };
44 }
virtual std::unique_ptr< std::istream > open(std::string const &url)=0
Find the URL and returns a unique_ptr to an input stream interface of an object that can be used to r...

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