CTR-Pia  5.4.3
Game Communication Engine
 全て クラス ネームスペース 関数 変数 型定義 列挙型 列挙型の値 ページ
clone_ReliableCloneElement.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/clone/clone_Definitions.h>
17 #include <nn/pia/clone/clone_ReliableCloneElementBase.h>
18 
19 namespace nn
20 {
21 namespace pia
22 {
23 namespace clone
24 {
25 
26 
27 /*!
28  @brief 到達保証された値の送受信を管理します。
29 
30  @tparam Value_ 管理する値の型です。
31  */
32 template <typename Value_>
34 {
35 public:
36  /*!
37  @brief このオブジェクトが管理する値の型です。
38  */
39  typedef Value_ Value;
40 
41 
42  /*!
43  @brief Value をシリアライズするためのアルゴリズムです。
44  */
46 
47 
48  /*!
49  @brief デフォルトコンストラクタです。
50  */
52  : ReliableCloneElementBase(), m_Value()
53  {
54  }
55 
56 
57  /*!
58  @brief デストラクタです。
59  */
61  {
62  }
63 
64 
65  /*!
66  @brief 値を設定します。
67  @param[in] value 設定する値です。
68  @return 成功すれば、IsSuccess() が true を返す Result が返されます。
69  @retval ResultInvalidState 登録している CloneBase が送信可能状態ではありません。プログラミングエラーです。このエラーが返らないようにソースコードを修正してください。
70  @retval ResultTemporaryUnavailable 値を設定できるタイミングではありません。値を設定するためには時刻を進める必要があります。アプリケーションで適切にハンドリングしてください。
71  */
72  Result SetValue(const Value& value);
73 
74 
75  /*!
76  @brief 値を取得します。
77  @return このオブジェクトが管理する値です。 IsValidValue() が false の場合に取得できる値は不定です。
78  */
79  const Value& GetValue() const
80  {
81  return m_Value;
82  }
83 
84 
85  //! @cond PRIVATE
86 
87 protected:
88  virtual uint32_t GetSize() const
89  {
91  }
92  virtual void Serialize(void* pBuffer) const
93  {
94  ValueSerializePolicy::Serialize(pBuffer, m_Value);
95  }
96  virtual void Deserialize(const void* cpData)
97  {
98  ValueSerializePolicy::Deserialize(&m_Value, cpData);
99  }
100  virtual void ClearValue()
101  {
102  m_Value = Value();
103  }
104 
105 private:
106  Value m_Value;
107  NN_PIA_DISALLOW_COPY(ReliableCloneElement);
108  //! @endcond
109 };
110 
111 
112 //! @cond
113 template <typename Value>
114 Result ReliableCloneElement<Value>::SetValue(const Value& value)
115 {
116  Result r = SetValueCore();
117  if (r.IsSuccess())
118  {
119  m_Value = value;
120  }
121  return r;
122 }
123 //! @endcond
124 }
125 }
126 } // end of namespace nn::pia::clone