CTR Pia  4.11.3
Game Communication Engine
transport_SequenceIdController.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: transport_SequenceIdController.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 @brief Manages the sequence ID of the packet.
30 In conjunction with this, includes a profiling feature for packet loss.
31 
32 @date 2013-03-25 Removed the <tt>GetProfiledToAllPacketNum</tt> function and added the <tt>GetProfiledMulticastPacketNum</tt> function.
33 @date 2012-06-28 Clearly indicated which functions are thread-safe.
34 @date 2012-06-21 Made the constructor and destructor private.
35 @date 2012-04-19 Made it possible to count the packets addressed to <tt>STATION_INDEX_ALL</tt>.
36 @date 2012-04-06 Initial version.
37 */
39 {
40 public:
41 /*!
42 @cond PRIVATE
43 @brief Instantiates the object with default parameters (default constructor).
44 */
46  //! @endcond
47 
48 
49 /*!
50 @cond PRIVATE
51 @brief Destroys the object.
52 */
53  virtual ~SequenceIdController(void);
54  //! @endcond
55 
56 
57 /*!
58 @cond PRIVATE
59 @brief Initiates communication.
60 @return Returns <tt>nn::ResultSuccess</tt>.
61 */
62  nn::Result Startup();
63  //! @endcond
64 
65 
66 /*!
67 @cond PRIVATE
68 @brief Ends communication.
69 */
70  void Cleanup();
71  //! @endcond
72 
73 
74 /*!
75 @cond PRIVATE
76 @brief Gets the next sequence ID to send.
77 @return The next sequence ID to send.
78 */
79  u16 GetNextSendSequenceId();
80  //! @endcond
81 
82 
83 /*!
84 @cond PRIVATE
85 @brief Checks a received sequence ID.
86 @return Returns <tt>true</tt> if it is a valid sequence ID, or <tt>false</tt> otherwise.
87 */
88  bool CheckReceivedSequenceId(u16 sequenceId);
89  //! @endcond
90 
91 
92 /*!
93 @cond PRIVATE
94 @brief Profiles the packets to <tt>STATION_INDEX_ALL</tt>.
95 */
96  void CountReceivedToAllPacket();
97  //! @endcond
98 
99 
100 /*!
101 @brief Starts profiling.
102 */
103  void StartProfile();
104 
105 
106 /*!
107 @brief Stops profiling.
108 */
109  void StopProfile();
110 
111 
112 /*!
113 @brief Gets the total number of profiled packets.
114 This function is thread-safe.
115 @return The total number of profiled packets.
116 */
118  {
119  return m_ProfileTotalPacketCount;
120  }
121 
122 
123 /*!
124 @brief Gets the number of profiled packet losses.
125 This function is thread-safe.
126 @return The number of profiled packet losses.
127 */
129  {
130  return m_ProfilePacketLossCount;
131  }
132 
133 
134 /*!
135 @brief Gets the number of multicast packets profiled.
136 This function is thread-safe.
137 @return The number of multicast packets profiled.
138 */
140  {
141  return m_ProfileMulticastPacketCount;
142  }
143 
144 
145 /*!
146 @brief Prints information that is useful for debugging.
147 
148 @param[in] flag Specifies the bitwise OR of trace flags. For more information, see the <tt>@ref TraceFlag</tt> type.
149 */
150  virtual void Trace(u64 flag) const;
151 
152 
153 /*!
154 @cond PRIVATE
155 @brief Invalid sequence ID value.
156 @return Invalid sequence ID value.
157 */
158  static u16 GetInvalidSequenceId()
159  {
160  return c_InvalidSequenceId;
161  }
162  //! @endcond
163 
164 
165 /*!
166 @cond PRIVATE
167 @brief Gets the total number of profiled packets (for <tt>TransportAnalyzer</tt>).
168 @return The total number of profiled packets.
169 */
170  u32 GetProfiledTotalPacketNumForTransportAnalyzer() const
171  {
172  return m_ProfileTotalPacketCountForTransportAnalyzer;
173  }
174  //! @endcond
175 
176 
177 /*!
178 @cond PRIVATE
179 @brief Gets the number of profiled packet losses (for <tt>TransportAnalyzer</tt>).
180 @return The number of profiled packet losses.
181 */
182  u32 GetProfiledPacketLossNumForTransportAnalyzer() const
183  {
184  return m_ProfilePacketLossCountForTransportAnalyzer;
185  }
186  //! @endcond
187 
188 private:
189  // Will not implement.
191  bool operator==(const SequenceIdController& rhs) const;
192  bool operator!=(const SequenceIdController& rhs) const;
193  SequenceIdController& operator=(const SequenceIdController& rhs);
194 
195 
196  u16 m_SendSequenceId;
197  u16 m_LastReceiveSequenceId;
198 
199  u16 m_ProfileTotalPacketCount;
200  u16 m_ProfilePacketLossCount;
201  u16 m_ProfileMulticastPacketCount;
202  bool m_IsProfiling;
203 
204  u32 m_ProfileTotalPacketCountForTransportAnalyzer;
205  u32 m_ProfilePacketLossCountForTransportAnalyzer;
206 
207  static const u16 c_InvalidSequenceId = 0;
208 };
209 }
210 }
211 } // end of namespace nn::pia::transport
Manages the sequence ID of the packet. In conjunction with this, includes a profiling feature for pac...
Definition: transport_SequenceIdController.h:38
Definition: assert.h:115
u16 GetProfiledTotalPacketNum() const
Gets the total number of profiled packets. This function is thread-safe.
Definition: transport_SequenceIdController.h:117
u16 GetProfiledPacketLossNum() const
Gets the number of profiled packet losses. This function is thread-safe.
Definition: transport_SequenceIdController.h:128
void StartProfile()
Starts profiling.
This is the common base class used inside the Pia library.
Definition: common_RootObject.h:40
virtual void Trace(u64 flag) const
Prints information that is useful for debugging.
u16 GetProfiledMulticastPacketNum() const
Gets the number of multicast packets profiled. This function is thread-safe.
Definition: transport_SequenceIdController.h:139