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.
class DocumentRetrievalDriver;
Factory (theGUID : GUID from Standard) returns Transient from Standard;
+ ---C++: return const &
AttributeDrivers (MsgDrv : MessageDriver from CDM)
returns ADriverTable from BinMDF;
//function : Factory
//purpose : PLUGIN FACTORY
//=======================================================================
-Handle(Standard_Transient) BinDrivers::Factory(const Standard_GUID& theGUID)
+const Handle(Standard_Transient)& BinDrivers::Factory(const Standard_GUID& theGUID)
{
if (theGUID == BinStorageDriver)
{
}
Standard_Failure::Raise ("BinDrivers : unknown GUID");
- return NULL;
+ static Handle(Standard_Transient) aNullHandle;
+ return aNullHandle;
}
//=======================================================================
return BinLDrivers::StorageVersion();
}
-#ifdef _MSC_VER
-#pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
-#endif
PLUGIN(BinDrivers)
imported VectorOfDocumentSection;
Factory (theGUID : GUID from Standard) returns Transient from Standard;
+ ---C++: return const &
AttributeDrivers (MsgDrv : MessageDriver from CDM)
returns ADriverTable from BinMDF;
//function : Factory
//purpose : PLUGIN FACTORY
//=======================================================================
-Handle(Standard_Transient) BinLDrivers::Factory(const Standard_GUID& theGUID)
+const Handle(Standard_Transient)& BinLDrivers::Factory(const Standard_GUID& theGUID)
{
if (theGUID == BinLStorageDriver)
{
}
Standard_Failure::Raise ("BinLDrivers : unknown GUID");
- return NULL;
+ static Handle(Standard_Transient) aNullHandle;
+ return aNullHandle;
}
//=======================================================================
return aVersionStr;
}
-#ifdef _MSC_VER
-#pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
-#endif
PLUGIN(BinLDrivers)
static Standard_GUID BinStorageDriver ("f78ff4a2-a779-11d5-aab4-0050044b1af1");
static Standard_GUID BinRetrievalDriver("f78ff4a3-a779-11d5-aab4-0050044b1af1");
-Handle(Standard_Transient) BinTObjDrivers::Factory(const Standard_GUID& aGUID)
+const Handle(Standard_Transient)& BinTObjDrivers::Factory(const Standard_GUID& aGUID)
{
if(aGUID == BinStorageDriver)
{
aDriverTable -> AddDriver (new BinTObjDrivers_IntSparseArrayDriver (aMsgDrv));
}
-#ifdef _MSC_VER
-#pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
-#endif
PLUGIN(BinTObjDrivers)
public:
// ---------- PUBLIC METHODS ----------
- Standard_EXPORT static Handle(Standard_Transient) Factory
+ Standard_EXPORT static const Handle(Standard_Transient)& Factory
(const Standard_GUID& aGUID);
// Returns a driver corresponding to <aGUID>. Used for plugin.
class DocumentRetrievalDriver;
Factory (theGUID : GUID from Standard) returns Transient from Standard;
+ ---C++: return const &
AttributeDrivers (MsgDrv : MessageDriver from CDM)
returns ADriverTable from BinMDF;
//function :
//purpose :
//=======================================================================
-Handle(Standard_Transient) BinXCAFDrivers::Factory(const Standard_GUID& theGUID) {
+const Handle(Standard_Transient)& BinXCAFDrivers::Factory(const Standard_GUID& theGUID) {
if (theGUID == BinXCAFStorageDriver)
{
Standard_Failure::Raise ("XCAFBinDrivers : unknown GUID");
- return NULL;
+ static Handle(Standard_Transient) aNullHandle;
+ return aNullHandle;
}
//=======================================================================
return aTable;
}
-#ifdef _MSC_VER
-#pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
-#endif
PLUGIN(BinXCAFDrivers)
Factory(aGUID: GUID from Standard)
returns Transient from Standard;
---Purpose: returns a DriverFactory.
+ ---C++: return const&
+
end FWOSDriver;
#include <Plugin_Macro.hxx>
-#ifdef _MSC_VER
-#pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
-#endif
-
PLUGIN(FWOSDriver)
-Handle(Standard_Transient) FWOSDriver::Factory(const Standard_GUID& /*aGUID*/) {
+const Handle(Standard_Transient)& FWOSDriver::Factory(const Standard_GUID& /*aGUID*/) {
static Handle(FWOSDriver_DriverFactory) f;
if(f.IsNull()) f = new FWOSDriver_DriverFactory;
return f;
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;
#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
class DocumentRetrievalDriver;
Factory (theGUID : GUID from Standard) returns Transient from Standard;
+ ---C++: return const &
AttributeDrivers (theMsgDriver: MessageDriver from CDM)
returns ADriverTable from XmlMDF;
//function : Factory
//purpose : PLUGIN FACTORY
//=======================================================================
-Handle(Standard_Transient) XmlDrivers::Factory(const Standard_GUID& theGUID)
+const Handle(Standard_Transient)& XmlDrivers::Factory(const Standard_GUID& theGUID)
{
if (theGUID == XmlStorageDriver)
{
}
Standard_Failure::Raise ("XmlDrivers : unknown GUID");
- return NULL;
+ static Handle(Standard_Transient) aNullHandle;
+ return aNullHandle;
}
//=======================================================================
return aTable;
}
-#ifdef _MSC_VER
-#pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
-#endif
-
// Declare entry point PLUGINFACTORY
PLUGIN(XmlDrivers)
imported SequenceOfNamespaceDef;
Factory (theGUID : GUID from Standard) returns Transient from Standard;
+ ---C++: return const &
CreationDate returns AsciiString from TCollection;
//function : Factory
//purpose : PLUGIN FACTORY
//=======================================================================
-Handle(Standard_Transient) XmlLDrivers::Factory(const Standard_GUID& theGUID)
+const Handle(Standard_Transient)& XmlLDrivers::Factory(const Standard_GUID& theGUID)
{
if (theGUID == XmlLStorageDriver)
{
}
Standard_Failure::Raise ("XmlLDrivers : unknown GUID");
- return NULL;
+ static Handle(Standard_Transient) aNullHandle;
+ return aNullHandle;
}
#define SLENGTH 80
return aVersionStr;
}
-#ifdef _MSC_VER
-#pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
-#endif
-
// Declare entry point PLUGINFACTORY
PLUGIN(XmlLDrivers)
static Standard_GUID XmlStorageDriver ("f78ff4a0-a779-11d5-aab4-0050044b1af1");
static Standard_GUID XmlRetrievalDriver("f78ff4a1-a779-11d5-aab4-0050044b1af1");
-Handle(Standard_Transient) XmlTObjDrivers::Factory(const Standard_GUID& aGUID)
+const Handle(Standard_Transient)& XmlTObjDrivers::Factory(const Standard_GUID& aGUID)
{
if(aGUID == XmlStorageDriver)
{
aDriverTable -> AddDriver (new XmlTObjDrivers_IntSparseArrayDriver(anMsgDrv));
}
-#ifdef _MSC_VER
-#pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
-#endif
-
PLUGIN(XmlTObjDrivers)
public:
// ---------- PUBLIC METHODS ----------
- Standard_EXPORT static Handle(Standard_Transient) Factory
+ Standard_EXPORT static const Handle(Standard_Transient)& Factory
(const Standard_GUID& aGUID);
// Returns a driver corresponding to <aGUID>. Used for plugin.
Factory (aGUID: GUID from Standard)
returns Transient from Standard;
+ ---C++: return const &
---Purpose: Depending from the ID, returns a list of storage
-- or retrieval attribute drivers. Used for plugin.
--
static Standard_GUID XSStorageDriver ("f78ff496-a779-11d5-aab4-0050044b1af1");
static Standard_GUID XSRetrievalDriver("f78ff497-a779-11d5-aab4-0050044b1af1");
-Handle(Standard_Transient) XmlXCAFDrivers::Factory(const Standard_GUID& aGUID)
+const Handle(Standard_Transient)& XmlXCAFDrivers::Factory(const Standard_GUID& aGUID)
{
if(aGUID == XSStorageDriver)
{
return XmlDrivers::Factory (aGUID);
}
-#ifdef _MSC_VER
-#pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
-#endif
PLUGIN(XmlXCAFDrivers)