1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +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

@@ -42,8 +42,8 @@ class CDM_Application : public Standard_Transient
public:
//! the manager returned by this virtual method will be
//! used to search for Format`.Retrieval resource items.
//! The manager returned by this virtual method will be
//! used to search for Format.Retrieval resource items.
Standard_EXPORT virtual Handle(Resource_Manager) Resources() = 0;
//! By default returns a NullMessageDriver;

View File

@@ -60,12 +60,7 @@ CDM_Document::CDM_Document():
myRequestedNameIsDefined (Standard_False),
myRequestedPreviousVersionIsDefined(Standard_False),
myFileExtensionWasFound (Standard_False),
myDataTypeWasFound (Standard_False),
myVersionDataTypeWasFound (Standard_False),
myDescriptionWasFound (Standard_False),
myDomainWasFound (Standard_False),
myStoragePluginWasFound (Standard_False),
myDefaultPresentationWasFound (Standard_False)
myDescriptionWasFound (Standard_False)
{}
@@ -518,7 +513,7 @@ void CDM_Document::Comments(TColStd_SequenceOfExtendedString& aComments) const
Standard_ExtString CDM_Document::Comment() const
{
if (myComments.Length() < 1)
return TCollection_ExtendedString().ToExtString();
return 0;
return myComments(1).ToExtString();
}
@@ -556,7 +551,6 @@ void CDM_Document::ComputePresentation()
TCollection_ExtendedString presentation("");
static Standard_Integer theUnnamedDocuments(0);
static CDM_NamesDirectory theNames;
static CDM_NamesDirectory theTypes;
if(!myMetaData.IsNull()) {
presentation += myMetaData->Name();
@@ -571,21 +565,8 @@ void CDM_Document::ComputePresentation()
}
}
else {
LoadResources();
if(myDefaultPresentationWasFound) {
// presentation += "$";
presentation += myDefaultPresentation;
if(!theTypes.IsBound(presentation)) theTypes.Bind(presentation,0);
Standard_Integer range = theTypes(presentation);
range +=1;
theTypes(presentation) = range;
presentation += "_";
presentation += range;
}
else {
presentation += TCollection_ExtendedString("Document_");
presentation += ++theUnnamedDocuments;
}
presentation = "Document_";
presentation += ++theUnnamedDocuments;
}
if(getPresentations().IsBound(presentation)) {
@@ -1167,46 +1148,13 @@ void CDM_Document::LoadResources()
FIND(theDocumentResource,
theResourceName,myFileExtensionWasFound,myFileExtension);
theResourceName=theFormat;
theResourceName+="DataType";
FIND(theDocumentResource,theResourceName,myDataTypeWasFound,myDataType);
theResourceName=theFormat;
theResourceName+="VersionDataType";
FIND(theDocumentResource,
theResourceName,myVersionDataTypeWasFound,myVersionDataType);
theResourceName=theFormat;
theResourceName+="Description";
FIND(theDocumentResource,theResourceName,myDescriptionWasFound,myDescription);
theResourceName=theFormat;
theResourceName+="Domain";
FIND(theDocumentResource,theResourceName,myDomainWasFound,myDomain);
theResourceName=theFormat;
theResourceName+="Presentation";
FIND(theDocumentResource,
theResourceName,myDefaultPresentationWasFound,myDefaultPresentation);
theResourceName=theFormat;
theResourceName+="StoragePlugin";
TCollection_ExtendedString thePluginId;
FIND(theDocumentResource,theResourceName,myStoragePluginWasFound,thePluginId);
if(myStoragePluginWasFound)
{
// Check whether the GUID (as a string) contains blanks before and after the string.
// If it is so, remove them.
if (thePluginId.Search(' ') != -1)
thePluginId.RemoveAll(' ');
// Convert to GUID.
myStoragePlugin=UTL::GUID(thePluginId);
}
myResourcesAreLoaded=Standard_True;
// cout << "resource Loaded: Format: " << theFormat << ", FileExtension:" << myFileExtension << ", DataType:" << myDataType << ", VersionDataType:" << myVersionDataType << ", Description:" << myDescription << ", Domain:" << myDomain << endl;
// cout << "resource Loaded: Format: " << theFormat << ", FileExtension:" << myFileExtension << ", Description:" << myDescription << endl;
}
return;
}
@@ -1233,50 +1181,6 @@ TCollection_ExtendedString CDM_Document::FileExtension()
return myFileExtension;
}
//=======================================================================
//function : FindDataType
//purpose :
//=======================================================================
Standard_Boolean CDM_Document::FindDataType ()
{
LoadResources();
return myDataTypeWasFound;
}
//=======================================================================
//function : DataType
//purpose :
//=======================================================================
TCollection_ExtendedString CDM_Document::DataType()
{
LoadResources();
return myDataType;
}
//=======================================================================
//function : FindVersionDataType
//purpose :
//=======================================================================
Standard_Boolean CDM_Document::FindVersionDataType ()
{
LoadResources();
return myVersionDataTypeWasFound;
}
//=======================================================================
//function : VersionDataType
//purpose :
//=======================================================================
TCollection_ExtendedString CDM_Document::VersionDataType()
{
LoadResources();
return myVersionDataType;
}
//=======================================================================
//function : FindDescription
//purpose :
@@ -1299,50 +1203,6 @@ TCollection_ExtendedString CDM_Document::Description()
return myDescription;
}
//=======================================================================
//function : FindDomain
//purpose :
//=======================================================================
Standard_Boolean CDM_Document::FindDomain ()
{
LoadResources();
return myDomainWasFound;
}
//=======================================================================
//function : Domain
//purpose :
//=======================================================================
TCollection_ExtendedString CDM_Document::Domain()
{
LoadResources();
return myDomain;
}
//=======================================================================
//function : FindStoragePlugin
//purpose :
//=======================================================================
Standard_Boolean CDM_Document::FindStoragePlugin()
{
LoadResources();
return myStoragePluginWasFound;
}
//=======================================================================
//function : StoragePlugin
//purpose :
//=======================================================================
Standard_GUID CDM_Document::StoragePlugin()
{
LoadResources();
return myStoragePlugin;
}
//=======================================================================
//function : IsReadOnly
//purpose :

View File

@@ -20,17 +20,12 @@
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <CDM_ListOfReferences.hxx>
#include <CDM_CanCloseStatus.hxx>
#include <TColStd_SequenceOfExtendedString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Standard_Boolean.hxx>
#include <CDM_ListOfReferences.hxx>
#include <Standard_Integer.hxx>
#include <Standard_GUID.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Address.hxx>
#include <Standard_ExtString.hxx>
#include <Standard_OStream.hxx>
#include <CDM_CanCloseStatus.hxx>
class CDM_MetaData;
class CDM_Application;
class Standard_NoSuchObject;
@@ -40,8 +35,6 @@ class CDM_Reference;
class CDM_ReferenceIterator;
class TCollection_ExtendedString;
class Resource_Manager;
class Standard_GUID;
class CDM_Document;
DEFINE_STANDARD_HANDLE(CDM_Document, Standard_Transient)
@@ -292,33 +285,11 @@ public:
//! gets the Desktop.Domain.Application.`FileFormat`.FileExtension resource.
Standard_EXPORT TCollection_ExtendedString FileExtension();
Standard_EXPORT Standard_Boolean FindDataType();
//! this datatype will be used if the DBMS deals with this concept
//! gets the `FileFormat`.DataType resource.
//! concept.
Standard_EXPORT TCollection_ExtendedString DataType();
Standard_EXPORT Standard_Boolean FindVersionDataType();
//! this datatype will be used if the DBMS deals with this concept
//! gets the `FileFormat`.VersionDataType resource.
Standard_EXPORT TCollection_ExtendedString VersionDataType();
Standard_EXPORT Standard_Boolean FindDescription();
//! gets the `FileFormat`.Description resource.
Standard_EXPORT TCollection_ExtendedString Description();
Standard_EXPORT Standard_Boolean FindDomain();
//! gets the `FileFormat`.Domain resource.
Standard_EXPORT TCollection_ExtendedString Domain();
Standard_EXPORT Standard_Boolean FindStoragePlugin();
Standard_EXPORT Standard_GUID StoragePlugin();
//! returns true if the version is greater than the
//! storage version
Standard_EXPORT Standard_Boolean IsModified() const;
@@ -423,19 +394,9 @@ private:
Standard_Boolean myRequestedPreviousVersionIsDefined;
TCollection_ExtendedString myRequestedPreviousVersion;
TCollection_ExtendedString myFileExtension;
TCollection_ExtendedString myDataType;
TCollection_ExtendedString myVersionDataType;
TCollection_ExtendedString myDescription;
TCollection_ExtendedString myDomain;
TCollection_ExtendedString myDefaultPresentation;
Standard_Boolean myFileExtensionWasFound;
Standard_Boolean myDataTypeWasFound;
Standard_Boolean myVersionDataTypeWasFound;
Standard_Boolean myDescriptionWasFound;
Standard_Boolean myDomainWasFound;
Standard_Boolean myStoragePluginWasFound;
Standard_Boolean myDefaultPresentationWasFound;
Standard_GUID myStoragePlugin;
Handle(CDM_Application) myApplication;