![]() |
|
|||
File indexing completed on 2025-02-21 10:00:31
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 #ifndef GaudiKernel_IFileAccess_H 0012 #define GaudiKernel_IFileAccess_H 0013 0014 // Include Files 0015 #include "GaudiKernel/IInterface.h" 0016 #include <istream> 0017 #include <memory> 0018 #include <optional> 0019 #include <string> 0020 #include <vector> 0021 0022 /** @class IFileAccess IFileAccess.h GaudiKernel/IFileAccess.h 0023 * 0024 * Abstract interface for a service or tool implementing a read access to files. 0025 * 0026 * @author Marco Clemencic 0027 * @date 2008-01-18 0028 */ 0029 class GAUDI_API IFileAccess : virtual public IInterface { 0030 public: 0031 /// InterfaceID 0032 DeclareInterfaceID( IFileAccess, 3, 1 ); 0033 0034 /// Find the URL and returns a unique_ptr to an input stream interface of an 0035 /// object that can be used to read from the file the URL is pointing to. 0036 /// Returns an empty pointer if the URL cannot be resolved. 0037 virtual std::unique_ptr<std::istream> open( std::string const& url ) = 0; 0038 0039 /// Find the URL and returns an optional<string> to the content of 0040 /// the file the URL is pointing to. 0041 /// Returns an 'unengaged' optional if the URL cannot be resolved. 0042 virtual std::optional<std::string> read( std::string const& url ) { 0043 auto is = open( url ); 0044 if ( !is || !is->good() ) return std::nullopt; 0045 return std::string{ std::istreambuf_iterator<char>{ *is }, std::istreambuf_iterator<char>{} }; 0046 } 0047 0048 /// Protocols supported by the instance. 0049 virtual const std::vector<std::string>& protocols() const = 0; 0050 }; 0051 0052 #endif // GaudiKernel_IFileAccess_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |