CTR-Pia  5.4.3
Game Communication Engine
 全て クラス ネームスペース 関数 変数 型定義 列挙型 列挙型の値 ページ
clone_SendClone.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 namespace nn
20 {
21 namespace pia
22 {
23 namespace clone
24 {
25 
26 
27 /*!
28  @brief 一方向の送受信の送信側を管理する CloneBase 派生クラスです。
29  */
31 {
32 public:
33  /*!
34  @brief デフォルトコンストラクタです。
35  */
36  SendClone();
37 
38 
39  /*!
40  @brief デストラクタです。
41  */
42  virtual ~SendClone();
43 
44 
45  /*!
46  @brief この SendClone からデータを受け取る ReceiveClone が存在するかどうかを判定します。
47  @details 相手の ReceiveClone が途中で登録解除された場合、アプリケーションや内部によるデータの送受信や、
48  CloneProtocol の通信終了、ステーションの離脱等が起こるまでは反映されないので注意してください。
49  @param[in] stationId 送信先の @ref StationId です。
50  @return この SendClone からデータを受け取る ReceiveClone が stationId に存在すれば true を返します。
51  @see IsConnectedWithAll, ReceiveClone::IsConnected
52  */
53  bool IsConnected(StationId stationId) const;
54 
55 
56  /*!
57  @brief この SendClone からデータを受け取る ReceiveClone が全てのステーションに存在するかどうかを判定します。
58  @details CloneProtocol::IsActiveStation() が true となるステーションが判定対象です。
59  @details 相手の ReceiveClone が途中で登録解除された場合、アプリケーションや内部によるデータの送受信等が
60  起こるまでは反映されないので注意してください。
61  @return この SendClone からデータを受け取る ReceiveClone が全てのステーションに存在すれば true を返します。
62  @see IsConnected, ReceiveClone::IsConnected
63  */
64  bool IsConnectedWithAll() const;
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  @cond PRIVATE
78  @brief 宛先を取得します。(デバッグ用)
79  */
80  uint32_t GetReceiverBmp() const
81  {
82  return m_ReceiverBmp;
83  }
84  //! @endcond
85 
86  /*!
87  @cond PRIVATE
88  @brief 開始通知中かどうかを取得します。(デバッグ用)
89  */
90  bool IsInAnnounce() const
91  {
92  return m_AnnounceCommandToken.IsInList();
93  }
94  //! @endcond
95 
96  /*!
97  @cond PRIVATE
98  @brief 開始通知の宛先を取得します。(デバッグ用)
99  */
100  uint32_t GetAnnounceBmp() const
101  {
102  return m_AnnounceCommandToken.GetDestStationBitmap();
103  }
104  //! @endcond
105 
106  /*!
107  @cond PRIVATE
108  @brief 終了通知中かどうかを取得します。(デバッグ用)
109  */
110  bool IsEnding() const
111  {
112  return m_EndCommandToken.IsInList();
113  }
114  //! @endcond
115 
116 
117  //! @cond PRIVATE
118 public:
119  static Type GetTypeStatic()
120  {
121  return Type_Send;
122  }
123  static Key ToKey(Id id)
124  {
125  return CloneBase::ToKey(Type_Send, StationIndex_Invalid, id);
126  }
127  virtual Type GetTypeVirtual() const
128  {
129  return GetTypeStatic();
130  }
131 
132 
133 protected:
134  virtual void OnStartup();
135  virtual void OnCleanup();
136  virtual void OnEnd();
137  virtual void OnSendFinished();
138  virtual bool IsEndProcessFinished();
139 
140  //virtual void OnEnter(StationIndex stationIndex) {(void)stationIndex;}
141  virtual void OnExit(StationIndex stationIndex);
142  virtual void OnDisconnect(StationIndex stationIndex, bool isValid);
143 
144 public:
145  bool ReceiveRequest(StationIndex src, ClockValue clock, uint8_t count);
146  void ReceiveAnnounceAck(StationIndex src);
147  void ReceiveStop(StationIndex src);
148 
149 public:
150  virtual bool IsReadyToSetValue() const;
151  virtual uint32_t GetDestBitmap() const;
152 
153  virtual uint64_t GetRegisterCountAll() const
154  {
155  return m_RegisterCountAll;
156  }
157  void SetRegisterCountAll(StationIndex stationIndex, uint8_t count);
158 
159 public:
160  class AnnounceCommandToken : public CommandToken
161  {
162  public:
163  explicit AnnounceCommandToken(SendClone* pClone)
164  : CommandToken(pClone), m_DestBitmap(0)
165  {
166  }
167  virtual CommandType GetType() const
168  {
169  return CommandType_Announce;
170  }
171  virtual uint32_t GetDestStationBitmap() const
172  {
173  return m_DestBitmap;
174  }
175  void SetDestBitmap(uint32_t destBitmap)
176  {
177  m_DestBitmap = destBitmap;
178  }
179  void Exit(StationIndex stationIndex)
180  {
181  m_DestBitmap &= ~(0x1 << stationIndex);
182  }
183 
184  private:
185  uint32_t m_DestBitmap;
186  };
187 
188 
189  class EndCommandToken : public CommandToken
190  {
191  public:
192  explicit EndCommandToken(SendClone* pClone)
193  : CommandToken(pClone)
194  {
195  }
196  virtual CommandType GetType() const
197  {
198  return CommandType_End;
199  }
200  virtual uint32_t GetDestStationBitmap() const
201  {
202  return static_cast<const SendClone*>(GetClone())->m_ReceiverBmp;
203  }
204  };
205 
206 
207 private:
208  uint32_t m_ReceiverBmp;
209 
210  AnnounceCommandToken m_AnnounceCommandToken;
211  EndCommandToken m_EndCommandToken;
212 
213  uint64_t m_RegisterCountAll; // 全員の Register カウンタ (各ステーション 2 bit)
214 
215 public:
216  template <int TEST_ID, typename Arg>
217  static void Test(const SendClone& obj, Arg* pArg = NULL);
218 
219  NN_PIA_DISALLOW_COPY(SendClone);
220  //! @endcond
221 };
222 }
223 }
224 } // end of namespace nn::pia::clone