rfid_tag_phy.hpp

00001 
00002 #ifndef RFID_TAG_PHY_H
00003 #define RFID_TAG_PHY_H
00004 
00005 #include <boost/shared_ptr.hpp>
00006 
00007 #include "physical_layer.hpp"
00008 #include "simulator.hpp"
00009 
00013 class RfidTagPhy : public PhysicalLayer {
00014 public:
00016    typedef boost::shared_ptr<RfidTagPhy> RfidTagPhyPtr;
00017 
00022    static inline RfidTagPhyPtr create(
00023       NodePtr node, WirelessChannelManagerPtr wirelessChannelManager);
00024    
00028    virtual ~RfidTagPhy();
00029 
00036    inline RfidTagPhyPtr thisRfidTagPhy();
00037 
00044    virtual inline PhysicalLayerPtr thisPhysicalLayer();
00045 
00052    virtual inline SimulationEndListenerPtr thisSimulationEndListener();
00053 
00057    virtual void simulationEndHandler();
00058 
00072    bool setSendingChannel(t_uint channelId);
00073 
00081    void resetSendingChannel();
00082 
00096    bool setAllListenersChannel(t_uint channelId);
00097 
00105    void resetAllListenersChannel();
00106 
00116    virtual void recvdErrorFreeSignal(
00117       WirelessCommSignalPtr signal, double recvdSignalStrength);
00118 
00119 protected:
00120 
00122    RfidTagPhy(NodePtr node, 
00123       WirelessChannelManagerPtr wirelessChannelManager);
00124 
00125 private:
00126 
00129    boost::weak_ptr<RfidTagPhy> m_weakThis;
00130 
00134    bool m_sendingChannelIsValid;
00135 
00139    t_uint m_sendingChannel;
00140 
00144    bool m_allListenersChannelIsValid;
00145 
00149    t_uint m_allListenersChannel;
00150 
00151 };
00152 typedef boost::shared_ptr<RfidTagPhy> RfidTagPhyPtr;
00153 typedef boost::shared_ptr<RfidTagPhy const> ConstRfidTagPhyPtr;
00154 
00156 // Inline Functions
00158 
00159 inline RfidTagPhyPtr RfidTagPhy::create(
00160    NodePtr node, WirelessChannelManagerPtr wirelessChannelManager)
00161 {
00162    RfidTagPhyPtr p(new RfidTagPhy(node, wirelessChannelManager));
00163    p->m_weakThis = p;
00164    // weakThis *must* be set before this* functions are called.
00165    Simulator::instance()->addSimulationEndListener(
00166       p->thisSimulationEndListener());
00167    return p;
00168 }
00169 
00170 inline RfidTagPhyPtr RfidTagPhy::thisRfidTagPhy()
00171 {
00172    RfidTagPhyPtr p(m_weakThis);
00173    return p;
00174 }
00175 
00176 inline PhysicalLayerPtr RfidTagPhy::thisPhysicalLayer()
00177 {
00178    PhysicalLayerPtr p(m_weakThis);
00179    return p;
00180 }
00181 
00182 inline SimulationEndListenerPtr RfidTagPhy::thisSimulationEndListener()
00183 {
00184    SimulationEndListenerPtr p(m_weakThis);
00185    return p;
00186 }
00187 
00189 // Overloaded Operators
00191 
00192 #endif // RFID_TAG_PHY_H
00193 

Generated on Tue Dec 12 17:04:38 2006 for rfidsim by  doxygen 1.4.7