1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     rdt_SendBuffer.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  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: 46347 $
14  *---------------------------------------------------------------------------*/
15 
16 #include "stdafx.h"
17 
18 #ifndef NN_LIBRARIES_RDT_CTR_RDT_SEND_BUFFER_H_
19 #define NN_LIBRARIES_RDT_CTR_RDT_SEND_BUFFER_H_
20 
21 #include "rdt_RingBuffer.h"
22 
23 namespace nn { namespace rdt { namespace CTR {
24 
25 /* Please see man pages for details
26 
27 */
28 class SendBuffer{
29 public:
30 /* Please see man pages for details
31 
32 */
33     SendBuffer(void);
34 
35 /* Please see man pages for details
36 
37 */
38    ~SendBuffer(void);
39 
40 /* Please see man pages for details
41 
42  */
43     void Initialize(void *pBuf, u16 bufSize);
44 
45 /* Please see man pages for details
46 
47 */
48     void Finalize(void);
49 
50 /* Please see man pages for details
51 
52 
53 
54 */
55     bool Push(const void *pBuf, size_t len);
56 
57 /* Please see man pages for details
58 
59 
60 
61 
62  */
63     size_t Pull(void *pBuf, u32 *pSeq, size_t len);
64 
65 /* Please see man pages for details
66 
67 */
68     bool IsEmpty(void) const;
69 
70 /* Please see man pages for details
71 
72 */
73     u32 GetInitialSequenceNumber(void) const;
74 
75 /* Please see man pages for details
76 
77 */
78     u32 GetCurrentSequenceNumber(void) const;
79 
80 /* Please see man pages for details
81 
82 
83 
84 */
85     void Clear(u32 initSeqNum);
86 
87 /* Please see man pages for details
88 
89 */
90     void PrintDebugInfo(void) const;
91 
92 /* Please see man pages for details
93 
94 */
95     static void Test(void);
96 
97 
98 private:
99 /* Please see man pages for details
100 
101 */
102     SendBuffer           (const SendBuffer&);
103 
104 /* Please see man pages for details
105 
106 */
107     SendBuffer& operator=(const SendBuffer&);
108 
109     u32 genInitSeqNum(void) const;
110 
111     RingBuffer m_ringBuf;
112     u32        m_initSeqNum;   // Initial sequence number
113     u32        m_readByte;     // Number of data bytes read in with Pull up to this time
114     bool       m_initialized;
115 
116     u8         m_padding[3];   // Padding
117 };
118 
119 
120 
121 }}} // namespace nn::rdt::CTR
122 
123 #endif  // end of NN_LIBRARIES_RDT_CTR_RDT_SEND_BUFFER_H_
124