Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:37

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 
0027   //! Constructor.
0028   OSD_FileSystemSelector() {}
0029 
0030   //! Registers file system within this selector.
0031   //! @param theFileSystem  [in] file system to register
0032   //! @param theIsPreferred [in] add to the beginning of the list when TRUE, or add to the end otherwise
0033   Standard_EXPORT void AddProtocol (const Handle(OSD_FileSystem)& theFileSystem, bool theIsPreferred = false);
0034 
0035   //! Unregisters file system within this selector.
0036   Standard_EXPORT void RemoveProtocol (const Handle(OSD_FileSystem)& theFileSystem);
0037 
0038 public:
0039 
0040   //! Returns TRUE if URL defines a supported protocol.
0041   Standard_EXPORT virtual bool IsSupportedPath (const TCollection_AsciiString& theUrl) const Standard_OVERRIDE;
0042 
0043   //! Returns TRUE if current input stream is opened for reading operations.
0044   Standard_EXPORT virtual Standard_Boolean IsOpenIStream (const std::shared_ptr<std::istream>& theStream) const Standard_OVERRIDE;
0045 
0046   //! Returns TRUE if current output stream is opened for writing operations.
0047   Standard_EXPORT virtual Standard_Boolean IsOpenOStream (const std::shared_ptr<std::ostream>& theStream) const Standard_OVERRIDE;
0048 
0049   //! Opens input stream using one of registered protocols.
0050   Standard_EXPORT virtual std::shared_ptr<std::istream> OpenIStream
0051                           (const TCollection_AsciiString& theUrl,
0052                            const std::ios_base::openmode theMode,
0053                            const int64_t theOffset = 0,
0054                            const std::shared_ptr<std::istream>& theOldStream = std::shared_ptr<std::istream>()) Standard_OVERRIDE;
0055 
0056   //! Opens output stream using one of registered protocols.
0057   Standard_EXPORT virtual std::shared_ptr<std::ostream> OpenOStream (const TCollection_AsciiString& theUrl,
0058                                                                      const std::ios_base::openmode theMode) Standard_OVERRIDE;
0059 
0060   //! Opens stream buffer using one of registered protocols.
0061   Standard_EXPORT virtual std::shared_ptr<std::streambuf> OpenStreamBuffer
0062                           (const TCollection_AsciiString& theUrl,
0063                            const std::ios_base::openmode theMode,
0064                            const int64_t theOffset = 0,
0065                            int64_t* theOutBufSize = NULL) Standard_OVERRIDE;
0066 
0067 protected:
0068 
0069   NCollection_List<Handle(OSD_FileSystem)> myProtocols;
0070 
0071 };
0072 
0073 #endif // _OSD_FileSystemSelector_HeaderFile