b311480e |
1 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
69ff08ff |
15 | #include <Standard_Type.hxx> |
e7195ab4 |
16 | #include <Standard_Transient.hxx> |
17 | #include <Standard_Atomic.hxx> |
18 | #include <Standard_CString.hxx> |
19 | #include <Standard_ProgramError.hxx> |
7fd59977 |
20 | |
e7195ab4 |
21 | void Standard_Transient::Delete() const |
22 | { |
23 | delete this; |
69ff08ff |
24 | } |
25 | |
f5f4ebd0 |
26 | const Handle(Standard_Type)& Standard_Transient::get_type_descriptor () |
27 | { |
28 | return opencascade::type_instance<Standard_Transient>::get(); |
29 | } |
30 | |
7fd59977 |
31 | // |
7fd59977 |
32 | // |
e7195ab4 |
33 | const Handle(Standard_Type)& Standard_Transient::DynamicType() const |
7fd59977 |
34 | { |
f5f4ebd0 |
35 | return get_type_descriptor(); |
7fd59977 |
36 | } |
37 | |
38 | // |
39 | // |
40 | Standard_Boolean Standard_Transient::IsInstance(const Handle(Standard_Type) &AType) const |
41 | { |
dde68833 |
42 | return (AType == DynamicType()); |
7fd59977 |
43 | } |
44 | |
45 | // |
46 | // |
47 | Standard_Boolean Standard_Transient::IsInstance(const Standard_CString theTypeName) const |
48 | { |
42a9dcfc |
49 | return IsEqual ( DynamicType()->Name(), theTypeName ); |
7fd59977 |
50 | } |
51 | |
52 | // |
53 | // |
54 | Standard_Boolean Standard_Transient::IsKind (const Handle(Standard_Type)& aType) const |
55 | { |
56 | return DynamicType()->SubType ( aType ); |
57 | } |
58 | |
59 | // |
60 | // |
61 | Standard_Boolean Standard_Transient::IsKind (const Standard_CString theTypeName) const |
62 | { |
63 | return DynamicType()->SubType ( theTypeName ); |
64 | } |
65 | |
e7195ab4 |
66 | // |
67 | // |
68 | Standard_Transient* Standard_Transient::This() const |
69 | { |
70 | if (GetRefCount() == 0) |
9775fa61 |
71 | throw Standard_ProgramError("Attempt to create handle to object created in stack, not yet constructed, or destroyed"); |
e7195ab4 |
72 | return const_cast<Standard_Transient*> (this); |
73 | } |
74 | |
75 | // Increment reference counter |
76 | void Standard_Transient::IncrementRefCounter() const |
77 | { |
78 | Standard_Atomic_Increment (&count); |
79 | } |
80 | |
81 | // Decrement reference counter |
82 | Standard_Integer Standard_Transient::DecrementRefCounter() const |
83 | { |
84 | return Standard_Atomic_Decrement (&count); |
7fd59977 |
85 | } |