1 /*--------------------------------------------------------------------------
2   Project:  HorizonSDK
3   File:     rdt_ReceiveBuffer.h
4 
5   Copyright 2009 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   $Date:: 2010-04-30#$
14   $Rev: 15289 $
15   $Author: hiratsu_daisuke $
16  *-------------------------------------------------------------------------*/
17 
18 #include "stdafx.h"
19 
20 #ifndef NN_RDT_RECEIVEBUFFER_H_
21 #define NN_RDT_RECEIVEBUFFER_H_
22 
23 #include "rdt_RingBuffer.h"
24 
25 
26 namespace nn { namespace rdt { namespace CTR {
27 
28 /* Please see man pages for details
29 
30 
31 
32 */
33 class ReceiveBuffer{
34 public:
35 /* Please see man pages for details
36 
37 */
38     ReceiveBuffer(void);
39 
40 /* Please see man pages for details
41 
42 */
43    ~ReceiveBuffer(void);
44 
45 /* Please see man pages for details
46 
47 
48  */
49     void Initialize(void *pBuf, u16 bufSize);
50 
51 /* Please see man pages for details
52 
53 */
54     void Finalize(void);
55 
56 /* Please see man pages for details
57 
58 
59 
60 
61 */
62     void SetInitialSequenceNumber(u32 num);
63 
64 /* Please see man pages for details
65 
66 
67 */
68     void Pop(size_t n);
69 
70 /* Please see man pages for details
71 
72 
73 
74 */
75     bool Push(const void *pBuf, size_t len);
76 
77 /* Please see man pages for details
78 
79 
80 
81 
82 */
83     size_t Read(void *pBuf, size_t len);
84 
85 /* Please see man pages for details
86 
87 
88 */
89     u32 GetLatestSequenceNumber(void) const;
90 
91 /* Please see man pages for details
92 
93 */
94     size_t GetRestSize(void) const;
95 
96 /* Please see man pages for details
97 
98 
99 */
100     void Clear(void);
101 
102 /* Please see man pages for details
103 
104 */
105     bool IsEmpty(void) const;
106 
107 /* Please see man pages for details
108 
109 */
110     void PrintDebugInfo(void) const;
111 
112 /* Please see man pages for details
113 
114 */
115     static void Test(void);
116 
117 
118 private:
119 /* Please see man pages for details
120 
121 */
122     ReceiveBuffer           (const ReceiveBuffer&);
123 
124 /* Please see man pages for details
125 
126 */
127     ReceiveBuffer& operator=(const ReceiveBuffer&);
128 
129 
130     // Member variable group
131     RingBuffer m_ringBuf;
132     u32        m_initSeqNum;  // Initial sequence number
133     u32        m_latestSeqNum;
134     bool       m_initialized; // true if initialization completes
135 
136     // Padding
137     u8         m_padding[3];
138 };
139 
140 }}} // namespace nn::rdt::CTR
141 
142 #endif  // end of NN_RDT_RECEIVEBUFFER_H_
143