Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 09:17:49

0001 // Copyright (c) 2021 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _OSD_FileSystemSelector_HeaderFile
0015 #define _OSD_FileSystemSelector_HeaderFile
0016 
0017 #include <OSD_FileSystem.hxx>
0018 
0019 #include <NCollection_List.hxx>
0020 
0021 //! File system implementation which tried to open stream using registered list of file systems.
0022 class OSD_FileSystemSelector : public OSD_FileSystem
0023 {
0024   DEFINE_STANDARD_RTTIEXT(OSD_FileSystemSelector, OSD_FileSystem)
0025 public:
0026   //! Constructor.
0027   OSD_FileSystemSelector() {}
0028 
0029   //! Registers file system within this selector.
0030   //! @param[in] theFileSystem   file system to register
0031   //! @param[in] theIsPreferred  add to the beginning of the list when TRUE, or add to the end
0032   //! otherwise
0033   Standard_EXPORT void AddProtocol(const Handle(OSD_FileSystem)& theFileSystem,
0034                                    bool                          theIsPreferred = false);
0035 
0036   //! Unregisters file system within this selector.
0037   Standard_EXPORT void RemoveProtocol(const Handle(OSD_FileSystem)& theFileSystem);
0038 
0039 public:
0040   //! Returns TRUE if URL defines a supported protocol.
0041   Standard_EXPORT virtual bool IsSupportedPath(const TCollection_AsciiString& theUrl) const
0042     Standard_OVERRIDE;
0043 
0044   //! Returns TRUE if current input stream is opened for reading operations.
0045   Standard_EXPORT virtual Standard_Boolean IsOpenIStream(
0046     const std::shared_ptr<std::istream>& theStream) const Standard_OVERRIDE;
0047 
0048   //! Returns TRUE if current output stream is opened for writing operations.
0049   Standard_EXPORT virtual Standard_Boolean IsOpenOStream(
0050     const std::shared_ptr<std::ostream>& theStream) const Standard_OVERRIDE;
0051 
0052   //! Opens input stream using one of registered protocols.
0053   Standard_EXPORT virtual std::shared_ptr<std::istream> OpenIStream(
0054     const TCollection_AsciiString&       theUrl,
0055     const std::ios_base::openmode        theMode,
0056     const int64_t                        theOffset    = 0,
0057     const std::shared_ptr<std::istream>& theOldStream = std::shared_ptr<std::istream>())
0058     Standard_OVERRIDE;
0059 
0060   //! Opens output stream using one of registered protocols.
0061   Standard_EXPORT virtual std::shared_ptr<std::ostream> OpenOStream(
0062     const TCollection_AsciiString& theUrl,
0063     const std::ios_base::openmode  theMode) Standard_OVERRIDE;
0064 
0065   //! Opens stream buffer using one of registered protocols.
0066   Standard_EXPORT virtual std::shared_ptr<std::streambuf> OpenStreamBuffer(
0067     const TCollection_AsciiString& theUrl,
0068     const std::ios_base::openmode  theMode,
0069     const int64_t                  theOffset     = 0,
0070     int64_t*                       theOutBufSize = NULL) Standard_OVERRIDE;
0071 
0072 protected:
0073   NCollection_List<Handle(OSD_FileSystem)> myProtocols;
0074 };
0075 
0076 #endif // _OSD_FileSystemSelector_HeaderFile