CTR Pia  4.11.3
Game Communication Engine
inet_LanCreateSessionSetting.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: inet_LanCreateSessionSetting.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/inet/inet_LanSessionTypes.h>
18 #include <pia/session/session_CreateSessionSetting.h>
19 
20 namespace nn
21 {
22 namespace pia
23 {
24 namespace inet
25 {
26 //! @cond CAFE_DOC
27 
28 /*!
29 @brief Class that manages settings specific to LAN matchmaking session creation.
30 
31 @date 2014-02-03 Initial version.
32 
33 @see nn::pia::session::CreateSessionSetting
34 */
35 class LanCreateSessionSetting : public nn::pia::session::CreateSessionSetting
36 {
37 public:
38 /*!
39 @brief The default constructor.
40 */
41  LanCreateSessionSetting();
42 
43 /*!
44 @brief Destroys the object.
45 */
46  virtual ~LanCreateSessionSetting();
47 
48 /*!
49 @brief Sets the game mode for the session to create.
50 @param[in] gameMode The game mode specified as the session to create.
51 */
52  void SetGameMode(u32 gameMode);
53 /*!
54 @brief Gets the specified game mode.
55 @return Returns the specified game mode.
56 */
57  u32 GetGameMode() const;
58 
59 /*!
60 @brief Sets the session type to create.
61 @param[in] sessionType The session type specified as the session to create.
62 */
63  void SetSessionType(LanSessionType sessionType);
64 /*!
65 @brief Gets the specified session type.
66 @return Returns the specified session type.
67 */
68  LanSessionType GetSessionType() const;
69 
70 /*!
71 @brief Sets the description string for the session to create.
72 @param[in] description The description string specified for the session to create.
73 */
74  void SetDescription(const wchar_t* description);
75 /*!
76 @brief Gets the specified description string.
77 @return Returns the specified description string.
78 */
79  const wchar_t* GetDescription() const;
80 
81 /*!
82 @brief Specifies the attributes for the session to create.
83 @param[in] index The index of the attribute specified for the session to create.
84 @param[in] value The value of the attribute specified for the session to create.
85 */
86  void SetAttribute(u32 index, u32 value);
87 /*!
88 @brief Gets the specified attribute.
89 @param[in] index Index for the attribute to get.
90 @return Returns a specified attribute value.
91 */
92  u32 GetAttribute(u32 index) const;
93 
94 /*!
95 @brief Sets application-defined data.
96 @param[in] pData The buffer for the application-defined data specified for the session to create.
97 @param[in] size The size of the application-defined data specified for the session to create.
98 @return Returns a <tt>Result</tt> value indicating success if the application-defined data is set successfully.
99 
100 @retval nn::pia::ResultInvalidArgument Indicates that either the buffer pointer was <tt>NULL</tt> or the specified data size was too big. Programming error. Fix your program so that this error is not returned.
101 */
102  nn::Result SetApplicationData(const u8* pData, size_t size);
103 /*!
104 @brief Gets specified application-defined data.
105 @param[in] pDataBuf Buffer for copying the specified application-defined data.
106 @param[in] pDataSize Size of the data written to the copy buffer.
107 @param[in] dataBufSize Indicates the copy buffer size.
108 @return Returns a <tt>Result</tt> value indicating success if the application-defined data is acquired successfully.
109 
110 @retval nn::pia::ResultInvalidArgument Indicates that either the buffer pointer is <tt>NULL</tt> or the pointer returned by the copied size is <tt>NULL</tt>. Programming error. Fix your program so that this error is not returned.
111 @retval nn::pia::ResultInvalidState Indicates that no application-defined data is set. Programming error. Fix your program so that this error is not returned.
112 @retval nn::pia::ResultBufferShortage Indicates that the set application-defined data cannot be copied because it is greater in size than the buffer. Programming error. Fix your program so that this error is not returned.
113 */
114  nn::Result GetApplicationData(u8* pDataBuf, size_t* pDataSize, size_t dataBufSize) const;
115 
116 /*!
117 @brief Gets the size of the specified application-defined data.
118 @return Returns the size of the application-defined data.
119 */
120  size_t GetApplicationDataSize() const
121  {
122  return m_ApplicationDataSize;
123  }
124 
125 /*!
126 @brief Sets whether participation in this session is possible.
127 
128 @details Sets whether the created session is to be created as joinable.
129 
130 @param[in] isOpen When set to <tt>true</tt>, the session created by this <tt>LanCreateSessionSetting</tt> function is joinable for the first time.
131 */
132  void SetOpenParticipation(bool isOpen)
133  {
134  m_OpenParticipation = isOpen;
135  }
136 
137 /*!
138 @brief Gets whether participation in this session is possible.
139 
140 @return Returns <tt>true</tt> if the session is joinable.
141 */
142  bool GetOpenParticipation() const
143  {
144  return m_OpenParticipation;
145  }
146 
147 /*!
148 @brief Sets the matchmaking priority when a session with the same requirements is found.
149 
150 @details Sets the matchmaking priority for the created session.
151 If a value that exceeds <tt>nn::pia::inet::SESSION_MAX_SELECTION_PRIORITY</tt> is provided as an argument, <tt>nn::pia::inet::SESSION_MAX_SELECTION_PRIORITY</tt> is set instead.
152 
153 @param[in] priority The matchmaking priority being set.
154 */
155  void SetSelectionPriority(u8 priority);
156 
157 /*!
158 @cond PRIVATE
159 @brief Gets the matchmaking priority when a session with the same requirements is found.
160 
161 @details Gets the matchmaking priority for the session being created.
162 
163 @return Returns the matchmaking priority being set.
164 */
165  u8 GetSelectionPriority() const;
166  //! @endcond
167 
168 /*!
169 @cond PRIVATE
170 @brief Prints information that is useful for debugging.
171 @param[in] flag Specifies the trace flag. For more information, see the <tt>@ref TraceFlag</tt> type.
172 @endcond
173 */
174  void Trace(u64 flag) const;
175 
176 
177 protected:
178  // Game mode.
179  u32 m_GameMode;
180 
181  LanSessionType m_SessionType;
182 
183  // The description string.
184  wchar_t m_Description[LAN_DESCRIPTION_DATA_BUFFER_MAX_SIZE];
185 
186  // Attribute.
187  u32 m_Attribute[LAN_ATTRIBUTE_MAX_SIZE];
188 
189  u8 m_ApplicationDataBuffer[LAN_APPLICATION_DATA_BUFFER_MAX_SIZE];
190  size_t m_ApplicationDataSize;
191 
192  bool m_OpenParticipation;
193 
194 private:
195  // The copy constructor is sealed.
196  LanCreateSessionSetting(const LanCreateSessionSetting&);
197 
198  // The assignment operator is sealed.
199  LanCreateSessionSetting& operator=(const LanCreateSessionSetting&);
200 };
201 
202 //! @endcond
203 }
204 }
205 } // end of namespace nn::pia::inet
Definition: assert.h:115
Base class that manages settings specific to session creation.
Definition: session_CreateSessionSetting.h:38