From 36d21f1a1a157065b28f8348d5b7f4c91a015e52 Mon Sep 17 00:00:00 2001 From: kgv Date: Thu, 9 Sep 2021 21:04:21 +0300 Subject: [PATCH] 0032565: Foundation Classes, OSD_FileSystem - expose interface for registering global protocols Added methods OSD_FileSystem::AddDefaultProtocol()/::RemoveDefaultProtocol() and fixed misleading description of OSD_FileSystemSelector::AddProtocol(). --- src/OSD/OSD_FileSystem.cxx | 20 ++++++++++++++++++++ src/OSD/OSD_FileSystem.hxx | 11 ++++++++++- src/OSD/OSD_FileSystemSelector.hxx | 4 ++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/OSD/OSD_FileSystem.cxx b/src/OSD/OSD_FileSystem.cxx index 81fc4c2de1..ccb0a25c48 100644 --- a/src/OSD/OSD_FileSystem.cxx +++ b/src/OSD/OSD_FileSystem.cxx @@ -54,6 +54,26 @@ const Handle(OSD_FileSystem)& OSD_FileSystem::DefaultFileSystem() return aDefSystem; } +//======================================================================= +// function : AddDefaultProtocol +// purpose : +//======================================================================= +void OSD_FileSystem::AddDefaultProtocol (const Handle(OSD_FileSystem)& theFileSystem, bool theIsPreferred) +{ + Handle(OSD_FileSystemSelector) aFileSelector = Handle(OSD_FileSystemSelector)::DownCast (DefaultFileSystem()); + aFileSelector->AddProtocol (theFileSystem, theIsPreferred); +} + +//======================================================================= +// function : RemoveDefaultProtocol +// purpose : +//======================================================================= +void OSD_FileSystem::RemoveDefaultProtocol (const Handle(OSD_FileSystem)& theFileSystem) +{ + Handle(OSD_FileSystemSelector) aFileSelector = Handle(OSD_FileSystemSelector)::DownCast (DefaultFileSystem()); + aFileSelector->RemoveProtocol (theFileSystem); +} + //======================================================================= // function : openIStream // purpose : diff --git a/src/OSD/OSD_FileSystem.hxx b/src/OSD/OSD_FileSystem.hxx index 19334f9068..f741dc09a9 100644 --- a/src/OSD/OSD_FileSystem.hxx +++ b/src/OSD/OSD_FileSystem.hxx @@ -24,9 +24,18 @@ class OSD_FileSystem : public Standard_Transient DEFINE_STANDARD_RTTIEXT(OSD_FileSystem, Standard_Transient) public: - //! Returns a global file system, which a selector between registered file systems. + //! Returns a global file system, which a selector between registered file systems (OSD_FileSystemSelector). Standard_EXPORT static const Handle(OSD_FileSystem)& DefaultFileSystem(); + //! Registers file system within the global file system selector returned by OSD_FileSystem::DefaultFileSystem(). + //! Note that registering protocols is not thread-safe operation and expected to be done once at application startup. + //! @param[in] theFileSystem file system to register + //! @param[in] theIsPreferred add to the beginning of the list when TRUE, or add to the end otherwise + Standard_EXPORT static void AddDefaultProtocol (const Handle(OSD_FileSystem)& theFileSystem, bool theIsPreferred = false); + + //! Unregisters file system within the global file system selector returned by OSD_FileSystem::DefaultFileSystem(). + Standard_EXPORT static void RemoveDefaultProtocol (const Handle(OSD_FileSystem)& theFileSystem); + public: //! Returns TRUE if URL defines a supported protocol. diff --git a/src/OSD/OSD_FileSystemSelector.hxx b/src/OSD/OSD_FileSystemSelector.hxx index 60aa5e1fd6..89777f4175 100644 --- a/src/OSD/OSD_FileSystemSelector.hxx +++ b/src/OSD/OSD_FileSystemSelector.hxx @@ -27,12 +27,12 @@ public: //! Constructor. OSD_FileSystemSelector() {} - //! Registers file system within the global file system selector returned by OSD_FileSystem::DefaultFileSystem(). + //! Registers file system within this selector. //! @param theFileSystem [in] file system to register //! @param theIsPreferred [in] add to the beginning of the list when TRUE, or add to the end otherwise Standard_EXPORT void AddProtocol (const Handle(OSD_FileSystem)& theFileSystem, bool theIsPreferred = false); - //! Unregisters file system within the global file system selector returned by OSD_FileSystem::DefaultFileSystem(). + //! Unregisters file system within this selector. Standard_EXPORT void RemoveProtocol (const Handle(OSD_FileSystem)& theFileSystem); public: