wireless_channel_manager.hpp

00001 
00002 #ifndef CHANNEL_MANAGER_H
00003 #define CHANNEL_MANAGER_H
00004 
00005 #include <map>
00006 #include <set>
00007 using namespace std;
00008 #include <boost/shared_ptr.hpp>
00009 #include <boost/enable_shared_from_this.hpp>
00010 #include <boost/utility.hpp>
00011 
00012 #include "utility.hpp"
00013 
00014 class WirelessChannel;
00015 typedef boost::shared_ptr<WirelessChannel> WirelessChannelPtr;
00016 class PhysicalLayer;
00017 typedef boost::shared_ptr<PhysicalLayer> PhysicalLayerPtr;
00018 typedef boost::shared_ptr<PhysicalLayer const> ConstPhysicalLayerPtr;
00019 class WirelessCommSignal;
00020 typedef boost::shared_ptr<WirelessCommSignal> WirelessCommSignalPtr;
00021 class Simulator;
00022 typedef Simulator* SimulatorPtr;
00023 class SignalListeners;
00024 typedef boost::shared_ptr<SignalListeners> SignalListenersPtr;
00025 class ListenerSignals;
00026 typedef boost::shared_ptr<ListenerSignals> ListenerSignalsPtr;
00027 
00028 typedef map<t_uint,WirelessChannelPtr> ChannelIdMap;
00029 typedef multimap<WirelessChannelPtr,PhysicalLayerPtr> ChannelObserver;
00030 typedef multimap<PhysicalLayerPtr,WirelessChannelPtr> SenderChannel;
00031 
00036 class WirelessChannelManager : boost::noncopyable,
00037    public boost::enable_shared_from_this<WirelessChannelManager> {
00038 public:
00040    typedef boost::shared_ptr<WirelessChannelManager> 
00041       WirelessChannelManagerPtr;
00042 
00047    static inline WirelessChannelManagerPtr create();
00048    
00055    void recvSignal(PhysicalLayerPtr sender, 
00056       WirelessCommSignalPtr signal);
00057 
00065    void passSignalToReceiver(PhysicalLayerPtr receiver, 
00066       WirelessCommSignalPtr signal) const;
00067 
00076    bool attachAsSender(PhysicalLayerPtr physicalLayer, t_uint channelId);
00077 
00086    bool attachAsListener(PhysicalLayerPtr physicalLayer, t_uint channelId);
00087 
00096    bool detachAsSender(PhysicalLayerPtr physicalLayer, t_uint channelId);
00097 
00106    bool detachAsListener(PhysicalLayerPtr physicalLayer, t_uint channelId);
00107 
00115    void addChannel(t_uint channelId, WirelessChannelPtr channel);
00116 
00122    bool removeChannel(t_uint channelId);
00123 
00124 protected:
00125 
00127    WirelessChannelManager();
00128 
00129 private:
00130 
00132    static const bool m_DEBUG_SIGNAL_STRENGTH = false;
00133 
00135    ChannelIdMap m_channels;
00136 
00138    ChannelObserver m_listeners;
00139 
00142    SenderChannel m_senders;
00143 
00152    void sendSignalOnChannel(ConstPhysicalLayerPtr sender, 
00153       WirelessCommSignalPtr signal, WirelessChannelPtr channel);
00154 
00163    t_uint getChannelId(WirelessChannelPtr channel) const;
00164 
00165 };
00166 typedef boost::shared_ptr<WirelessChannelManager> 
00167    WirelessChannelManagerPtr;
00168 typedef boost::shared_ptr<WirelessChannelManager const> 
00169    ConstWirelessChannelManagerPtr;
00170 
00172 // Inline Functions
00174 
00175 inline WirelessChannelManagerPtr WirelessChannelManager::create()
00176 {
00177    WirelessChannelManagerPtr p(new WirelessChannelManager());
00178    return p;
00179 }
00180 
00182 // Overloaded Operators
00184 
00185 #endif // CHANNEL_MANAGER_H
00186 

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