mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
0027566: Configuration - define Handle_ as non-template class for compatibility with C++/CLI
For MSVC compiler (version 12 and above), Handle_Class types are defined as true classes (inheriting corresponding opencascade::handle<Class>) to allow using them in "public" statement of C++/CLI language, to make these classes recognizable by other C++/CLI libraries. Code to test operations with Handle_ class is added to QAHandleOps test command
This commit is contained in:
@@ -409,8 +409,25 @@ inline Standard_Integer HashCode (const Handle(T)& theHandle, const Standard_Int
|
||||
return ::HashCode (const_cast<Standard_Address>(static_cast<const void*>(theHandle.get())), theUpper);
|
||||
}
|
||||
|
||||
//! For compatibility with previous versions of OCCT, defines typedef opencascade::handle<Class> Handle(Class)
|
||||
//! For compatibility with previous versions of OCCT, define Handle_Class alias for opencascade::handle<Class>.
|
||||
#if (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||
//! For Visual Studio 2013+, define Handle_Class as non-template class to allow exporting this type in C++/CLI.
|
||||
#define DEFINE_STANDARD_HANDLECLASS(C1,C2,BC) class C1; class Handle_##C1 : public Handle(C1) \
|
||||
{ \
|
||||
public: \
|
||||
Handle_##C1() {} \
|
||||
Handle_##C1(Handle(C1)&& theHandle) : Handle(C1)(theHandle) {} \
|
||||
template <class T2, typename = typename std::enable_if <std::is_base_of <C1,T2>::value>::type> \
|
||||
inline Handle_##C1(const opencascade::handle<T2>& theOther) : Handle(C1)(theOther) {} \
|
||||
template <class T2, typename = typename std::enable_if <std::is_base_of <C1,T2>::value>::type> \
|
||||
inline Handle_##C1(const T2* theOther) : Handle(C1)(theOther) {} \
|
||||
template<typename T> inline Handle_##C1& operator=(T theOther) { Handle(C1)::operator=(theOther); return *this; } \
|
||||
};
|
||||
#else
|
||||
//! For other compilers, use simple typedef
|
||||
#define DEFINE_STANDARD_HANDLECLASS(C1,C2,BC) class C1; typedef Handle(C1) Handle_##C1;
|
||||
#endif
|
||||
|
||||
#define DEFINE_STANDARD_HANDLE(C1,C2) DEFINE_STANDARD_HANDLECLASS(C1,C2,Standard_Transient)
|
||||
#define DEFINE_STANDARD_PHANDLE(C1,C2) DEFINE_STANDARD_HANDLECLASS(C1,C2,Standard_Persistent)
|
||||
|
||||
|
Reference in New Issue
Block a user