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 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.
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 #include <Standard_DefineAlloc.hxx>
24 #include <Standard_TypeDef.hxx>
25 #include <Standard_Persistent_proto.hxx>
28 // Disable the warning "conversion from 'unsigned int' to Standard_Persistent *"
29 #pragma warning (push)
30 #pragma warning (disable:4312)
33 class Standard_Persistent;
34 class Handle_Standard_Type;
35 class Handle_Standard_Persistent;
37 Standard_EXPORT Standard_Integer HashCode(const Handle(Standard_Persistent)& ,
38 const Standard_Integer);
40 class Handle(Standard_Persistent)
44 Standard_Persistent *entity;
46 Standard_EXPORT void RaiseNullObject(const Standard_CString S) const;
48 void BeginScope() const
50 if (entity != 0) entity->count++;
58 if (entity->count == 0) {
70 Handle(Standard_Persistent)()
75 Handle(Standard_Persistent)(const Handle(Standard_Persistent)& aTid)
81 Handle(Standard_Persistent)(const Standard_Persistent *anItem)
86 entity = (Standard_Persistent *)anItem;
91 Standard_EXPORT void Dump(Standard_OStream& out) const;
93 Standard_EXPORT ~Handle(Standard_Persistent)();
95 bool operator==(const Handle(Standard_Persistent)& right) const
97 return entity == right.entity;
100 bool operator==(const Standard_Persistent *right) const
102 return entity == right;
105 friend bool operator==(const Standard_Persistent *left, const Handle(Standard_Persistent)& right)
107 return left == right.entity;
110 bool operator!=(const Handle(Standard_Persistent)& right) const
112 return entity != right.entity;
115 bool operator!=(const Standard_Persistent *right) const
117 return entity != right;
120 friend bool operator!=(const Standard_Persistent *left, const Handle(Standard_Persistent)& right)
122 return left != right.entity;
131 Standard_Boolean IsNull() const
136 Standard_Persistent* Access() const
143 Standard_Persistent* ControlAccess() const
148 void Assign(const Standard_Persistent *anItem)
154 entity = (Standard_Persistent *)anItem;
162 operator Standard_Persistent*()
168 Standard_EXPORT Handle(Standard_Persistent)& operator=(const Handle(Standard_Persistent)& aHandle);
169 Standard_EXPORT Handle(Standard_Persistent)& operator=(const Standard_Persistent* anItem);
171 Standard_Persistent* operator->()
173 return ControlAccess();
176 Standard_Persistent* operator->() const
178 return ControlAccess();
181 Standard_Persistent& operator*()
183 return *(ControlAccess());
186 const Standard_Persistent& operator*() const
188 return *(ControlAccess());
191 Standard_EXPORT static const Handle(Standard_Persistent) DownCast(const Handle(Standard_Persistent)& AnObject);
197 #pragma warning (pop)