Gaudi Framework, version v20r4

Generated: 8 Jan 2009

FileReadTool.cpp

Go to the documentation of this file.
00001 #include "FileReadTool.h"
00002 #include <fstream>
00003 
00004 #include "GaudiKernel/ToolFactory.h"
00005 DECLARE_TOOL_FACTORY( FileReadTool )
00006 
00007 FileReadTool::FileReadTool( const std::string& type, 
00008                             const std::string& name,
00009                             const IInterface* parent):
00010   AlgTool ( type, name , parent )
00011 {
00012   declareInterface<IFileAccess>(this);
00013   m_protocols.push_back("file");
00014 }
00015 
00016 FileReadTool::~FileReadTool(){}
00017 
00018 std::auto_ptr<std::istream> FileReadTool::open(const std::string &url) {
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 }
00028 
00029 const std::vector<std::string> &FileReadTool::protocols() const 
00030 {
00031   return m_protocols;
00032 }

Generated at Thu Jan 8 17:44:24 2009 for Gaudi Framework, version v20r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004