⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rfid_tag_app.hpp

📁 RFID reader 语 tag 模拟器
💻 HPP
字号:
 #ifndef RFID_TAG_APP_H #define RFID_TAG_APP_H #include <algorithm> using namespace std; #include <boost/shared_ptr.hpp> #include "application_layer.hpp" #include "packet.hpp" #include "simulator.hpp" class RfidTagApp : public ApplicationLayer { public:    typedef boost::shared_ptr<RfidTagApp> RfidTagAppPtr;    static inline RfidTagAppPtr create(NodePtr node);    virtual inline RfidTagAppPtr thisRfidTagApp();    virtual inline ApplicationLayerPtr thisApplicationLayer();    virtual inline SimulationEndListenerPtr thisSimulationEndListener();    void startHandler();    void stopHandler();    bool getReplyToReads() const;    void setReplyToReads(bool replyToReads);    virtual void simulationEndHandler();    inline ostream& print(ostream& s) const; protected:    RfidTagApp(NodePtr node);    bool handleRecvdPacket(PacketPtr packet, t_uint sendingLayerIdx); private:    boost::weak_ptr<RfidTagApp> m_weakThis;    bool m_replyToReads;    void sendIdPacket(const NodeId& destination); }; typedef boost::shared_ptr<RfidTagApp> RfidTagAppPtr; // Inline Functions inline RfidTagAppPtr RfidTagApp::create(NodePtr node) {    RfidTagAppPtr p(new RfidTagApp(node));    p->m_weakThis = p;    // weakThis *must* be set before the this function is called.    Simulator::instance()->addSimulationEndListener(       p->thisSimulationEndListener());    return p; } inline RfidTagAppPtr RfidTagApp::thisRfidTagApp() {    RfidTagAppPtr p(m_weakThis);    return p; } inline ApplicationLayerPtr RfidTagApp::thisApplicationLayer() {    ApplicationLayerPtr p(m_weakThis);    return p; } inline SimulationEndListenerPtr RfidTagApp::thisSimulationEndListener() {    SimulationEndListenerPtr p(m_weakThis);    return p; } // Overloaded Operators // PacketData Subclass class RfidTagAppData : public PacketData { public:    typedef boost::shared_ptr<RfidTagAppData> RfidTagAppDataPtr;    enum Types {       Types_NoType,       Types_Reply    };    static inline RfidTagAppDataPtr create();    static inline RfidTagAppDataPtr create(const RfidTagAppData& rhs);    virtual inline t_uint getSizeInBytes() const;    void setTagId(const NodeId& nodeId);    NodeId getTagId() const;    inline void setType(Types type);    inline Types getType() const;    inline ostream& print(ostream& s) const; protected:    RfidTagAppData();    RfidTagAppData(const RfidTagAppData& rhs);    virtual PacketDataPtr clone() const; private:    static const t_uint m_nodeIdBytes = 12;    static const t_uint m_typeBytes = 1;    t_uchar m_nodeId[m_nodeIdBytes];    Types m_type; }; typedef boost::shared_ptr<RfidTagAppData> RfidTagAppDataPtr; // Inline Functions inline RfidTagAppDataPtr RfidTagAppData::create() {    RfidTagAppDataPtr p(new RfidTagAppData());    return p; } inline RfidTagAppDataPtr RfidTagAppData::create(const RfidTagAppData& rhs) {    RfidTagAppDataPtr p =       boost::dynamic_pointer_cast<RfidTagAppData>(rhs.clone());    // If the shared_ptr is empty, then the cast failed.    assert(p.get() != 0);    return p; } inline t_uint RfidTagAppData::getSizeInBytes() const {    return (m_nodeIdBytes + m_typeBytes); } inline void RfidTagAppData::setType(RfidTagAppData::Types type) {    m_type = type; } inline RfidTagAppData::Types RfidTagAppData::getType() const {    return m_type; } // Overloaded Operators inline ostream& operator<< (ostream& s,    const RfidTagAppData::Types& dataType) {    switch(dataType) {    case RfidTagAppData::Types_NoType:       s << "NO_TYPE";       break;    case RfidTagAppData::Types_Reply:       s << "REPLY";       break;    }    return s; } inline ostream& RfidTagAppData::print(ostream& s) const {    s << "type=" << m_type << ", " <<       "nodeId=" << NodeId(m_nodeId, m_nodeIdBytes);    return s; } #endif // RFID_TAG_APP_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -