CTR-Pia  5.4.3
Game Communication Engine
 全て クラス ネームスペース 関数 変数 型定義 列挙型 列挙型の値 ページ
clone_StraightSerializePolicy.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 #if 0
14 #pragma once
15 
16 #include <nn/pia/clone/clone_Definitions.h>
17 #include <memory>
18 
19 namespace nn
20 {
21 namespace pia
22 {
23 namespace clone
24 {
25 
26 
27 /*!
28  @brief 元のデータ構造そのままにシリアライズします。
29 
30  @tparam Type_ シリアライズ対象のデータ型です。
31  */
32 template <typename Type_>
33 class StraightSerializePolicy
34 {
35 public:
36  /*!
37  @brief シリアライズ対象のデータ型です。
38  */
39  typedef Type_ Type;
40 
41 
42  /*!
43  @cond PRIVATE
44  @brief シリアライズします。
45  @param[out] pBuffer 出力先バッファです。
46  @param[in] value シリアライズ対象のデータです。
47  */
48  static void Serialize(void* pBuffer, const Type& value)
49  {
50 #if NN_PIA_CAFE
51  if (reinterpret_cast<uint32_t>(pBuffer) % __alignof(Type) != 0)
52  {
53  OSBlockMove(pBuffer, &value, sizeof(Type), FALSE);
54  }
55  else
56  {
57  *reinterpret_cast<Type*>(pBuffer) = value;
58  }
59 #elif NN_PIA_CTR
60  nn::nstd::MemCpy(pBuffer, &value, sizeof(Type));
61 #elif NN_PIA_NINTENDOSDK
62  memcpy(pBuffer, &value, sizeof(Type));
63 #else
64  *reinterpret_cast<Type*>(pBuffer) = value;
65 #endif
66  }
67  //! @endcond
68 
69 
70  /*!
71  @cond PRIVATE
72  @brief デシリアライズします。
73  @param[out] pValue デシリアライズされたデータの保存先です。
74  @param[in] cpData デシリアライズするバイト列です。
75  */
76  static void Deserialize(Type* pValue, const void* cpData)
77  {
78 #if NN_PIA_CAFE
79  if (reinterpret_cast<uint32_t>(cpData) % __alignof(Type) != 0)
80  {
81  OSBlockMove(pValue, cpData, sizeof(Type), FALSE);
82  }
83  else
84  {
85  *pValue = *reinterpret_cast<const Type*>(cpData);
86  }
87 #elif NN_PIA_CTR
88  nn::nstd::MemCpy(pValue, cpData, sizeof(Type));
89 #elif NN_PIA_NINTENDOSDK
90  memcpy(pValue, cpData, sizeof(Type));
91 #else
92  *pValue = *reinterpret_cast<const Type*>(cpData);
93 #endif
94  }
95  //! @endcond
96 
97 
98  /*!
99  @cond PRIVATE
100  @brief シリアライズされたサイズを取得します。
101  @details @ref nn::pia::clone::CloneProtocol::GetElementSizeMax() "CloneProtocol::GetElementSizeMax()" より大きな値は使用できません。
102  @return シリアライズされたサイズです。
103  */
104  static uint32_t GetSize()
105  {
106  return sizeof(Type);
107  }
108  //! @endcond
109 
110 
111  /*!
112  @cond PRIVATE
113  @brief シリアライズされたサイズです。
114  @details @ref nn::pia::clone::ReliableLargeCloneElement で使用するときは @ref GetSize() ではなくこちらの値が使われます。
115  */
116  static const uint32_t Size = sizeof(Type);
117  //! @endcond
118 };
119 }
120 }
121 } // end of namespace nn::pia::clone
122 #endif