CTR Pia  4.11.3
Game Communication Engine
transport_ProtocolId.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: transport_ProtocolId.h
4 
5  Copyright Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 
15 #pragma once
16 
17 #include <pia/transport/transport_definitions.h>
18 
19 
20 namespace nn
21 {
22 namespace pia
23 {
24 namespace transport
25 {
26 
27 
28 /*!
29 @cond PRIVATE
30 @brief A struct representing a protocol ID.
31 */
32 struct ProtocolId
33 {
34 public:
35  struct Item
36  {
37 #if NN_PIA_ENDIAN_BIG
38  u16 m_Type;
39  u16 m_Port;
40 #else
41  u16 m_Port;
42  u16 m_Type;
43 #endif
44  };
45 
46  union
47  {
48  u32 m_Value;
49  Item m_Item;
50  };
51 
52 
53 /*!
54 @brief Default constructor.
55 */
56  ProtocolId()
57  : m_Value(INVALID.m_Value)
58  {
59  }
60 
61 
62 /*!
63 @brief Converts from a <tt>u32</tt> value.
64 */
65  ProtocolId(u32 value)
66  : m_Value(value)
67  {
68  }
69 
70 /*!
71 @brief Gets the type.
72 */
73  u16 GetType()
74  {
75  return m_Item.m_Type;
76  }
77 
78 /*!
79 @brief Generates from the type and port.
80 */
81  ProtocolId(u16 type, u16 port)
82  {
83  m_Item.m_Type = type;
84  m_Item.m_Port = port;
85  }
86 
87 
88 /*!
89 @brief Converts to a <tt>u32</tt> value.
90 */
91  operator u32() const
92  {
93  return m_Value;
94  }
95 
96 
97 /*!
98 @brief Invalid protocol ID.
99 */
100  static const ProtocolId INVALID;
101 };
102 //! @endcond
103 }
104 }
105 } // end of namespace nn::pia::transport
Definition: assert.h:115