gwnavruntime/navgraph/identifiers/navgraphptr.h Source File

navgraphptr.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
10 
14 
15 
16 namespace Kaim
17 {
18 
22 {
23  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
24 public:
27  NavGraphPtr(NavGraph* navGraph = nullptr);
28 
31  bool IsValid() const;
32 
33  void Invalidate();
34 
37  NavGraph* GetNavGraph() const;
38 
42 
45  const NavGraphBlob* GetNavGraphBlob() const;
46 
49  const NavGraphBlob* GetNavGraphBlob_UnSafe() const;
50 
51  bool operator ==(const NavGraphPtr& rhs) const;
52  bool operator !=(const NavGraphPtr& rhs) const;
53  bool operator < (const NavGraphPtr& rhs) const;
54  bool operator <=(const NavGraphPtr& rhs) const;
55 private:
56  mutable Ptr<NavGraph> m_navGraphPtr;
57 };
58 
59 KY_INLINE NavGraphPtr::NavGraphPtr(NavGraph* navGraph) : m_navGraphPtr(navGraph) {}
60 KY_INLINE void NavGraphPtr::Invalidate() { m_navGraphPtr = nullptr; }
61 KY_INLINE bool NavGraphPtr::IsValid() const
62 {
63  if(m_navGraphPtr != nullptr)
64  {
65  if(m_navGraphPtr->IsStillLoaded())
66  return m_navGraphPtr->IsActive();
67 
68  m_navGraphPtr = nullptr;
69  }
70 
71  return false;
72 }
73 
74 KY_INLINE NavGraph* NavGraphPtr::GetNavGraph() const { return IsValid() ? GetNavGraph_UnSafe() : nullptr; }
75 KY_INLINE NavGraph* NavGraphPtr::GetNavGraph_UnSafe() const { return m_navGraphPtr; }
76 
77 KY_INLINE const NavGraphBlob* NavGraphPtr::GetNavGraphBlob() const { return IsValid() ? GetNavGraphBlob_UnSafe() : nullptr; }
78 KY_INLINE const NavGraphBlob* NavGraphPtr::GetNavGraphBlob_UnSafe() const { return GetNavGraph_UnSafe()->GetNavGraphBlob(); }
79 
80 KY_INLINE bool NavGraphPtr::operator ==(const NavGraphPtr& rhs) const { return m_navGraphPtr == rhs.m_navGraphPtr; }
81 KY_INLINE bool NavGraphPtr::operator !=(const NavGraphPtr& rhs) const { return !(*this == rhs); }
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 !(rhs < *this); }
84 
85 } // namespace Kaim
86 
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:80
bool IsValid() const
Returns true if this object refers to a valid runtime NavGraph, which means a NavFloor that exists...
Definition: navgraphptr.h:61
The NavGraphBlob contains the static data of a NavGraph.
Definition: navgraphblob.h:19
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
const NavGraphBlob * GetNavGraphBlob() const
Returns a pointer to the NavGraphBlob identified by this object.
Definition: navgraphptr.h:77
const NavGraphBlob * GetNavGraphBlob_UnSafe() const
Returns a pointer to the NavGraphBlob identified by this object.
Definition: navgraphptr.h:78
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
This class uniquely identifies a single NavGraph.
Definition: navgraphptr.h:21
NavGraphPtr(NavGraph *navGraph=nullptr)
Constructs a new NavGraphPtr.
Definition: navgraphptr.h:59
bool operator!=(const NavGraphPtr &rhs) const
Returns true if this object identifies an NavGraph different from the one identified by rhs...
Definition: navgraphptr.h:81
NavGraph * GetNavGraph_UnSafe() const
Returns a pointer to the NavGraph that handles the graph identified by this object.
Definition: navgraphptr.h:75
void Invalidate()
Invalidates this object.
Definition: navgraphptr.h:60
NavGraph * GetNavGraph() const
Returns a pointer to the NavGraph that handles the graph identified by this object.
Definition: navgraphptr.h:74
This class is a runtime wrapper of a NavGraphBlob, it gathers all the runtime information associated ...
Definition: navgraph.h:22