gwnavruntime/navmesh/traverselogicobsoletechecker.h Source File

traverselogicobsoletechecker.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 // ---------- Primary contact: BRGR - secondary contact: JUBA
9 #ifndef Navigation_TraverseLogicObsoleteChecker_H
10 #define Navigation_TraverseLogicObsoleteChecker_H
11 
13 
14 namespace Kaim
15 {
16 
17 class Vec3f;
18 class NavTag;
19 class NavTriangleRawPtr;
20 class NavGraphEdgeRawPtr;
21 
22 class LogicWithoutCostMultipler;
23 class LogicWithCostMultiplerPerNavTag;
24 class LogicWithCostMultiplerPerTriangle;
25 
26 
32 class TraverseLogicObsoleteChecker
33 {
36 
37 public:
38  template<class TLogic>
39  static KY_INLINE bool HasNoObsoleteFunctions() { return Check<TLogic>(typename TLogic::CostMultiplierUsage()); }
40 
41 private:
42  // ----- SimpleTraverseLogic interface check ----
43 
44  class SimpleTraverseLogicObsoleteFuncPtr
45  {
46  public:
47  bool CompareAndLog(const SimpleTraverseLogicObsoleteFuncPtr& other);
48 
49  public:
50  bool (*m_ptrCanTraverse)(void*, const NavTag&);
51  KyFloat32 (*m_ptrGetCostMultiplier)(void*, const NavTag&);
52  bool (*m_ptrCanTraverseGraphEdgeAndGetCost)(void*, const Vec3f&, const Vec3f&, const NavTag&, KyFloat32&);
53  };
54 
55  // Init is not a member of SimpleTraverseLogicObsoleteFuncPtr to satisfy friend declaration in KY_TRAVERSE_LOGIC
56  // Some compilers doesn't consider a nested class of a friend class as a friend class
57  template<class TLogic>
58  static void Init(SimpleTraverseLogicObsoleteFuncPtr& funcPtr)
59  {
60  funcPtr.m_ptrCanTraverse = &TLogic::CanTraverse;
61  funcPtr.m_ptrGetCostMultiplier = &TLogic::GetCostMultiplier;
62  funcPtr.m_ptrCanTraverseGraphEdgeAndGetCost = &TLogic::CanTraverseGraphEdgeAndGetCost;
63  }
64 
65  template<class TLogic>
66  static bool Check(const LogicWithoutCostMultipler&)
67  {
68  SimpleTraverseLogicObsoleteFuncPtr base;
69  Init<typename TLogic::BaseClass>(base);
70 
71  SimpleTraverseLogicObsoleteFuncPtr derived;
72  Init<TLogic>(derived);
73 
74  return base.CompareAndLog(derived);
75  }
76 
77 
78  // ----- TraverseLogicWithCostMultiplerPerNavTag interface check ----
79 
80  template<class TLogic>
81  static bool Check(const LogicWithCostMultiplerPerNavTag&) { return true; }
82 
83  // ----- TraverseLogicWithCostPerTriangle interface check ----
84 
85  template<class TLogic>
86  static bool Check(const LogicWithCostMultiplerPerTriangle&) { return true; }
87 };
88 
89 
90 
91 }
92 
93 #endif
94 
This class is used in order to check that an inherited TraverseLogic is not implementing an obsolete ...
Definition: traverselogicobsoletechecker.h:34
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
Definition: gamekitcrowddispersion.h:20
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23