CTR-Pia  5.4.3
Game Communication Engine
 全て クラス ネームスペース 関数 変数 型定義 列挙型 列挙型の値 ページ
clone_CloneElementBase.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/common/common_TreeMapNode.h>
18 #include <nn/pia/common/common_ListNode.h>
19 
20 namespace nn
21 {
22 namespace pia
23 {
24 namespace clone
25 {
26 
27 class CloneBase;
28 class CloneProtocol;
29 class IDataPacker;
30 class IDataUnpacker;
31 class CloneProfilerBase;
32 
33 /*!
34  @brief 送受信されるデータを管理する基底クラスです。
35  */
37 {
38 protected:
39  /*!
40  @brief デフォルトコンストラクタです。
41  */
43 
44 
45 public:
46  /*!
47  @brief デストラクタです。
48  */
49  virtual ~CloneElementBase();
50 
51 
52  /*!
53  @brief クローンエレメントを識別するための ID の型です。
54  */
55  typedef uint16_t Id;
56 
57 
58  /*!
59  @brief ID を取得します。
60  @return CloneBase に登録する際に指定した ID です。 CloneBase に登録されていない場合は 0 を返します。
61  (登録する際に ID を 0 と指定していた場合、有効な値として 0 を返す場合もあります。)
62  */
63  Id GetId() const
64  {
65  return m_TreeMapNode.GetKey();
66  }
67 
68 
69  /*!
70  @brief このオブジェクトが登録されている CloneBase を取得します。
71  @return このオブジェクトが登録されている CloneBase です。
72  */
73  const CloneBase* GetCloneBase() const
74  {
75  return m_pCloneBase;
76  }
77 
78  /*!
79  @brief このオブジェクトが登録されている非constな CloneBase を取得します。
80  @return このオブジェクトが登録されている CloneBase です。
81  */
83  {
84  return m_pCloneBase;
85  }
86 
87 
88  /*!
89  @brief このオブジェクトが登録されている CloneBase が登録されている CloneProtocol を取得します。
90  @return このオブジェクトが登録されている CloneBase が登録されている CloneProtocol です。
91  */
92  const CloneProtocol* GetProtocol() const;
93 
94 
95  /*!
96  @brief CloneBase に登録されているかどうかを判定します。
97  @return CloneBase に登録されていれば true を返します。
98  */
100  {
101  return m_pCloneBase != NULL;
102  }
103 
104 
105  /*!
106  @brief CloneProtocol に登録されているかどうかを判定します。
107  @return CloneProtocol に登録されていれば true を返します。
108  */
109  bool IsRegisteredWithProtocol() const;
110 
111 
112  /*!
113  @brief 値を設定できる状態かどうかを判定します。
114  @return 値を設定できる状態なら true を返します。
115  */
116  bool IsReadyToSetValue() const;
117 
118 
119  //! @name プロファイリング
120  //! @{
121 
122  /*!
123  @brief 送受信のプロファイリング管理オブジェクトを設定します。
124  @details CloneProfiler を設定すると、クローンエレメントが行った送受信をプロファイリングできます。
125  ここでの計測は、このクローンエレメントが他のクローンエレメントと行うすべてのデータのやり取りが計上されるため、
126  自ステーション内でのクローンエレメント間のデータのやり取りも値に含まれます。
127  @details 圧縮を有効にしていた場合でも、計測されるサイズは非圧縮状態でのサイズです。
128  @details 引数に NULL を指定すると、既に設定してある CloneProfiler を解除する事ができます。
129  @param[in] pSendProfiler 送信のプロファイリングを管理する CloneProfiler を指定します。
130  必要ない場合は NULL を指定する必要があります。
131  @param[in] pReceiveProfiler 受信のプロファイリングを管理する CloneProfiler を指定します。
132  必要ない場合は NULL を指定する必要があります。
133  @return 成功すれば、IsSuccess() が true を返す Result が返されます。この関数がエラーを返さないようにアプリケーションを実装する必要があります。
134  @retval ResultInvalidArgument 引数が不正です。プログラミングエラーです。このエラーが返らないようにソースコードを修正してください。
135  */
136  Result SetProfiler(CloneProfilerBase* pSendProfiler, CloneProfilerBase* pReceiveProfiler);
137 
138 
139  /*!
140  @brief 設定されている送信プロファイリング管理オブジェクトを取得します。
141  @return 設定されている送信プロファイリング管理オブジェクトです。設定されていない場合は NULL を返します。
142  @see SetProfiler
143  */
145  {
146  return m_pSendProfiler;
147  }
148 
149 
150  /*!
151  @brief 設定されている受信プロファイリング管理オブジェクトを取得します。
152  @return 設定されている受信プロファイリング管理オブジェクトです。設定されていない場合は NULL を返します。
153  @see SetProfiler
154  */
156  {
157  return m_pReceiveProfiler;
158  }
159 
160 
161  /*!
162  @brief 送受信のプロファイリングされた結果をリセットします。
163  @see SetProfiler
164  */
165  void ResetProfiler();
166 
167 
168  /*!
169  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に送信したクローンエレメントデータの個数を取得します。
170  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
171  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に送信したクローンエレメントデータの個数です。
172  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
173  @see SetProfiler
174  */
175  uint32_t GetProfiledLatestSendCount(StationIndex stationIndex) const;
176 
177 
178  /*!
179  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に送信したクローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
180  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
181  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に送信したクローンエレメントデータの圧縮前のサイズ(バイト)です。
182  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
183  @see SetProfiler
184  */
185  uint32_t GetProfiledLatestSendNoCompressedSize(StationIndex stationIndex) const;
186 
187 
188  /*!
189  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間にユニキャストで送信したクローンエレメントデータの個数を取得します。
190  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
191  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間にユニキャストで送信したクローンエレメントデータの個数です。
192  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
193  @see SetProfiler
194  */
195  uint32_t GetProfiledLatestSendUnicastCount(StationIndex stationIndex) const;
196 
197 
198  /*!
199  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間にユニキャストで送信したクローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
200  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
201  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間にユニキャストで送信したクローンエレメントデータの圧縮前のサイズ(バイト)です。
202  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
203  @see SetProfiler
204  */
205  uint32_t GetProfiledLatestSendUnicastSize(StationIndex stationIndex) const;
206 
207 
208  /*!
209  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に再送したクローンエレメントデータの個数を取得します。
210  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
211  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に再送したクローンエレメントデータの個数です。
212  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
213  @see SetProfiler
214  */
215  uint32_t GetProfiledLatestResendCount(StationIndex stationIndex) const;
216 
217 
218  /*!
219  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に再送したクローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
220  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
221  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に再送したクローンエレメントデータの圧縮前のサイズ(バイト)です。
222  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
223  @see SetProfiler
224  */
225  uint32_t GetProfiledLatestResendSize(StationIndex stationIndex) const;
226 
227 
228  /*!
229  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に送信したシステム用クローンエレメントデータの個数を取得します。
230  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
231  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に送信したシステム用クローンエレメントデータの個数です。
232  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
233  @see SetProfiler
234  */
235  uint32_t GetProfiledLatestSendSystemCount(StationIndex stationIndex) const;
236 
237 
238  /*!
239  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に送信したシステム用クローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
240  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
241  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に送信したシステム用クローンエレメントデータの圧縮前のサイズ(バイト)です。
242  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
243  @see SetProfiler
244  */
245  uint32_t GetProfiledLatestSendSystemSize(StationIndex stationIndex) const;
246 
247 
248  /*!
249  @brief ResetProfiler 以降に送信したクローンエレメントデータの個数を取得します。
250  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
251  @return ResetProfiler() 以降に送信したクローンエレメントデータの個数です。
252  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
253  @see SetProfiler, ResetProfiler
254  */
255  uint32_t GetProfiledTotalSendCount(StationIndex stationIndex) const;
256 
257 
258  /*!
259  @brief ResetProfiler 以降に送信したクローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
260  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
261  @return ResetProfiler() 以降に送信したクローンエレメントデータの圧縮前のサイズ(バイト)です。
262  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
263  @see SetProfiler, ResetProfiler
264  */
265  uint32_t GetProfiledTotalSendNoCompressedSize(StationIndex stationIndex) const;
266 
267 
268  /*!
269  @brief ResetProfiler 以降にユニキャストで送信したクローンエレメントデータの個数を取得します。
270  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
271  @return ResetProfiler() 以降にユニキャストで送信したクローンエレメントデータの個数です。
272  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
273  @see SetProfiler, ResetProfiler
274  */
275  uint32_t GetProfiledTotalSendUnicastCount(StationIndex stationIndex) const;
276 
277 
278  /*!
279  @brief ResetProfiler 以降にユニキャストで送信したクローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
280  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
281  @return ResetProfiler() 以降にユニキャストで送信したクローンエレメントデータの圧縮前のサイズ(バイト)です。
282  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
283  @see SetProfiler, ResetProfiler
284  */
285  uint32_t GetProfiledTotalSendUnicastSize(StationIndex stationIndex) const;
286 
287 
288  /*!
289  @brief ResetProfiler 以降に再送したクローンエレメントデータの個数を取得します。
290  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
291  @return ResetProfiler() 以降に再送したクローンエレメントデータの個数です。
292  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
293  @see SetProfiler, ResetProfiler
294  */
295  uint32_t GetProfiledTotalResendCount(StationIndex stationIndex) const;
296 
297 
298  /*!
299  @brief ResetProfiler 以降に再送したクローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
300  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
301  @return ResetProfiler() 以降に再送したクローンエレメントデータの圧縮前のサイズ(バイト)です。
302  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
303  @see SetProfiler, ResetProfiler
304  */
305  uint32_t GetProfiledTotalResendSize(StationIndex stationIndex) const;
306 
307 
308  /*!
309  @brief ResetProfiler 以降に送信したシステム用クローンエレメントデータの個数を取得します。
310  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
311  @return ResetProfiler() 以降に送信したシステム用クローンエレメントデータの個数です。
312  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
313  @see SetProfiler, ResetProfiler
314  */
315  uint32_t GetProfiledTotalSendSystemCount(StationIndex stationIndex) const;
316 
317 
318  /*!
319  @brief ResetProfiler 以降に送信したシステム用クローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
320  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
321  @return ResetProfiler() 以降に送信したシステム用クローンエレメントデータの圧縮前のサイズ(バイト)です。
322  送信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
323  @see SetProfiler, ResetProfiler
324  */
325  uint32_t GetProfiledTotalSendSystemSize(StationIndex stationIndex) const;
326 
327 
328  /*!
329  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に受信したクローンエレメントデータの個数を取得します。
330  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
331  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に受信したクローンエレメントデータの個数です。
332  受信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
333  @see SetProfiler
334  */
335  uint32_t GetProfiledLatestReceiveCount(StationIndex stationIndex) const;
336 
337 
338  /*!
339  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に受信したクローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
340  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
341  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に受信したクローンエレメントデータの圧縮前のサイズ(バイト)です。
342  受信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
343  @see SetProfiler
344  */
345  uint32_t GetProfiledLatestReceiveNoCompressedSize(StationIndex stationIndex) const;
346 
347 
348  /*!
349  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に受信したシステム用クローンエレメントデータの個数を取得します。
350  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
351  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に受信したシステム用クローンエレメントデータの個数です。
352  受信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
353  @see SetProfiler
354  */
355  uint32_t GetProfiledLatestReceiveSystemCount(StationIndex stationIndex) const;
356 
357 
358  /*!
359  @brief 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に受信したシステム用クローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
360  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
361  @return 直近の @ref CloneProfiler "CloneProfiler::LATEST_BUFFER_SIZE" 回の common::Scheduler::Dispatch の間に受信したシステム用クローンエレメントデータの圧縮前のサイズ(バイト)です。
362  受信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
363  @see SetProfiler
364  */
365  uint32_t GetProfiledLatestReceiveSystemSize(StationIndex stationIndex) const;
366 
367 
368  /*!
369  @brief ResetProfiler 以降に受信したクローンエレメントデータの個数を取得します。
370  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
371  @return ResetProfiler() 以降に受信したクローンエレメントデータの個数です。
372  受信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
373  @see SetProfiler, ResetProfiler
374  */
375  uint32_t GetProfiledTotalReceiveCount(StationIndex stationIndex) const;
376 
377 
378  /*!
379  @brief ResetProfiler 以降に受信したクローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
380  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
381  @return ResetProfiler() 以降に受信したクローンエレメントデータの圧縮前のサイズ(バイト)です。
382  受信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
383  @see SetProfiler, ResetProfiler
384  */
385  uint32_t GetProfiledTotalReceiveNoCompressedSize(StationIndex stationIndex) const;
386 
387 
388  /*!
389  @brief ResetProfiler 以降に受信したシステム用クローンエレメントデータの個数を取得します。
390  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
391  @return ResetProfiler() 以降に受信したシステム用クローンエレメントデータの個数です。
392  受信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
393  @see SetProfiler, ResetProfiler
394  */
395  uint32_t GetProfiledTotalReceiveSystemCount(StationIndex stationIndex) const;
396 
397 
398  /*!
399  @brief ResetProfiler 以降に受信したシステム用クローンエレメントデータの圧縮前のサイズ(バイト)を取得します。
400  @param[in] stationIndex プロファイリング対象の @ref StationIndex です。
401  @return ResetProfiler() 以降に受信したシステム用クローンエレメントデータの圧縮前のサイズ(バイト)です。
402  受信プロファイリング管理オブジェクトが設定されていない場合は 0xFFFFFFFF を返します。
403  @see SetProfiler, ResetProfiler
404  */
405  uint32_t GetProfiledTotalReceiveSystemSize(StationIndex stationIndex) const;
406 
407 
408  /*!
409  @brief クローンエレメントの種類を表す列挙型です。
410  */
411  enum Type
412  {
413  Type_Unreliable = 0x1000, //!< UnreliableCloneElement
414  Type_Reliable = 0x2000, //!< ReliableCloneElement
415  Type_Event = 0x3000, //!< EventCloneElement
416  Type_Reckoning = 0x4000, //!< ReckoningCloneElement
417  Type_ReliableLarge = 0x5000 //!< ReliableLargeCloneElement
418  };
419 
420  /*!
421  @brief クローンエレメントの種類を取得します。
422  @return クローンエレメントの種類です。
423  */
424  virtual Type GetType() const = 0;
425 
426  //! @}
427 
428 
429  //! @cond PRIVATE
430 
431 public:
432  static int32_t GetTreeMapNodeOffset()
433  {
434  NN_PIA_PRAGMA_PUSH_WARNINGS
435  NN_PIA_DISABLE_WARNING_CLANG_INVALID_OFFSETOF
436  return offsetof(CloneElementBase, m_TreeMapNode);
437  NN_PIA_PRAGMA_POP_WARNINGS
438  }
439 
440  virtual bool IsCloneSupported(int cloneType) const
441  {
442  NN_PIA_UNUSED(cloneType);
443  return true;
444  }
445  void AttachCloneBase(CloneBase* pCloneBase);
446  void DetachCloneBase();
447 
448  CloneProfilerBase* GetSendProfilerPtr()
449  {
450  return m_pSendProfiler;
451  }
452  CloneProfilerBase* GetReceiveProfilerPtr()
453  {
454  return m_pReceiveProfiler;
455  }
456 
457  virtual uint32_t GetSize() const = 0;
458 
459  virtual bool IsInitialized() const
460  {
461  return true;
462  }
463 
464  virtual void ClearData() = 0;
465  virtual void AddDest(StationIndex stationIndex)
466  {
467  NN_PIA_UNUSED(stationIndex);
468  }
469  virtual void RemoveDest(StationIndex stationIndex)
470  {
471  NN_PIA_UNUSED(stationIndex);
472  }
473  virtual void AddParticipant(StationIndex stationIndex)
474  {
475  NN_PIA_UNUSED(stationIndex);
476  }
477  virtual void Complement(StationIndex stationIndex)
478  {
479  NN_PIA_UNUSED(stationIndex);
480  }
481  virtual void Lock()
482  {
483  }
484 
485  virtual void RequestInitialData()
486  {
487  }
488 
489  uint32_t GetStationNum() const;
490 
491 public:
492  class ISendToken
493  {
494  public:
495  ISendToken()
496  : m_ListNode()
497  {
498  }
499  bool IsInList() const
500  {
501  return m_ListNode.IsFreeListNode() == false;
502  }
503  virtual Type GetElementType() const = 0;
504  virtual uint32_t GetDestBitmap() const = 0;
505  virtual bool IsResend() const
506  {
507  return false;
508  }
509  virtual uint32_t GetChunkSize() const = 0;
510  virtual void WriteChunk(void* pChunkBuffer) const = 0;
511  virtual CloneElementBase* GetElement() = 0;
512  static int32_t GetListNodeOffset()
513  {
514  NN_PIA_PRAGMA_PUSH_WARNINGS
515  NN_PIA_DISABLE_WARNING_CLANG_INVALID_OFFSETOF
516  return offsetof(ISendToken, m_ListNode);
517  NN_PIA_PRAGMA_POP_WARNINGS
518  }
519  virtual void TraceTokenType()
520  {
521  PIA_TRACE_EX(common::TraceFlagClone, "TokenType: Unknown");
522  };
523 
524  private:
525  common::ListNode m_ListNode;
526  };
527 
528 
529  class ResendableSendToken : public ISendToken
530  {
531  public:
532  ResendableSendToken()
533  : ISendToken(), m_LastSendTime(InvalidSystemTime), m_SendCount(0)
534  {
535  for (int i = 0; i < MaxStationNum; ++i)
536  {
537  m_LastSendTimeArray[i] = InvalidSystemTime;
538  m_SendCountArray[i] = 0;
539  }
540  }
541  virtual bool IsResend() const
542  {
543  return true;
544  }
545  SystemTime GetLastSendTime(StationIndex stationIndex) const
546  {
547  if (stationIndex == StationIndex_Invalid)
548  {
549  return m_LastSendTime;
550  }
551  else
552  {
553  PIA_ASSERT(IsUnicast());
554  PIA_ASSERT(stationIndex < MaxStationNum);
555  return m_LastSendTimeArray[stationIndex];
556  }
557  }
558  void SetLastSendTime(SystemTime time, StationIndex stationIndex)
559  {
560  if (stationIndex == StationIndex_Invalid)
561  {
562  m_LastSendTime = time;
563  }
564  else
565  {
566  PIA_ASSERT(IsUnicast());
567  PIA_ASSERT(stationIndex < MaxStationNum);
568  m_LastSendTimeArray[stationIndex] = time;
569  }
570  }
571  // 再送をユニキャストで行うトークンクラスでオーバーライドし、true を返すようにする
572  virtual bool IsUnicast() const
573  {
574  return false;
575  }
576  void SetSendCount(uint32_t sendCount, StationIndex stationIndex)
577  {
578  if (stationIndex == StationIndex_Invalid)
579  {
580  m_SendCount = sendCount;
581  }
582  else
583  {
584  PIA_ASSERT(IsUnicast());
585  PIA_ASSERT(stationIndex < MaxStationNum);
586  m_SendCountArray[stationIndex] = sendCount;
587  }
588  }
589  void IncrementSendCount(StationIndex stationIndex)
590  {
591  if (stationIndex == StationIndex_Invalid)
592  {
593  ++m_SendCount;
594  }
595  else
596  {
597  PIA_ASSERT(IsUnicast());
598  PIA_ASSERT(stationIndex < MaxStationNum);
599  ++m_SendCountArray[stationIndex];
600  }
601  }
602  uint32_t GetSendCount(StationIndex stationIndex) const
603  {
604  if (stationIndex == StationIndex_Invalid)
605  {
606  return m_SendCount;
607  }
608  else
609  {
610  PIA_ASSERT(IsUnicast());
611  PIA_ASSERT(stationIndex < MaxStationNum);
612  return m_SendCountArray[stationIndex];
613  }
614  }
615 
616  private:
617  SystemTime m_LastSendTime;
618  SystemTime m_LastSendTimeArray[MaxStationNum];
619  uint32_t m_SendCount;
620  uint32_t m_SendCountArray[MaxStationNum];
621  };
622 
623 
624  class ConversibleResendableSendToken : public ResendableSendToken
625  {
626  public:
627  ConversibleResendableSendToken()
628  : ResendableSendToken(), m_IsResend(false)
629  {
630  }
631  virtual bool IsResend() const
632  {
633  return m_IsResend;
634  }
635  void SetResend(bool isResend)
636  {
637  m_IsResend = isResend;
638  }
639 
640  private:
641  bool m_IsResend;
642  };
643 
644 protected:
645  void AddSendData(ISendToken* pToken);
646  void CancelSendData(ISendToken* pToken);
647 
648 protected:
649  void ErrorEventDropped();
650 
651 private:
652  common::TreeMapNode<Id> m_TreeMapNode;
653  CloneBase* m_pCloneBase;
654 
655 public:
656  template <typename Element, typename CP>
657  class DefinitionBase
658  {
659  protected:
660  DefinitionBase()
661  {
662  CP::GetElementDefinition()->Register(Element::GetTypeStatic(), Element::Receive, Element::GetDataChunkHeaderSize());
663  }
664  };
665 
666  template <typename Element>
667  class Definition : public DefinitionBase<Element, CloneProtocol>
668  {
669  public:
670  Definition()
671  : DefinitionBase<Element, CloneProtocol>()
672  {
673  }
674  };
675 
676 private:
677  CloneProfilerBase* m_pSendProfiler;
678  CloneProfilerBase* m_pReceiveProfiler;
679 
680 public:
681  template <int TEST_ID, typename Arg>
682  static void Test(const CloneElementBase& obj, Arg* pArg = NULL);
683 
684  NN_PIA_DISALLOW_COPY(CloneElementBase);
685  //! @endcond
686 };
687 }
688 }
689 } // end of namespace nn::pia::clone