gwnavruntime/world/visualdebugregistry.h Source File

visualdebugregistry.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 // Authors: GUAL
8 #ifndef Navigation_VisualDebugRegistry_H
9 #define Navigation_VisualDebugRegistry_H
10 
11 
15 
16 
17 namespace Kaim
18 {
19 
20 class World;
21 class WorldElement;
22 class VisualDebugServer;
23 
24 typedef Hash<KyUInt32, WorldElement*, FixedSizeHash<KyUInt32>, AllocatorGH<KyUInt32, MemStat_VisualDebugRegistry> > WorldElementHash;
25 
26 // This class is used as a component of Kaim::World
27 // If KY_BUILD_SHIPPING is enabled, this class is not functional, and Kaim::World does not instanciate it.
28 class VisualDebugRegistry
29 {
30  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_VisualDebugRegistry)
31  KY_CLASS_WITHOUT_COPY(VisualDebugRegistry)
32 
33 public:
34  VisualDebugRegistry(World* world) : m_world(world), m_nextVisualDebugId(0) {}
35 
36  ~VisualDebugRegistry();
37 
38  void Register(WorldElement* worldElement);
39 
40  void UnRegister(WorldElement* worldElement);
41 
42  KyUInt32 GetNewVisualDebugId();
43 
44  WorldElement* Get(KyUInt32 visualDebugId);
45 
46  WorldElement* GetAs(KyUInt32 visualDebugId, WorldElementType worldElementType);
47 
48  template<class T>
49  T* GetAs(KyUInt32 visualDebugId);
50 
51  //const WorldElementHash& GetElements() const { return m_hash; }
52 
53  // Called every frame, this is where we send visual debug data associated to WorldElements
54  void SendVisualDebug(VisualDebugServer& visualDebugServer);
55 
56  void OnConnection();
57 
58 private:
59  World* m_world; // allows to browse directly the WorldElement collections in SendVisualDebug() instead of browsing m_hash
60  KyUInt32 m_nextVisualDebugId;
61  WorldElementHash m_hash; // visualDebugId => WorldElement
62 };
63 
64 
65 #ifndef KY_BUILD_SHIPPING
66 
67 template<class T>
68 KY_INLINE T* VisualDebugRegistry::GetAs(KyUInt32 visualDebugId) { return (T*)GetAs(visualDebugId, T::GetStaticType()); }
69 
70 #else // VisualDebug disabled in shipping
71 
72 KY_INLINE VisualDebugRegistry::~VisualDebugRegistry() {}
73 KY_INLINE void VisualDebugRegistry::Register(WorldElement*) {}
74 KY_INLINE void VisualDebugRegistry::UnRegister(WorldElement*) {}
75 KY_INLINE KyUInt32 VisualDebugRegistry::GetNewVisualDebugId() { return KyUInt32MAXVAL; }
76 KY_INLINE WorldElement* VisualDebugRegistry::Get(KyUInt32) { return KY_NULL; }
77 KY_INLINE WorldElement* VisualDebugRegistry::GetAs(KyUInt32, WorldElementType) { return KY_NULL; }
78 template<class T>
79 KY_INLINE T* VisualDebugRegistry::GetAs(KyUInt32) { return KY_NULL; }
80 KY_INLINE void VisualDebugRegistry::SendVisualDebug(VisualDebugServer&) {}
81 KY_INLINE void VisualDebugRegistry::OnConnection() {}
82 
83 #endif
84 
85 }
86 
87 #endif
#define KY_NULL
Null value.
Definition: types.h:247
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
WorldElementType
Enumerates the WorldElement types.
Definition: worldelementtype.h:15
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226