1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     rdt_Result.h
4 
5   Copyright (C) 2009-2011 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   $Rev: 56250 $
14  *---------------------------------------------------------------------------*/
15 
16 ////#include <stdafx.h>
17 
18 #ifndef NN_RDT_RESULT_H_
19 #define NN_RDT_RESULT_H_
20 
21 #include <nn/Result.h>
22 
23 
24 namespace nn { namespace rdt {
25 
26 /*!
27     @ingroup nn_rdt
28     @defgroup nn_rdt_result  Reliable Local Communication (RDT) Results
29     @brief  A list of <tt>Results</tt> used in the Reliable Local Communication (RDT) library.
30     @{
31 */
32 
33 
34 /*!
35 @private
36 @brief <tt>Result</tt> code details.
37 */
38 enum Description
39 {
40     DESCRIPTION_RESET_RECEIVED = 1,   //!< These results transition to a <tt>CLOSED</tt> state because a reset signal was received from the partner.
41     DESCRIPTION_UNTIMELY_CALL  = 2,   //!< Do not call the function in this state.
42     DESCRIPTION_INVALID_VALUE  = 3    //!< Invalid parameter value.
43 };
44 
45 
46 /*!
47   @class nn::rdt::ResultAlreadyInitialized
48   @brief Indicates that a function exited without doing anything because initialization had already finished. (This is not an error.)
49 
50     This result code may be returned when an initialization function is called more than once.
51  */
52 NN_DEFINE_RESULT_CONST(
53     ResultAlreadyInitialized,
54     Result::LEVEL_INFO,
55     Result::SUMMARY_NOTHING_HAPPENED,
56     Result::MODULE_NN_RDT,
57     Result::DESCRIPTION_ALREADY_INITIALIZED);
58 
59 
60 /*!
61   @class nn::rdt::ResultDoNothing
62   @brief Indicates that a function exited without doing anything. (This is not an error.)
63 
64     One example of when this result may be returned is when you try to send zero bytes of data.
65 */
66 NN_DEFINE_RESULT_CONST(
67     ResultDoNothing,
68     Result::LEVEL_INFO,
69     Result::SUMMARY_NOTHING_HAPPENED,
70     Result::MODULE_NN_RDT,
71     Result::DESCRIPTION_SUCCESS);
72 
73 
74 /*!
75     @class nn::rdt::ResultNotInitialized
76     @brief Indicates an uninitialized instance.
77 
78     Most functions in the RDT API require an instance to be initialized before they can be used.
79     Initialize an object instance with an initialization function before you call a function in the RDT library.
80 */
81 NN_DEFINE_RESULT_CONST(
82     ResultNotInitialized,
83     Result::LEVEL_USAGE,
84     Result::SUMMARY_INVALID_STATE,
85     Result::MODULE_NN_RDT,
86     Result::DESCRIPTION_NOT_INITIALIZED);
87 
88 
89 /*!
90     @class nn::rdt::ResultSendBufferIsNotAvailable
91     @brief Indicates that the <tt>Sender::Send</tt> function attempted to write data to the send buffer, but the send buffer did not have enough free space.
92 
93     Call <tt>Sender::Process</tt> to make free space in the send buffer.
94     Because <tt>@ref Sender::Process</tt> actually sends the data, data copied to the send buffer is eventually used up. (Of course, this assumes the data was successfully received by the receiver.)
95     If you encounter this result code, you might succeed by calling <tt>@ref Sender::Process</tt> followed by <tt>@ref Sender::Send</tt> several times.
96 
97 
98 */
99 NN_DEFINE_RESULT_CONST(
100     ResultSendBufferIsNotAvailable,
101     Result::LEVEL_TEMPORARY,
102     Result::SUMMARY_OUT_OF_RESOURCE,
103     Result::MODULE_NN_RDT,
104     Result::DESCRIPTION_OUT_OF_MEMORY);
105 
106 
107 /*!
108     @class nn::rdt::ResultInvalidSize
109     @brief Indicates that an invalid size was specified as an argument.
110 
111     This result code is returned if, for example, you specify a buffer size of zero.
112  */
113 NN_DEFINE_RESULT_CONST(
114     ResultInvalidSize,
115     Result::LEVEL_USAGE,
116     Result::SUMMARY_INVALID_ARGUMENT,
117     Result::MODULE_NN_RDT,
118     Result::DESCRIPTION_INVALID_SIZE);
119 
120 
121 /*!
122     @class nn::rdt::ResultMisalignedAddress
123     @brief Indicates that a memory address with an invalid alignment was passed as an argument.
124 
125     Some parts of the RDT library require 8-byte alignment.
126     In cases like this, you must pass a correctly aligned memory address.
127 
128  */
129 NN_DEFINE_RESULT_CONST(
130     ResultMisalignedAddress,
131     Result::LEVEL_USAGE,
132     Result::SUMMARY_INVALID_ARGUMENT,
133     Result::MODULE_NN_RDT,
134     Result::DESCRIPTION_MISALIGNED_ADDRESS);
135 
136 
137 /*!
138     @class nn::rdt::ResultNullPointer
139     @brief Indicates an error caused by specifying a null pointer as an argument.
140 
141     For example, you cannot use a null pointer in places where you are passing a memory address for use as working memory or as the memory address to start writing data.
142 
143  */
144 NN_DEFINE_RESULT_CONST(
145     ResultNullPointer,
146     Result::LEVEL_USAGE,
147     Result::SUMMARY_INVALID_ARGUMENT,
148     Result::MODULE_NN_RDT,
149     Result::DESCRIPTION_INVALID_POINTER);
150 
151 
152 /*!
153     @class nn::rdt::ResultResetReceived
154     @brief Indicates that a reset signal was received from a peer, and there was a state transition to <tt>CLOSED</tt>.
155 
156     The reset signal is sent in response to mistaken connection requests and when <tt>@ref Sender::Cancel</tt> or <tt>@ref Receiver::Cancel</tt> is executed. When this reset signal is received, the instance changes state to <tt>CLOSED</tt>. Depending on the situation, you may want to handle this by trying to reconnect again or by disconnecting altogether.
157 
158 
159 
160  */
161 NN_DEFINE_RESULT_CONST(
162     ResultResetReceived,
163     Result::LEVEL_STATUS,
164     Result::SUMMARY_STATUS_CHANGED,
165     Result::MODULE_NN_RDT,
166             DESCRIPTION_RESET_RECEIVED);
167 
168 
169 /*!
170     @class nn::rdt::ResultResendQueueIsFull
171     @brief Indicates that the internal resend queue for the RDT library was full.
172 
173     This is an internal error. If you encounter it, there is a good chance that it is caused by a bug in the RDT library. Please contact Nintendo (support@noa.com) if you come across this error during development.
174 
175  */
176 NN_DEFINE_RESULT_CONST(
177     ResultResendQueueIsFull,
178     Result::LEVEL_RESET,
179     Result::SUMMARY_OUT_OF_RESOURCE,
180     Result::MODULE_NN_RDT,
181     Result::DESCRIPTION_OUT_OF_MEMORY);
182 
183 
184 /*!
185     @class nn::rdt::ResultUntimelyFunctionCall
186     @brief Indicates that a function was called at the wrong time.
187 
188     Call some functions, such as <tt>@ref Sender::Open</tt> and <tt>@ref Receiver::Wait</tt>, only at particular times or instance states. For example, do not call <tt>@ref Sender::Open</tt> when the instance is already in the <tt>SENDER_STATE_OPENED</tt> state. This result code is returned in such situations.
189 
190 
191  */
192 NN_DEFINE_RESULT_CONST(
193     ResultUntimelyFunctionCall,
194     Result::LEVEL_STATUS,
195     Result::SUMMARY_INVALID_STATE,
196     Result::MODULE_NN_RDT,
197             DESCRIPTION_UNTIMELY_CALL);
198 
199 
200 /*!
201     @class nn::rdt::ResultNoData
202     @brief A result code that is used only within the library. Indicates that no segments have been received.
203 
204     Application developers do not need to worry about this result code. It is only used internally by the RDT library.
205 
206  */
207 NN_DEFINE_RESULT_CONST(
208     ResultNoData,
209     Result::LEVEL_TEMPORARY,
210     Result::SUMMARY_NOT_FOUND,
211     Result::MODULE_NN_RDT,
212     Result::DESCRIPTION_NO_DATA);
213 
214 
215 /*!
216     @class nn::rdt::ResultInvalidValue
217     @brief A result code that indicates that an argument value was invalid.
218 
219     Returned when an RDT function receives an unexpected value.
220  */
221 NN_DEFINE_RESULT_CONST(
222     ResultInvalidValue,
223     Result::LEVEL_USAGE,
224     Result::SUMMARY_INVALID_ARGUMENT,
225     Result::MODULE_NN_RDT,
226             DESCRIPTION_INVALID_VALUE);
227 
228 //! @}
229 
230 }} // namespace nn::rdt
231 
232 #endif  // end of NN_RDT_RESULT_H_
233