CTR Pia  4.11.3
Game Communication Engine
types.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: types.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 // Moved definitions according to the platform.
18 #include <pia/platform.h>
19 
20 
21 namespace nn
22 {
23 namespace pia
24 {
25 /*!
26 @brief Definition of the <tt>StationId</tt> identifying the station within the session.
27 
28 @details A unique value is assigned to each station participating in the session.
29  You will never see the same value for another participating station.
30  That said, after participating in a session, if a station leaves,
31  its ID might be assigned to another session.
32 */
33 struct StationId
34 {
35  u32 uniqueId; //!< A unique station value.
36  u32 reserved; //!< This is a reserved region.
37 
38  StationId()
39  : uniqueId(0),
40  reserved(0)
41  {
42  }
43 
44  StationId(u64 arg)
45  {
46 *this = arg;
47  }
48 
49  StationId& operator=(const StationId& rhs)
50  {
51  uniqueId = rhs.uniqueId;
52  reserved = rhs.reserved;
53  return *this;
54  }
55 
56  StationId& operator=(u64 arg)
57  {
58  uniqueId = arg % 0x100000000;
59  reserved = static_cast<u32>(arg / 0x100000000);
60  return *this;
61  }
62 
63  bool operator==(const StationId& rhs) const
64  {
65  return (uniqueId == rhs.uniqueId) && (reserved == rhs.reserved);
66  }
67 
68  bool operator!=(const StationId& rhs) const
69  {
70  return !(*this == rhs);
71  }
72 
73  u64 GetValue() const
74  {
75  return (static_cast<u64>(uniqueId) << 0) | (static_cast<u64>(reserved) << 32);
76  }
77 };
78 
79 
80 const u64 STATION_ID_INVALID_VALUE = 0xFFFFFFFFFFFFFFFD; //!< Value indicating invalid <tt>StationId</tt>.
81 const u64 STATION_ID_HOST_VALUE = 0xFFFFFFFFFFFFFFFE; //!< Value indicating host <tt>StationId</tt>.
82 const u64 STATION_ID_ALL_VALUE = 0xFFFFFFFFFFFFFFFF; //!< Value indicating <tt>StationId</tt> for all participants.
83 
84 
85 
86 /*!
87  @brief Gets the <tt>const</tt> reference of the <tt>StationId</tt> object representing the invalid <tt>StationId</tt>.
88  You can also use the <tt>STATION_ID_INVALID</tt> macro.
89 */
91 
92 
93 /*!
94  @brief Gets the <tt>const</tt> reference of the <tt>StationId</tt> object representing the host <tt>StationId</tt>.
95  You can also use the <tt>STATION_ID_HOST</tt> macro.
96 */
98 
99 
100 /*!
101  @brief Gets the <tt>const</tt> reference indicating the <tt>StationId</tt> object to specify all session participants when sending and receiving data.
102  You can also use the <tt>STATION_ID_ALL</tt> macro.
103 */
104 const StationId& GetStationIdAll();
105 
106 
107 #define STATION_ID_INVALID GetStationIdInvalid()
108 #define STATION_ID_HOST GetStationIdHost()
109 #define STATION_ID_ALL GetStationIdAll()
110 
111 
112 }
113 } // end of namespace nn::pia
u32 uniqueId
A unique station value.
Definition: types.h:35
const u64 STATION_ID_HOST_VALUE
Value indicating host StationId.
Definition: types.h:81
Definition of the StationId identifying the station within the session.
Definition: types.h:33
Definition: assert.h:115
const StationId & GetStationIdAll()
Gets the const reference indicating the StationId object to specify all session participants when sen...
const u64 STATION_ID_ALL_VALUE
Value indicating StationId for all participants.
Definition: types.h:82
u32 reserved
This is a reserved region.
Definition: types.h:36
const StationId & GetStationIdInvalid()
Gets the const reference of the StationId object representing the invalid StationId. You can also use the STATION_ID_INVALID macro.
const u64 STATION_ID_INVALID_VALUE
Value indicating invalid StationId.
Definition: types.h:80
const StationId & GetStationIdHost()
Gets the const reference of the StationId object representing the host StationId. You can also use th...