gwnavruntime/navgraph/identifiers/navgraphptr.h Source File

navgraphptr.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 
9 // Primary contact: JODA - secondary contact: JUBA
10 #ifndef Navigation_NavGraphPtr_H
11 #define Navigation_NavGraphPtr_H
12 
16 
17 
18 namespace Kaim
19 {
20 
23 class NavGraphPtr
24 {
25  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
26 public:
29  NavGraphPtr(NavGraph* navGraph = KY_NULL);
30 
33  bool IsValid() const;
34 
35  void Invalidate();
36 
39  NavGraph* GetNavGraph() const;
40 
44 
47  const NavGraphBlob* GetNavGraphBlob() const;
48 
51  const NavGraphBlob* GetNavGraphBlob_UnSafe() const;
52 
53  bool operator ==(const NavGraphPtr& rhs) const;
54  bool operator !=(const NavGraphPtr& rhs) const;
55  bool operator < (const NavGraphPtr& rhs) const;
56  bool operator <=(const NavGraphPtr& rhs) const;
57 private :
58  mutable Ptr<NavGraph> m_navGraphPtr;
59 };
60 
61 KY_INLINE NavGraphPtr::NavGraphPtr(NavGraph* navGraph) : m_navGraphPtr(navGraph) {}
62 KY_INLINE void NavGraphPtr::Invalidate() { m_navGraphPtr = KY_NULL; }
63 KY_INLINE bool NavGraphPtr::IsValid() const
64 {
65  if(m_navGraphPtr != KY_NULL)
66  {
67  if(m_navGraphPtr->IsStillLoaded())
68  return m_navGraphPtr->IsActive();
69 
70  m_navGraphPtr = KY_NULL;
71  }
72 
73  return false;
74 }
75 
76 KY_INLINE NavGraph* NavGraphPtr::GetNavGraph() const { return IsValid() ? GetNavGraph_UnSafe() : KY_NULL; }
77 KY_INLINE NavGraph* NavGraphPtr::GetNavGraph_UnSafe() const { return m_navGraphPtr; }
78 
79 KY_INLINE const NavGraphBlob* NavGraphPtr::GetNavGraphBlob() const { return IsValid() ? GetNavGraphBlob_UnSafe() : KY_NULL; }
80 KY_INLINE const NavGraphBlob* NavGraphPtr::GetNavGraphBlob_UnSafe() const { return GetNavGraph_UnSafe()->GetNavGraphBlob(); }
81 
82 KY_INLINE bool NavGraphPtr::operator ==(const NavGraphPtr& rhs) const { return m_navGraphPtr == rhs.m_navGraphPtr; }
83 KY_INLINE bool NavGraphPtr::operator !=(const NavGraphPtr& rhs) const { return !(*this == rhs); }
84 KY_INLINE bool NavGraphPtr::operator < (const NavGraphPtr& rhs) const { return m_navGraphPtr < rhs.m_navGraphPtr; }
85 KY_INLINE bool NavGraphPtr::operator <=(const NavGraphPtr& rhs) const { return !(rhs < *this); }
86 
87 } // namespace Kaim
88 
89 #endif // #ifndef Navigation_NavGraphPtr_H
bool operator==(const NavGraphPtr &rhs) const
Returns true if this object identifies the same NavGraph as rhs, or if both are invalid.
Definition: navgraphptr.h:87
bool IsValid() const
Returns true if this object refers to a valid runtime NavGraph, which means a NavFloor that exists...
Definition: navgraphptr.h:68
The NavGraphBlob contains the static data of a NavGraph.
Definition: navgraphblob.h:21
#define KY_NULL
Null value.
Definition: types.h:247
const NavGraphBlob * GetNavGraphBlob() const
Returns a pointer to the NavGraphBlob identified by this object.
Definition: navgraphptr.h:84
const NavGraphBlob * GetNavGraphBlob_UnSafe() const
Returns a pointer to the NavGraphBlob identified by this object.
Definition: navgraphptr.h:85
Definition: gamekitcrowddispersion.h:20
This class uniquely identifies a single NavGraph.
Definition: navgraphptr.h:24
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
bool operator!=(const NavGraphPtr &rhs) const
Returns true if this object identifies an NavGraph different from the one identified by rhs...
Definition: navgraphptr.h:88
NavGraph * GetNavGraph_UnSafe() const
Returns a pointer to the NavGraph that handles the graph identified by this object.
Definition: navgraphptr.h:82
void Invalidate()
Invalidates this object.
Definition: navgraphptr.h:67
NavGraph * GetNavGraph() const
Returns a pointer to the NavGraph that handles the graph identified by this object.
Definition: navgraphptr.h:81
NavGraphPtr(NavGraph *navGraph=0)
Constructs a new NavGraphPtr.
Definition: navgraphptr.h:66
This class is a runtime wrapper of a NavGraphBlob, it gathers all the runtime information associated ...
Definition: navgraph.h:27