| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

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

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# FileReadTool Class Reference

`#include <FileReadTool.h>`

Inheritance diagram for FileReadTool:

[legend]
Collaboration diagram for FileReadTool:

[legend]
List of all members.

## Detailed Description

Basic implementation of the IFileAccess interface.

This tool simply takes a path to a file as url and return the std::istream interface of std::ifstream.

Author:
  Marco Clemencic

Date:
  2008-01-18

Definition at line 17 of file FileReadTool.h.

## Public Member Functions
| FileReadTool (const std::string &type, const std::string &name, const IInterface *parent)
| Standard constructor.
virtual | ~FileReadTool ()
virtual std::auto_ptr< std::istream > | open (const std::string &url)
| Find the URL and returns an auto_ptr to an input stream interface of an object that can be used to read from the file the URL is pointing to.
virtual const std::vector< std::string > & | protocols () const
| Protocols supported by the instance.
## Private Attributes
std::vector< std::string > | m_protocols
| Vector of supported protocols.

## Constructor & Destructor Documentation

FileReadTool::FileReadTool | ( | const std::string & | type,
|  | const std::string & | name,
|  | const IInterface * | parent |
| ) |  |  |

Standard constructor.

Definition at line 7 of file FileReadTool.cpp.

    00009                                                      :
    00010   AlgTool ( type, name , parent )
    00011 {
    00012   declareInterface<IFileAccess>(this);
    00013   m_protocols.push_back("file");
    00014 }

FileReadTool::~FileReadTool | ( |  | ) | `[virtual]`

Definition at line 16 of file FileReadTool.cpp.

    00016 {}

## Member Function Documentation

std::auto_ptr< std::istream > FileReadTool::open | ( | const std::string & | url | ) | `[virtual]`

Find the URL and returns an auto_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.

Implements IFileAccess.

Definition at line 18 of file FileReadTool.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), Gaudi::Utils::Histos::path(), and std::basic_string< _CharT, _Traits, _Alloc >::substr().

    00018                                                                {
    00019   // remove the optional "file://" from the beginnning of the url
    00020   std::string path;
    00021   if ( url.substr(0,7) == "file://" ) {
    00022     path = url.substr(7);
    00023   } else {
    00024     path = url;
    00025   }
    00026   return std::auto_ptr<std::istream>(new std::ifstream(path.c_str()));
    00027 }

const std::vector< std::string > & FileReadTool::protocols | ( |  | ) | const`[virtual]`

Protocols supported by the instance.

Implements IFileAccess.

Definition at line 29 of file FileReadTool.cpp.

References m_protocols.

    00030 {
    00031   return m_protocols;
    00032 }

## Member Data Documentation

std::vector<std::string> FileReadTool::m_protocols`[private]`

Vector of supported protocols.

Definition at line 39 of file FileReadTool.h.

Referenced by protocols().

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiSvc/v17r1/src/VFSSvc/FileReadTool.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiSvc/v17r1/src/VFSSvc/FileReadTool.cpp