1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and / or modify it
7 // under the terms of the GNU Lesser General Public 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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 //============================================================================
16 // Title : Handle_Standard_Persistent.hxx
17 // Role : This file just include <Standard_Persistent.hxx>
18 //============================================================================
20 #ifndef _Handle_Standard_Persistent_HeaderFile
21 #define _Handle_Standard_Persistent_HeaderFile
23 #ifndef _Standard_DefineAlloc_HeaderFile
24 #include <Standard_DefineAlloc.hxx>
26 #ifndef _Standard_Macro_HeaderFile
27 #include <Standard_Macro.hxx>
29 #ifndef _Standard_PrimitiveTypes_HeaderFile
30 #include <Standard_PrimitiveTypes.hxx>
32 #ifndef _Standard_Persistent_proto_HeaderFile
33 #include <Standard_Persistent_proto.hxx>
37 // Disable the warning "conversion from 'unsigned int' to Standard_Persistent *"
38 #pragma warning (push)
39 #pragma warning (disable:4312)
42 class Standard_Persistent;
43 class Handle_Standard_Type;
44 class Handle_Standard_Persistent;
46 Standard_EXPORT Standard_Integer HashCode(const Handle(Standard_Persistent)& ,
47 const Standard_Integer);
49 class Handle(Standard_Persistent)
53 Standard_Persistent *entity;
55 Standard_EXPORT void RaiseNullObject(const Standard_CString S) const;
57 void BeginScope() const
59 if (entity != 0) entity->count++;
67 if (entity->count == 0) {
79 Handle(Standard_Persistent)()
84 Handle(Standard_Persistent)(const Handle(Standard_Persistent)& aTid)
90 Handle(Standard_Persistent)(const Standard_Persistent *anItem)
95 entity = (Standard_Persistent *)anItem;
100 Standard_EXPORT void Dump(Standard_OStream& out) const;
102 Standard_EXPORT ~Handle(Standard_Persistent)();
104 Standard_EXPORT void ShallowDump(Standard_OStream&) const;
106 bool operator==(const Handle(Standard_Persistent)& right) const
108 return entity == right.entity;
111 bool operator==(const Standard_Persistent *right) const
113 return entity == right;
116 friend bool operator==(const Standard_Persistent *left, const Handle(Standard_Persistent)& right)
118 return left == right.entity;
121 bool operator!=(const Handle(Standard_Persistent)& right) const
123 return entity != right.entity;
126 bool operator!=(const Standard_Persistent *right) const
128 return entity != right;
131 friend bool operator!=(const Standard_Persistent *left, const Handle(Standard_Persistent)& right)
133 return left != right.entity;
142 Standard_Boolean IsNull() const
147 Standard_Persistent* Access() const
154 Standard_Persistent* ControlAccess() const
159 void Assign(const Standard_Persistent *anItem)
165 entity = (Standard_Persistent *)anItem;
173 operator Standard_Persistent*()
179 Standard_EXPORT Handle(Standard_Persistent)& operator=(const Handle(Standard_Persistent)& aHandle);
180 Standard_EXPORT Handle(Standard_Persistent)& operator=(const Standard_Persistent* anItem);
182 Standard_Persistent* operator->()
184 return ControlAccess();
187 Standard_Persistent* operator->() const
189 return ControlAccess();
192 Standard_Persistent& operator*()
194 return *(ControlAccess());
197 const Standard_Persistent& operator*() const
199 return *(ControlAccess());
202 Standard_EXPORT static const Handle(Standard_Persistent) DownCast(const Handle(Standard_Persistent)& AnObject);
208 #pragma warning (pop)