gwnavruntime/world/floatstat.h Source File

floatstat.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 #pragma once
9 
12 
13 
14 namespace Kaim
15 {
16 
19 class FloatStat
20 {
21  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Statistics)
22 
23 public:
24  FloatStat() { ResetValues(); }
25  FloatStat(const String& name, KyUInt32 windowSize = 300) { Init(name, windowSize); }
26 
27  void Init(const String& name, KyUInt32 windowSize = 300)
28  {
29  m_name = name;
30  SetWindowSize(windowSize);
31  }
32 
33  void SetWindowSize(KyUInt32 windowSize)
34  {
35  m_values.Resize(windowSize);
36  ResetValues();
37  }
38 
39  void ResetValues();
40  void Update();
41 
42  const String& GetName() const { return m_name; }
43  KyFloat32 GetCurrent() const { return m_current; }
44  KyFloat32 GetAverage() const { return m_average; }
45  KyFloat32 GetMin() const { return m_min; }
46  KyFloat32 GetMax() const { return m_max; }
47 
48  KyFloat32& GetWritableCurrent() { return m_current; }
49 
50  void SetCurrent(KyFloat32 current) { m_current = current; }
51 
52 private:
53  void AddValue();
54  void ReplaceValue();
55  void UpdateMin(KyUInt32 index);
56  void UpdateMax(KyUInt32 index);
57 
58 public:
59  String m_name;
60  KyFloat32 m_current;
61  KyFloat32 m_average;
62  KyFloat32 m_min;
63  KyFloat32 m_max;
64 
65 private:
66  Array<KyFloat32> m_values; // values in the window
67  KyUInt32 m_currentIndex;
68  KyUInt32 m_minIndex;
69  KyUInt32 m_maxIndex;
70  bool m_cycled;
71 };
72 
73 } // namespace Kaim
74 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
FloatStat maintains current, average, min, max statistics in a sliding window of frames.
Definition: floatstat.h:19
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
float KyFloat32
float
Definition: types.h:32