1 /*-------------------------------------------------------------------------- 2 Project: HorizonSDK 3 File: rdt_SendBuffer.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_SENDBUFFER_H_ 21 #define NN_RDT_SENDBUFFER_H_ 22 23 #include "rdt_RingBuffer.h" 24 25 namespace nn { namespace rdt { namespace CTR { 26 27 /*! 28 @brief これは送信バッファを表現するクラスです。 29 */ 30 class SendBuffer{ 31 public: 32 /*! 33 @brief 初期化します。 34 */ 35 SendBuffer(void); 36 37 /*! 38 @brief 解放します。 39 */ 40 ~SendBuffer(void); 41 42 /*! 43 @brief 初期化します。初期シーケンス番号は明示的に与えます。 44 */ 45 void Initialize(void *pBuf, u16 bufSize); 46 47 /*! 48 @brief 解放処理を行います。 49 */ 50 void Finalize(void); 51 52 /*! 53 @brief データを追加します。 54 バッファの空きが不足しており、データを追加するのに充分な空きが無い場合には 55 falseが返ります。 56 */ 57 bool Push(const void *pBuf, size_t len); 58 59 /*! 60 @brief バッファからデータを取り出します。また、取り出したデータの 61 先頭オクテットのシーケンス番号も得られます。 62 取り出したデータは、このオブジェクトから除去されることに注意して下さい。 63 取り出すことのできたバイト数が返ります。 64 */ 65 size_t Pull(void *pBuf, u32 *pSeq, size_t len); 66 67 /*! 68 @brief バッファがカラッポかどうかを判定します。 69 */ 70 bool IsEmpty(void) const; 71 72 /*! 73 @brief 初期シーケンス番号を取得します。 74 */ 75 u32 GetInitialSequenceNumber(void) const; 76 77 /*! 78 @brief 現時点でのシーケンス番号を取得します。 79 */ 80 u32 GetCurrentSequenceNumber(void) const; 81 82 /*! 83 @brief 保持されているデータを破棄し、まっさらな状態に戻します。 84 Initialize()直後の状態に戻るイメージです。 85 初期シーケンス番号も再設定する必要があります。 86 */ 87 void Clear(u32 initSeqNum); 88 89 /*! 90 @brief このオブジェクトの状態をプリントします。(デバッグ用) 91 */ 92 void PrintDebugInfo(void) const; 93 94 /*! 95 @brief CUnitによる単体テストです。 96 */ 97 static void Test(void); 98 99 100 private: 101 /*! 102 @brief コピーコンストラクタは封印します。 103 */ 104 SendBuffer (const SendBuffer&); 105 106 /*! 107 @brief 代入演算子は封印します。 108 */ 109 SendBuffer& operator=(const SendBuffer&); 110 111 u32 genInitSeqNum(void) const; 112 113 RingBuffer m_ringBuf; 114 u32 m_initSeqNum; // 初期シーケンス番号 115 u32 m_readByte; // これまでにPullによって読み取られたデータのバイト数 116 bool m_initialized; 117 118 u8 m_padding[3]; // パディング 119 }; 120 121 122 123 }}} // namespace nn::rdt::CTR 124 125 #endif // end of NN_RDT_SENDBUFFER_H_ 126