All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FileReadTool.cpp
Go to the documentation of this file.
1 #include "FileReadTool.h"
2 #include <fstream>
3 
6 
7 FileReadTool::FileReadTool( const std::string& type,
8  const std::string& name,
9  const IInterface* parent):
10  base_class(type, name, parent)
11 {
12  //declareInterface<IFileAccess>(this);
13  m_protocols.push_back("file");
14 }
15 
17 
18 std::auto_ptr<std::istream> FileReadTool::open(const std::string &url) {
19  // remove the optional "file://" from the beginning of the url
20  std::string path;
21  if ( url.substr(0,7) == "file://" ) {
22  path = url.substr(7);
23  } else {
24  path = url;
25  }
26  return std::auto_ptr<std::istream>(new std::ifstream(path.c_str()));
27 }
28 
29 const std::vector<std::string> &FileReadTool::protocols() const
30 {
31  return m_protocols;
32 }
Basic implementation of the IFileAccess interface.
Definition: FileReadTool.h:17
std::vector< std::string > m_protocols
Vector of supported protocols.
Definition: FileReadTool.h:39
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 re...
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
virtual const std::vector< std::string > & protocols() const
Protocols supported by the instance.
string type
Definition: gaudirun.py:126
virtual ~FileReadTool()
Definition of the basic interface.
Definition: IInterface.h:160
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram