gwnavruntime/kernel/SF_StackRegistry.h Source File

SF_StackRegistry.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 #pragma once
8 
10 
11 #if defined (KY_ENABLE_STACK_REGISTRY)
12 
15 
16 namespace Kaim
17 {
18 
19 #define MAX_STACK_DEPTH 32
20 #define MAX_NAME_LENGTH 256
21 
22 class StackRef
23 {
24 public:
25  StackRef(void* stack, KyUInt32 frameCount, UPInt size) : m_frameCount(frameCount), m_size(size)
26  {
27  Alg::MemUtil::Copy(m_stack, stack, sizeof(void*) * frameCount);
28  }
29 
30  ~StackRef() { }
31 
32  KyUInt32 GetFrameCount() const { return m_frameCount; }
33  void* GetFrame(KyUInt32 frameIndex) const { return m_stack[frameIndex]; }
34  UPInt GetSize() const { return m_size; }
35 
36 private:
37  void* m_stack[MAX_STACK_DEPTH];
38  KyUInt32 m_frameCount;
39  UPInt m_size;
40 };
41 
42 class StackRegistryImpl;
43 
46 class StackRegistry
47 {
48  KY_CLASS_WITHOUT_COPY(StackRegistry)
49 public: // internal - you shouldn't need to access any of these functions by hand.
51  static void Initialize(bool initSymbolTable);
52  static void Clear();
53 
54  static void MapCurrentStackToUid(UPInt uid, UPInt size); // uid is typically a void*
55  static void UnMapStackFromUid(UPInt uid);
56 
57  static KyUInt32 GetCount();
58  static void Report(); // Outputs all the stack that have not been removed.
59 
60 private:
61  StackRegistry() : m_initialized(false), m_impl(KY_NULL) { }
62  ~StackRegistry() { m_impl = KY_NULL; }
63 
64  static StackRegistry& Instance() { static StackRegistry s_instance; return s_instance; }
65 
66  bool m_initialized;
67  StackRegistryImpl* m_impl;
68  Lock m_lock;
69 };
70 
71 }
72 
73 #endif // KY_ENABLE_STACK_REGISTRY
74 
#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
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36