mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024925: Enabling OCAF persistence without setting environment variables
Add test case bugs/caf/bug24925 Merging with current master IR-2014-07-03
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
|
||||
package Plugin
|
||||
|
||||
uses TCollection,OSD
|
||||
uses TCollection,
|
||||
OSD,
|
||||
Resource
|
||||
|
||||
is
|
||||
|
||||
@@ -25,7 +27,23 @@ is
|
||||
class MapOfFunctions instantiates DataMap from TCollection(AsciiString from TCollection ,Function from OSD, AsciiString from TCollection);
|
||||
|
||||
|
||||
Load(aGUID: GUID from Standard) returns Transient from Standard
|
||||
Load(aGUID: GUID from Standard; theVerbose: Boolean from Standard = Standard_True)
|
||||
returns Transient from Standard
|
||||
raises Failure from Plugin;
|
||||
|
||||
AdditionalPluginMap
|
||||
returns Manager from Resource;
|
||||
---C++ : return const &
|
||||
---Purpose: 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");
|
||||
|
||||
end Plugin;
|
||||
|
@@ -30,7 +30,8 @@ static Standard_PCharacter thePluginId = tc;
|
||||
//function : Load
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Standard_Transient) Plugin::Load(const Standard_GUID& aGUID)
|
||||
Handle(Standard_Transient) Plugin::Load (const Standard_GUID& aGUID,
|
||||
const Standard_Boolean theVerbose)
|
||||
{
|
||||
|
||||
aGUID.ToCString(thePluginId);
|
||||
@@ -45,10 +46,14 @@ Handle(Standard_Transient) Plugin::Load(const Standard_GUID& aGUID)
|
||||
theResource += ".Location";
|
||||
|
||||
if(!PluginResource->Find(theResource.ToCString())) {
|
||||
Standard_SStream aMsg; aMsg << "could not find the resource:";
|
||||
aMsg << theResource.ToCString()<< endl;
|
||||
cout << "could not find the resource:"<<theResource.ToCString()<< endl;
|
||||
Plugin_Failure::Raise(aMsg);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
TCollection_AsciiString thePluginLibrary("");
|
||||
@@ -72,7 +77,8 @@ Handle(Standard_Transient) Plugin::Load(const Standard_GUID& aGUID)
|
||||
aMsg << PluginResource->Value(theResource.ToCString());
|
||||
aMsg << "; reason:";
|
||||
aMsg << error.ToCString();
|
||||
cout << "could not open: " << PluginResource->Value(theResource.ToCString())<< " ; reason: "<< error.ToCString() << endl;
|
||||
if (theVerbose)
|
||||
cout << "could not open: " << PluginResource->Value(theResource.ToCString())<< " ; reason: "<< error.ToCString() << endl;
|
||||
Plugin_Failure::Raise(aMsg);
|
||||
}
|
||||
f = theSharedLibrary.DlSymb("PLUGINFACTORY");
|
||||
@@ -95,3 +101,10 @@ Handle(Standard_Transient) Plugin::Load(const Standard_GUID& aGUID)
|
||||
|
||||
}
|
||||
|
||||
const Handle(Resource_Manager)& Plugin::AdditionalPluginMap()
|
||||
{
|
||||
static Handle(Resource_Manager) aMap;
|
||||
if (aMap.IsNull())
|
||||
aMap = new Resource_Manager ("" /*theName*/, Standard_False /*theVerbose*/);
|
||||
return aMap;
|
||||
}
|
||||
|
Reference in New Issue
Block a user