1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0025812: Replace dynamic loading mechanism of OCAF persistence with dynamic-link one

Fields to store cached instances of reader and writer drivers for each format are added in CDF_Application.
Method DefineFormat() is added in TDocStd_Application, allowing defining format completely by single call, including drivers to be used for persistence.
All OCAF driver packages provide static method DefineFormat() that defines standard OCAF persistence format supported by corresponding package; these methods are called in DRAW to enable all persistence by default.

DRAW commands (except TObj-specific ones) now use single instance of OCAF Application, returned by DDocStd::GetApplication(). Other instances are eliminated, as well as method DDocStd::Find(const Handle(TDocStd_Application)&).
Method MessageDriver() and relevant field are moved to TDocStd_Application from its descendants.

Method CDF_Application::ReaderFromFormat() is made virtual to allow its redefinition in descendants.
Creation of storage driver is moved from PCDM::StorageDriver() to new virtual method CDF_Application::WriterFromFormat().
The code loading driver as plugin is retained in both these methods for compatibility.

Test command OCC24925 is converted to use virtual methods instead of defining plugin resource.

Migration table for old OCAF types is hard-coded in Storage_Schema::CheckTypeMigration().

Removed obsolete and unused items:
- FWOSPlugin library (driver is created directly)
- Methods in classes CDM_Document dealing with unused parameters of format
- DRAW command OCC23010 for testing non-reproducible issue #23010
- Methods PCDM::StorageDriver(), PCDM::FindStorageDriver()
- Method Formats() from CDF_Application and descendants
- Methods LoadExtensions and SchemaName from PCDM_StorageDriver
- Method Plugin::AdditionalPluginMap()
- Method BinLDrivers_DocumentStorageDriver::SchemaName()
- Method CDF_Application::DefaultExtension(), Reader(), FindReader(), FindReaderFromFormat()
- Method CDF_Store::Check()
This commit is contained in:
abv
2016-06-20 06:53:14 +03:00
parent 8072aba1ae
commit 6fe96f8416
221 changed files with 1001 additions and 8896 deletions

View File

@@ -48,14 +48,11 @@ Handle(Standard_Transient) Plugin::Load (const Standard_GUID& aGUID,
theResource += ".Location";
if(!PluginResource->Find(theResource.ToCString())) {
PluginResource = AdditionalPluginMap();
if (!PluginResource->Find(theResource.ToCString())) {
Standard_SStream aMsg; aMsg << "could not find the resource:";
aMsg << theResource.ToCString()<< endl;
if (theVerbose)
cout << "could not find the resource:"<<theResource.ToCString()<< endl;
Plugin_Failure::Raise(aMsg);
}
Standard_SStream aMsg; aMsg << "could not find the resource:";
aMsg << theResource.ToCString() << endl;
if (theVerbose)
cout << "could not find the resource:" << theResource.ToCString() << endl;
Plugin_Failure::Raise(aMsg);
}
TCollection_AsciiString thePluginLibrary("");
@@ -102,11 +99,3 @@ Handle(Standard_Transient) Plugin::Load (const Standard_GUID& aGUID,
return theServiceFactory;
}
const Handle(Resource_Manager)& Plugin::AdditionalPluginMap()
{
static Handle(Resource_Manager) aMap;
if (aMap.IsNull())
aMap = new Resource_Manager ("" /*theName*/, Standard_False /*theVerbose*/);
return aMap;
}

View File

@@ -26,51 +26,11 @@ class Standard_Transient;
class Standard_GUID;
class Resource_Manager;
class Plugin
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT static Handle(Standard_Transient) Load (const Standard_GUID& aGUID, const Standard_Boolean theVerbose = Standard_True);
//! Returns a global map of {guid, plugin_library} pairs.
//! The Load() method will use this map to search for plugins if and only if
//! the GUID is not found in the Plugin file specified by the CSF_PluginDefaults
//! (or CSF_PluginUserDefaults) environment variable, or if they are not defined.
//!
//! This allows to populate this additional resource manager
//! in run-time and to avoid using the above environment variables.
//! This map must be populated (using Resource_Manager::SetResource() method)
//! following syntax conventions of the Plugin file, for instance:
//! const Handle(Resource_Manager)& aPluginMap = Plugin::AdditionalPluginMap();
//! aPluginMap->SetResource ("ad696000-5b34-11d1-b5ba-00a0c9064368.Location", "TKStdSchema");
Standard_EXPORT static const Handle(Resource_Manager)& AdditionalPluginMap();
protected:
private:
Standard_EXPORT static Handle(Standard_Transient) Load (const Standard_GUID& aGUID, const Standard_Boolean theVerbose = Standard_True);
};
#endif // _Plugin_HeaderFile