1 /*-------------------------------------------------------------------------- 2 Project: HorizonSDK 3 File: rdt_Transceiver.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-07-21#$ 14 $Rev: 21558 $ 15 $Author: hiratsu_daisuke $ 16 *-------------------------------------------------------------------------*/ 17 18 #include "stdafx.h" 19 20 #ifndef NN_RDT_TRANSCEIVER_H_ 21 #define NN_RDT_TRANSCEIVER_H_ 22 23 24 #include "rdt_Segment.h" 25 26 namespace nn { namespace rdt { namespace CTR { 27 28 /*! 29 @brief これはセグメントの送受信に特化したクラスです。 30 */ 31 class Transceiver{ 32 public: 33 /*! 34 @brief コンストラクタです。 35 */ 36 Transceiver(void); 37 38 /*! 39 @brief 解放します。 40 */ 41 ~Transceiver(void); 42 43 /*! 44 @brief 初期化します。 45 */ 46 #ifdef _WIN32 47 nn::Result Initialize(SOCKET sock); 48 #elif defined(NN_PLATFORM_CTR) 49 nn::Result Initialize(u16 nodeId, u8 port); // 送信先のノードIDとポート番号 50 #else 51 #error no platform selected 52 #endif 53 54 /*! 55 @brief 解放します。 56 */ 57 void Finalize(void); 58 59 /*! 60 @brief セグメントの送信を行います 61 返値がvoidなのは、「この関数の動作は絶対に成功する」 62 という意味ではない。そもそもパケロスがが起こりうる環境であれば、 63 いずれにせよ後でACKによるケアをしなければならないので、 64 ここで成功/失敗を気にかけることはあまり意味がないように思えたため。 65 ↑方針転換。UDSのエラーコードをケアしたくなったので、返値を取れるようにする。 66 */ 67 nn::Result Put(const Segment &seg); 68 69 /*! 70 @brief セグメントを受信します。 71 */ 72 nn::Result Pull(Segment *pSeg); 73 74 /*! 75 @brief CUnitを用いた単体テストです。 76 */ 77 static void Test(void); 78 79 private: 80 /*! 81 @brief コピーコンストラクタは封印します。 82 */ 83 Transceiver (const Transceiver&); 84 85 /*! 86 @brief 代入演算子は封印します。 87 */ 88 Transceiver& operator=(const Transceiver&); 89 90 bool m_initialized; 91 u8 m_padding1[3]; 92 #ifdef _WIN32 93 SOCKET m_sock; 94 #elif defined(NN_PLATFORM_CTR) 95 nn::uds::EndpointDescriptor m_sendEp; 96 nn::uds::EndpointDescriptor m_recvEp; 97 u16 m_remoteNodeId; // 通信相手のノードID 98 u8 m_port; 99 u8 m_padding2[1]; 100 #else 101 #error no platform selected 102 #endif 103 }; 104 105 }}} // namespace nn::rdt::CTR 106 107 #endif // end of NN_RDT_TRANSCEIVER_H_ 108