7fd59977 |
1 | #ifndef _Standard_Transient_proto_HeaderFile |
2 | #define _Standard_Transient_proto_HeaderFile |
3 | |
4 | #ifndef _Standard_Macro_HeaderFile |
5 | #include <Standard_Macro.hxx> |
6 | #endif |
7 | #ifndef _Standard_HeaderFile |
8 | #include <Standard.hxx> |
9 | #endif |
10 | |
11 | class Handle_Standard_Transient; |
12 | class Standard_Type; |
13 | class Handle_Standard_Type; |
14 | |
15 | //! Abstract class which forms the root of the entire |
16 | //! Transient class hierarchy. |
17 | |
18 | class Standard_Transient |
19 | { |
20 | //---- uses the friend Standard_Transient class |
21 | friend class Handle(Standard_Transient); |
22 | |
23 | public: |
24 | //! Operator new for placement in pre-allocated memory |
25 | void* operator new(size_t,void* anAddress) |
26 | { |
27 | return anAddress; |
28 | } |
29 | //! Operator new for memory allocation uses Open CASCADE memory manager |
30 | void* operator new(size_t size) |
31 | { |
32 | return Standard::Allocate(size); |
33 | } |
34 | //! Operator delete symmetric to operator new |
35 | void operator delete(void *anAddress) |
36 | { |
37 | if (anAddress) Standard::Free((Standard_Address&)anAddress); |
38 | } |
39 | |
40 | //! Empty constructor |
41 | Standard_Transient() : count(0) {} |
42 | |
43 | //! Copy constructor -- does nothing |
44 | Standard_Transient(const Standard_Transient&) : count(0) {} |
45 | |
46 | //! Assignment operator, needed to avoid copying reference counter |
47 | Standard_Transient& operator= (const Standard_Transient&) { return *this; } |
48 | |
49 | //! Destructor must be virtual |
50 | Standard_EXPORT virtual ~Standard_Transient(); |
51 | |
52 | //! Memory deallocator for transient classes |
53 | Standard_EXPORT virtual void Delete() const; |
54 | |
55 | //! Returns a hash code value for this object. |
56 | //! The value is in the range 1..Upper. |
57 | Standard_EXPORT virtual Standard_Integer HashCode(const Standard_Integer Upper) const; |
58 | |
59 | Standard_EXPORT virtual void ShallowDump(Standard_OStream& ) const; |
60 | |
61 | //! Returns a type information object about this object. |
62 | Standard_EXPORT virtual const Handle_Standard_Type& DynamicType() const; |
63 | |
64 | //! Returns a true value if this is an instance of Type. |
65 | Standard_EXPORT Standard_Boolean IsInstance(const Handle_Standard_Type& theType) const; |
66 | |
67 | //! Returns a true value if this is an instance of TypeName. |
68 | Standard_EXPORT Standard_Boolean IsInstance(const Standard_CString theTypeName) const; |
69 | |
70 | //! Returns true if this is an instance of Type or an |
71 | //! instance of any class that inherits from Type. |
72 | //! Note that multiple inheritance is not supported by OCCT RTTI mechanism. |
73 | Standard_EXPORT Standard_Boolean IsKind(const Handle_Standard_Type& theType) const; |
74 | |
75 | //! Returns true if this is an instance of TypeName or an |
76 | //! instance of any class that inherits from TypeName. |
77 | //! Note that multiple inheritance is not supported by OCCT RTTI mechanism. |
78 | Standard_EXPORT Standard_Boolean IsKind(const Standard_CString theTypeName) const; |
79 | |
80 | //! Returns a Handle which references this object. |
81 | //! Must never be called to objects created in stack. |
82 | Standard_EXPORT virtual Handle_Standard_Transient This() const; |
83 | |
84 | //! Get the reference counter of this object. |
85 | Standard_EXPORT Standard_Integer GetRefCount() const { return count; } |
86 | |
87 | private: |
88 | |
e33e7e78 |
89 | volatile Standard_Integer count; |
7fd59977 |
90 | }; |
91 | |
92 | Standard_EXPORT const Handle(Standard_Type)& STANDARD_TYPE(Standard_Transient); |
93 | |
94 | #endif |