1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0024947: Redesign OCCT legacy type system

Global static functions instantiating RTTI descriptors for class types (used though STANDARD_TYPE macro) are replaced by template static method Instance() of the class Standard_Type.
Implementation of RTTI is revised accordingly (global registry of type descriptors added to ensure single instance of each type descriptor shared by all dynamic libraries).
Obsolete methods of Standard_Type class (IsInstance(), Ancestors()) are removed; new method Parent() is added returning type descriptor of the parent class.
Class Standard_AncestorIterator is removed; this iteration can be easily done by recursive calls to Standard_Type::Parent().

Definition of macro STANDARD_TYPE() moved from Standard_Macro.hxx to Standard_DefineHandle.hxx.
Inclusion of Standard_Type.hxx and the class header is now necessary for use of method DownCast() and function STANDARD_TYPE() for the class.
In general, Standard_Type.hxx should be included now instead of Standard_DefineHandle.hxx in places where these macros are used.

Macro DEFINE_STANDARD_EXCEPTION changed to define all methods inline; macro IMPLEMENT_STANDARD_EXCEPTION becomes obsolete.
Macros IMPLEMENT_DOWNCAST, IMPLEMENT_STANDARD_* become deprecated, they are still defined (as empty) for compatibility.

Implementation of Handle classes became fully inline.
Method get() is added in Handle classes returning pointer to the contained object.

RTTI removed from NCollection_Handle class.

Standard_Persistent is made empty descendant of Standard_Transient, instead of implementing its own hierarchy with reference counting.

Unused enumerations Standard_InternalType, Standard_WayOfLife, Standard_KindOfType are removed.
Global function HashCode() accepting Handle(Standard_Transient) is removed; HashCode() for Standard_CString with length should be used instead.

DRAW command dtryload is added for testing dynamic load / unload of the specified library.
New test perf fclasses bug24947 uses this command to measure performance of multiple (1000 times) loading / unloading OCCT libs on example of TKSTEP.
This commit is contained in:
abv
2015-05-22 06:40:28 +03:00
parent 4052fe71d9
commit 69ff08ff28
38 changed files with 435 additions and 1226 deletions

View File

@@ -14,8 +14,7 @@
#ifndef _Standard_DefineException_HeaderFile
#define _Standard_DefineException_HeaderFile
#include <Standard_Macro.hxx>
#include <Standard_DefineHandle.hxx>
#include <Standard_Type.hxx>
//! Defines an exception class \a C1 that inherits an exception class \a C2.
/*! \a C2 must be Standard_Failure or its ancestor.
@@ -25,49 +24,28 @@
When using DEFINE_STANDARD_EXCEPTION in your code make sure you also insert a macro
DEFINE_STANDARD_HANDLE(C1,C2) before it.
\sa IMPLEMENT_STANDARD_EXCEPTION.
*/
#define DEFINE_STANDARD_EXCEPTION(C1,C2) \
\
class C1 : public C2 { \
Standard_EXPORT virtual void Throw() const; \
void Throw () const { throw *this; } \
public: \
C1() : C2() {} \
C1(const Standard_CString AString) : C2(AString) {} \
Standard_EXPORT static void Raise(const Standard_CString aMessage = ""); \
Standard_EXPORT static void Raise(Standard_SStream& aReason); \
Standard_EXPORT static Handle(C1) NewInstance(const Standard_CString aMessage = ""); \
\
DEFINE_STANDARD_RTTI(C1) \
C1(const Standard_CString theMessage) : C2(theMessage) {} \
static void Raise(const Standard_CString theMessage = "") { \
Handle(C1) _E = new C1; \
_E->Reraise(theMessage); \
} \
static void Raise(Standard_SStream& theMessage) { \
Handle(C1) _E = new C1; \
_E->Reraise (theMessage); \
} \
static Handle(C1) NewInstance(const Standard_CString theMessage = "") { return new C1(theMessage); } \
DEFINE_STANDARD_RTTI(C1,C2) \
};
//! Implements an exception class \a C1 declared with DEFINE_STANDARD_EXCEPTION macro.
/*! If you are using IMPLEMENT_STANDARD_EXCEPTION in your code make sure you also call
IMPLEMENT_STANDARD_HANDLE(C1,C2) and IMPLEMENT_STANDARD_RTTIEXT(C1,C2).
*/
#define IMPLEMENT_STANDARD_EXCEPTION(C1) \
\
void C1::Raise(Standard_SStream& aReason) \
{ \
Handle(C1) _E = new C1; \
_E->Reraise (aReason); \
} \
\
void C1::Raise(const Standard_CString AString) \
{ \
Handle(C1) _E = new C1; \
_E->Reraise(AString); \
} \
\
Handle(C1) C1::NewInstance(const Standard_CString aMessage) \
{ \
return new C1(aMessage); \
} \
void C1::Throw () const \
{ \
throw *this; \
}
//! Obsolete macro, kept for compatibility with old code
#define IMPLEMENT_STANDARD_EXCEPTION(C1)
#endif