CTR-Pia  5.4.3
Game Communication Engine
 全て クラス ネームスペース 関数 変数 型定義 列挙型 列挙型の値 ページ
common_Watermark.h
1 /*--------------------------------------------------------------------------------*
2  Copyright (C)Nintendo All rights reserved.
3 
4  These coded instructions, statements, and computer programs contain proprietary
5  information of Nintendo and/or its licensed developers and are protected by
6  national and international copyright laws. They may not be disclosed to third
7  parties or copied or duplicated in any form, in whole or in part, without the
8  prior written consent of Nintendo.
9 
10  The content herein is highly confidential and should be handled accordingly.
11  *--------------------------------------------------------------------------------*/
12 
13 
14 #pragma once
15 
16 #include <nn/pia/common/common_Definitions.h>
17 
18 #include <nn/pia/common/common_RootObject.h>
19 
20 
21 namespace nn
22 {
23 namespace pia
24 {
25 namespace common
26 {
27 
28 
29 /*!
30  @brief Piaライブラリ内部のリソース使用量のピーク値などを計測するために用意されたクラスです(サポート対象外)。
31 
32  */
33 class Watermark : public RootObject
34 {
35 public:
36  /*!
37  @brief SetName() で設定可能な名前の最大長です。
38 
39  @see SetName
40  */
41  static const uint32_t MaxNameLength = 63;
42 
43 
44  /*!
45  @brief デフォルトコンストラクタです。
46  インスタンスは Update() 機能が無効にされた状態で構築されます。
47  */
48  Watermark(void);
49 
50 
51  /*!
52  @brief デストラクタです。
53  */
54  ~Watermark(void);
55 
56 
57  /*!
58  @brief Update() による値の更新を有効にします。
59 
60  @details 更新が有効な状態で Update() を呼び出すと、必要に応じて最大値/最小値が更新され、
61  GetLatestValue() で取得可能な値が更新され、 Update() の呼び出し回数カウンタが
62  インクリメントされます。
63  @see SetUpdateDisabled, IsUpdateEnabled
64  */
65  void SetUpdateEnabled(void)
66  {
67  m_IsEnabled = true;
68  }
69 
70 
71  /*!
72  @brief Update() による値の更新を無効にします。
73 
74  @details 更新が無効な状態では、 Update() を呼び出しても、最大値/最小値/最新の値/
75  Update() 呼び出し回数などの値は更新されません。
76  @see SetUpdateEnabled, IsUpdateEnabled
77  */
78  void SetUpdateDisabled(void)
79  {
80  m_IsEnabled = false;
81  }
82 
83 
84  /*!
85  @brief Update() 機能が有効な状態であるかどうかを返します。
86 
87  @return Update() による値の更新が有効に設定されていれば true 、無効に設定されていれば false を返します。
88  @see SetUpdateEnabled, SetUpdateDisabled
89  */
90  bool IsUpdateEnabled(void) const
91  {
92  return m_IsEnabled;
93  }
94 
95 
96  /*!
97  @brief インスタンスに名前を設定します。
98 
99  @param[in] pName 設定する名前。 NUL 文字で終端される文字列で、文字列長は MaxNameLength 以下でなくてはなりません。
100  無効なポインタが指定されたり、長すぎる名前が指定された場合は、アサート停止します。
101  @see GetName
102  */
103  void SetName(const char* pName);
104 
105 
106  /*!
107  @brief インスタンスに付けられた名前を得ます。
108 
109  @return 名前が格納された文字配列を指すポインタ。
110  @see SetName
111  */
112  const char* GetName(void) const
113  {
114  return m_Name;
115  }
116 
117 
118  /*!
119  @brief インスタンスが保持していた最大値、最小値、最新の値、 Update() 呼び出し回数を初期状態に戻します。
120 
121  @details SetName() で設定した名前と、 Update() 機能の有効/無効については何も変更を加えません。
122  @see SetName, SetUpdateEnabled, SetUpdateDisabled, IsUpdateEnabled
123  */
124  void Reset(void);
125 
126 
127  /*!
128  @brief 値を更新します。
129 
130  @details Update() 機能が有効に設定された状態でこの関数を呼び出すと、
131  これまでの最大値、最小値、最新の値、 Update() 呼び出し回数などの
132  値が適切に更新されます。
133  Update() 機能が無効に設定された状態でこの関数を呼び出した場合には、
134  何もせずに返ります。
135 
136  @param[in] value 監視対象の値。
137  @see SetUpdateEnabled, SetUpdateDisabled, IsUpdateEnabled, GetMaxValue, GetMinValue, GetLatestValue, GetUpdateCount
138  */
139  void Update(int64_t value);
140 
141 
142  /*!
143  @brief これまでの Update() における最大値を返します。
144 
145  @see Update, GetMinValue, GetLatestValue, GetUpdateCount
146  */
147  int64_t GetMaxValue(void) const
148  {
149  return m_MaxValue;
150  }
151 
152 
153  /*!
154  @brief これまでの Update() における最小値を返します。
155 
156  @see Update, GetMaxValue, GetLatestValue, GetUpdateCount
157  */
158  int64_t GetMinValue(void) const
159  {
160  return m_MinValue;
161  }
162 
163 
164  /*!
165  @brief 最後の Update() で渡された、最新の値を取得します。
166 
167  @see Update, GetMinValue, GetMaxValue, GetUpdateCount
168  */
169  int64_t GetLatestValue(void) const
170  {
171  return m_LatestValue;
172  }
173 
174  /*!
175  @brief これまでに Update() が呼ばれた回数を返します。
176 
177  @see Update, GetMaxValue, GetMinValue, GetLatestValue
178  */
179  int64_t GetUpdateCount(void) const
180  {
181  return m_UpdateCount;
182  }
183 
184 
185  /*!
186  @brief デバッグに有用な情報をプリントします。
187 
188  @param[in] flag トレースフラグの論理和。詳細は@ref TraceFlag 型を参照してください。
189  */
190  void Trace(uint64_t flag) const;
191 
192 
193 private:
194  int64_t m_MinValue; // 最小値。
195  int64_t m_MaxValue; // 最大値。
196  int64_t m_LatestValue; // 最新の値。
197  uint64_t m_UpdateCount; // Update() が実行された回数。
198 
199  bool m_IsEnabled; // Update() 機能が利用できるかどうか
200 
201  char m_Name[MaxNameLength + 1]; // Watermark インスタンスに付ける名前。
202 };
203 }
204 }
205 } // end of namespace nn::pia::common