gwnavruntime/world/floatstat.h Source File

floatstat.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: LAPA - secondary contact: NOBODY
9 
10 #ifndef Navigation_FloatStat_H
11 #define Navigation_FloatStat_H
12 
15 
16 
17 namespace Kaim
18 {
19 
22 class FloatStat
23 {
24  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Statistics)
25 
26 public:
27  FloatStat() { ResetValues(); }
28  FloatStat(const String& name, KyUInt32 windowSize = 300) { Init(name, windowSize); }
29 
30  void Init(const String& name, KyUInt32 windowSize = 300)
31  {
32  m_name = name;
33  SetWindowSize(windowSize);
34  }
35 
36  void SetWindowSize(KyUInt32 windowSize)
37  {
38  m_values.Resize(windowSize);
39  ResetValues();
40  }
41 
42  void ResetValues();
43  void Update();
44 
45  const String& GetName() const { return m_name; }
46  KyFloat32 GetCurrent() const { return m_current; }
47  KyFloat32 GetAverage() const { return m_average; }
48  KyFloat32 GetMin() const { return m_min; }
49  KyFloat32 GetMax() const { return m_max; }
50 
51  KyFloat32& GetWritableCurrent() { return m_current; }
52 
53  void SetCurrent(KyFloat32 current) { m_current = current; }
54 
55 private:
56  void AddValue();
57  void ReplaceValue();
58  void UpdateMin(KyUInt32 index);
59  void UpdateMax(KyUInt32 index);
60 
61 public:
62  String m_name;
63  KyFloat32 m_current;
64  KyFloat32 m_average;
65  KyFloat32 m_min;
66  KyFloat32 m_max;
67 
68 private:
69  Array<KyFloat32> m_values; // values in the window
70  KyUInt32 m_currentIndex;
71  KyUInt32 m_minIndex;
72  KyUInt32 m_maxIndex;
73  bool m_cycled;
74 };
75 
76 } // namespace Kaim
77 
78 #endif // Navigation_FloatStat_H
FloatStat maintains current, average, min, max statistics in a sliding window of frames.
Definition: floatstat.h:23
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
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43