CTR-Pia  5.4.3
Game Communication Engine
 全て クラス ネームスペース 関数 変数 型定義 列挙型 列挙型の値 ページ
clone_ReceiveClone.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_CloneBase.h>
18 
19 
20 namespace nn
21 {
22 namespace pia
23 {
24 namespace clone
25 {
26 
27 
28 /*!
29  @brief 一方向の送受信の受信側を管理する CloneBase 派生クラスです。
30  */
32 {
33 public:
34  /*!
35  @brief デフォルトコンストラクタです。
36  */
37  ReceiveClone();
38 
39 
40  /*!
41  @brief デストラクタです。
42  */
43  virtual ~ReceiveClone();
44 
45 
46  /*!
47  @brief CloneProtocol に登録するときに送信側として指定された @ref StationIndex を取得します。
48  @return 送信側の @ref StationIndex です。 CloneProtocol に登録されてない場合は @ref StationIndex_Invalid を返します。
49  */
51  {
52  return GetStationIndex();
53  }
54 
55 
56  /*!
57  @brief この ReceiveClone に送信する SendClone が存在するかどうかを判定します。
58  @return この ReceiveClone に送信する SendClone が存在すれば true を返します。
59  @see SendClone::IsConnected, SendClone::IsConnectedWithAll
60  */
61  bool IsConnected() const
62  {
63  return IsActive() && m_IsReceiving;
64  }
65 
66 
67  /*!
68  @brief デバッグに有用な情報をプリントします。
69 
70  @param[in] flag トレースフラグの論理和。詳細は @ref TraceFlag 型を参照してください。
71  */
72  virtual void Trace(uint64_t flag) const;
73 
74 
75 public:
76  // デバッグ用
77  /*!
78  @cond PRIVATE
79  @brief 受信中かどうかを取得します。(デバッグ用)
80  */
81  bool IsReceiving() const
82  {
83  return m_IsReceiving;
84  }
85  //! @endcond
86 
87  //! @cond PRIVATE
88 
89 public:
90  static Type GetTypeStatic()
91  {
92  return Type_Receive;
93  }
94  static Key ToKey(StationIndex stationIndex, Id id)
95  {
96  return CloneBase::ToKey(Type_Receive, stationIndex, id);
97  }
98  virtual Type GetTypeVirtual() const
99  {
100  return GetTypeStatic();
101  }
102 
103 protected:
104  virtual void OnStartup();
105  virtual void OnCleanup();
106  virtual void OnEnd();
107  virtual bool IsEndProcessFinished();
108 
109  virtual void OnEnter(StationIndex stationIndex);
110  virtual void OnExit(StationIndex stationIndex);
111  virtual void OnDisconnect(StationIndex stationIndex, bool isValid);
112  virtual void OnRegister();
113 
114 public:
115  virtual uint32_t GetDestBitmap() const;
116  virtual bool IsInRequest() const
117  {
118  return m_RequestCommandToken.IsInList();
119  }
120 
121  virtual uint8_t GetLocalRegisterCount() const
122  {
123  return m_LocalRegisterCount;
124  }
125  virtual bool IsMatchLocalRegisterCount(uint64_t registerCountAll) const;
126  void IncrementLocalRegisterCount();
127 
128 public:
129  bool ReceiveAnnounce();
130  void ReceiveAccept(ClockValue clock);
131  void ReceiveReject(ClockValue clock);
132  void ReceiveEnd();
133  void ReceiveStop(StationIndex src);
134 
135 public:
136  class RequestCommandToken : public ClockCommandToken
137  {
138  public:
139  explicit RequestCommandToken(ReceiveClone* pClone)
140  : ClockCommandToken(pClone), m_Clock(InvalidClock)
141  {
142  }
143  virtual CommandType GetType() const
144  {
145  return CommandType_Request;
146  }
147  virtual uint32_t GetDestStationBitmap() const
148  {
149  return (0x1 << (static_cast<const ReceiveClone*>(GetClone())->GetStationIndex()));
150  }
151  virtual ClockValue GetClock() const
152  {
153  return m_Clock;
154  }
155  void SetClock(ClockValue clock)
156  {
157  m_Clock = clock;
158  }
159 
160  private:
161  ClockValue m_Clock;
162  };
163 
164 private:
165  RequestCommandToken m_RequestCommandToken;
166  bool m_IsReceiving;
167  bool m_IsSendingStationDisconnected;
168 
169  uint8_t m_LocalRegisterCount; // 自分の Register カウンタ (2 bit)
170 
171 public:
172  template <int TEST_ID, typename Arg>
173  static void Test(const ReceiveClone& obj, Arg* pArg = NULL);
174 
175  NN_PIA_DISALLOW_COPY(ReceiveClone);
176  //! @endcond
177 };
178 }
179 }
180 } // end of namespace nn::pia::clone