0026360: Useless global functions IsSimilar() in Standard
[occt.git] / src / Standard / Standard_Transient.cxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <Standard_Type.hxx>
16 #include <Standard_Transient.hxx>
17 #include <Standard_Atomic.hxx>
18 #include <Standard_CString.hxx>
19 #include <Standard_ProgramError.hxx>
20
21 void Standard_Transient::Delete() const
22
23   delete this;
24 }
25
26 //
27 //
28 const Handle(Standard_Type)& Standard_Transient::DynamicType() const
29 {
30   return opencascade::type_instance<Standard_Transient>::get();
31 }
32
33 //
34 //
35 Standard_Boolean Standard_Transient::IsInstance(const Handle(Standard_Type) &AType) const
36 {
37   return (Standard_Boolean) (AType ==  DynamicType());
38 }
39
40 //
41 //
42 Standard_Boolean Standard_Transient::IsInstance(const Standard_CString theTypeName) const
43 {
44   return IsEqual ( DynamicType()->Name(), theTypeName );
45 }
46
47 //
48 //
49 Standard_Boolean Standard_Transient::IsKind (const Handle(Standard_Type)& aType) const
50 {
51   return DynamicType()->SubType ( aType );
52 }
53
54 //
55 //
56 Standard_Boolean Standard_Transient::IsKind (const Standard_CString theTypeName) const
57 {
58   return DynamicType()->SubType ( theTypeName );
59 }
60
61 //
62 //
63 Standard_Transient* Standard_Transient::This() const
64 {
65   if (GetRefCount() == 0)
66     Standard_ProgramError::Raise ("Attempt to create handle to object created in stack, not yet constructed, or destroyed");
67   return const_cast<Standard_Transient*> (this);
68 }
69
70 // Increment reference counter
71 void Standard_Transient::IncrementRefCounter() const
72 {
73   Standard_Atomic_Increment (&count);
74 }
75
76 // Decrement reference counter
77 Standard_Integer Standard_Transient::DecrementRefCounter() const
78 {
79   return Standard_Atomic_Decrement (&count);
80 }