CTR Pia  4.11.3
Game Communication Engine
common_StatisticValue.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: common_StatisticValue.h
4 
5  Copyright Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 
15 #pragma once
16 
17 #include <pia/common/common_definitions.h>
18 
19 namespace nn
20 {
21 namespace pia
22 {
23 namespace common
24 {
25 
26 
27 /*!
28 @cond PRIVATE
29 @brief Statistics class.
30 */
31 class StatisticValue : public nn::pia::common::RootObject
32 {
33 public:
34  u32 m_Value;
35  u32 m_ValueMax;
36  u32 m_ValueMaxResult;
37  u32 m_ValueMin;
38  u32 m_ValueMinResult;
39  u32 m_ValueSum;
40  u32 m_Count;
41  u32 m_Average;
42 
43 /*!
44 @brief Instantiates the object.
45 */
46  StatisticValue(void)
47  {
48  ResetValue();
49  }
50 
51  void ResetValue()
52  {
53  m_Value = 0;
54  m_ValueMax = 0;
55  m_ValueMaxResult = 0;
56  m_ValueMin = 0xFFFFFFFF;
57  m_ValueMinResult = 0;
58  m_ValueSum = 0;
59  m_Count = 0;
60  m_Average = 0;
61  }
62 
63  void AddValue(u32 value)
64  {
65  m_Value = value;
66  m_ValueSum += m_Value;
67  m_Count++;
68  if (m_Value > m_ValueMax)
69  {
70  m_ValueMax = m_Value;
71  }
72  if (m_Value < m_ValueMin)
73  {
74  m_ValueMin = m_Value;
75  }
76  }
77 
78  void CalcAverage()
79  {
80  m_Average = m_ValueSum / m_Count;
81  m_ValueMaxResult = m_ValueMax;
82  m_ValueMinResult = m_ValueMin;
83  }
84 };
85 //! @endcond
86 }
87 }
88 } // end of namespace nn::pia::common
Definition: assert.h:115
This is the common base class used inside the Pia library.
Definition: common_RootObject.h:40