mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-08 14:17:06 +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:
@@ -30,13 +30,11 @@
|
||||
#include <OSD_Path.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
//#include <AppStdL_Application.hxx>
|
||||
// avoid warnings on 'extern "C"' functions returning C++ classes
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(4:4190)
|
||||
#endif
|
||||
//static Handle(AppStdL_Application) stdApp;
|
||||
static Handle(AppStd_Application) stdApp;
|
||||
|
||||
//=======================================================================
|
||||
//function : AllComands
|
||||
//purpose :
|
||||
@@ -48,82 +46,16 @@ void DPrsStd::AllCommands (Draw_Interpretor& theCommands)
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
// APPLICATION
|
||||
if (stdApp.IsNull()) stdApp = new AppStd_Application ();//new AppStdL_Application ();
|
||||
|
||||
DPrsStd::AISPresentationCommands(theCommands);
|
||||
DPrsStd::AISViewerCommands(theCommands);
|
||||
//DPrsStd::BasicCommands(theCommands);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Found standard CAF Plugin
|
||||
//==============================================================================
|
||||
static Standard_Boolean FoundCAFPlugin () {
|
||||
|
||||
// Define Environment Variable
|
||||
|
||||
const char *plugin, *casroot, *standard;
|
||||
plugin = getenv("CSF_PluginDefaults");
|
||||
standard = getenv("CSF_StandardDefaults");
|
||||
casroot = getenv("CASROOT");
|
||||
Standard_Boolean hasPlugin = Standard_False;
|
||||
TCollection_AsciiString PluginName ;
|
||||
if ( !plugin ) {
|
||||
if ( casroot ) {
|
||||
PluginName = TCollection_AsciiString (casroot);
|
||||
PluginName+="/src/StdResource" ;
|
||||
hasPlugin = Standard_True ;
|
||||
}
|
||||
} else {
|
||||
PluginName = TCollection_AsciiString (plugin);
|
||||
hasPlugin = Standard_True ;
|
||||
}
|
||||
if ( hasPlugin ) {
|
||||
OSD_Path aPath ( PluginName );
|
||||
OSD_Directory aDir(aPath);
|
||||
if ( aDir.Exists () ) {
|
||||
TCollection_AsciiString PluginFileName = PluginName + "/Plugin" ;
|
||||
OSD_File PluginFile ( PluginFileName );
|
||||
if ( PluginFile.Exists() ) {
|
||||
if (!plugin) {
|
||||
OSD_Environment PluginEnv ( "CSF_PluginDefaults" , PluginName );
|
||||
PluginEnv.Build();
|
||||
if ( PluginEnv.Failed() ) {
|
||||
cout << " Problem when initialise CSF_PluginDefaults whith " << PluginName.ToCString() << endl;
|
||||
}
|
||||
}
|
||||
if (!standard) {
|
||||
OSD_Environment StandardEnv ( "CSF_StandardDefaults" , PluginName );
|
||||
StandardEnv .Build();
|
||||
if ( StandardEnv.Failed() ) {
|
||||
cout << " Problem when initialise CSF_StandardDefaults whith " << PluginName.ToCString() << endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hasPlugin = Standard_False;
|
||||
}
|
||||
} else {
|
||||
hasPlugin = Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !hasPlugin ) {
|
||||
cout << " an environement variable named : CSF_PluginDefaults is mandatory to use OCAF " <<endl;
|
||||
Standard_Failure::Raise ( "an environement variable named : CSF_PluginDefaults is mandatory to use OCAF" );
|
||||
}
|
||||
|
||||
return hasPlugin ;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// DPrsStd::Factory
|
||||
//==============================================================================
|
||||
void DPrsStd::Factory(Draw_Interpretor& theDI)
|
||||
{
|
||||
if(!FoundCAFPlugin())
|
||||
return;
|
||||
|
||||
static Standard_Boolean DPrsStdFactoryDone = Standard_False;
|
||||
if (DPrsStdFactoryDone) return;
|
||||
DPrsStdFactoryDone = Standard_True;
|
||||
|
Reference in New Issue
Block a user