mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024023: Revamp the OCCT Handle -- plugin
Definition of PLUGINFACTORY function changed to return Standard_Transient* instead of Handle(Standard_Transient), which cannot be returned by C-style function. Default implementation of PLUGINFACTORY() instantiated by macro PLUGIN() is corrected accordingly. Methods Factory() in persistence packages are made returning const & to handle; this is to reflect the fact that returned handle should point to existing object (usually statically allocated) rather than new one.
This commit is contained in:
@@ -94,8 +94,8 @@ Handle(Standard_Transient) Plugin::Load (const Standard_GUID& aGUID,
|
||||
else
|
||||
f = theMapOfFunctions(pid);
|
||||
|
||||
Handle(Standard_Transient) (*fp) (const Standard_GUID&) = NULL;
|
||||
fp = (Handle(Standard_Transient) (*)(const Standard_GUID&)) f;
|
||||
Standard_Transient* (*fp) (const Standard_GUID&) = NULL;
|
||||
fp = (Standard_Transient* (*)(const Standard_GUID&)) f;
|
||||
Handle(Standard_Transient) theServiceFactory = (*fp) (aGUID);
|
||||
return theServiceFactory;
|
||||
|
||||
|
@@ -17,11 +17,11 @@
|
||||
#ifndef _Plugin_Macro_HeaderFile
|
||||
#define _Plugin_Macro_HeaderFile
|
||||
|
||||
//! Macro implementing C-style interface function to get factory object from the dynamically loaded library
|
||||
#define PLUGIN(name) \
|
||||
extern "C" {Standard_EXPORT Handle(Standard_Transient) PLUGINFACTORY(const Standard_GUID&);} \
|
||||
Handle(Standard_Transient) PLUGINFACTORY(const Standard_GUID& aGUID) { \
|
||||
return name::Factory(aGUID);}\
|
||||
\
|
||||
extern "C" Standard_EXPORT Standard_Transient* PLUGINFACTORY(const Standard_GUID& aGUID) { \
|
||||
return const_cast<Standard_Transient*>(name::Factory(aGUID).get()); \
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user