|
IBR-DTNSuite 0.6
|
00001 /* 00002 * LinkManager.h 00003 * 00004 * Created on: 21.12.2010 00005 * Author: morgenro 00006 */ 00007 00008 #ifndef LINKMANAGER_H_ 00009 #define LINKMANAGER_H_ 00010 00011 #include "ibrcommon/net/vinterface.h" 00012 #include "ibrcommon/net/vaddress.h" 00013 #include <string> 00014 00015 namespace ibrcommon 00016 { 00017 class LinkManagerEvent 00018 { 00019 public: 00020 enum EventType 00021 { 00022 EVENT_UNKOWN, 00023 EVENT_LINK_STATE, 00024 EVENT_ADDRESS_REMOVED, 00025 EVENT_ADDRESS_ADDED 00026 }; 00027 00028 virtual ~LinkManagerEvent() {}; 00029 00030 virtual const ibrcommon::vinterface& getInterface() const = 0; 00031 virtual const ibrcommon::vaddress& getAddress() const = 0; 00032 virtual unsigned int getState() const = 0; 00033 virtual EventType getType() const = 0; 00034 }; 00035 00036 class LinkManager 00037 { 00038 public: 00039 class EventCallback 00040 { 00041 public: 00042 virtual ~EventCallback() {}; 00043 virtual void eventNotify(const LinkManagerEvent&) = 0; 00044 }; 00045 00046 virtual ~LinkManager() {}; 00047 00048 virtual const std::string getInterface(int index) const = 0; 00049 virtual const std::list<vaddress> getAddressList(const vinterface &iface, const vaddress::Family f) = 0; 00050 00051 virtual void registerInterfaceEvent(const vinterface&, LinkManager::EventCallback*) { }; 00052 virtual void unregisterInterfaceEvent(const vinterface&, LinkManager::EventCallback*) { }; 00053 virtual void unregisterAllEvents(LinkManager::EventCallback*) { }; 00054 00055 static LinkManager& getInstance(); 00056 static void initialize(); 00057 }; 00058 00059 class DefaultLinkManager : public LinkManager 00060 { 00061 public: 00062 DefaultLinkManager(); 00063 virtual ~DefaultLinkManager(); 00064 00065 const std::string getInterface(int index) const; 00066 const std::list<vaddress> getAddressList(const vinterface &iface, const vaddress::Family f); 00067 }; 00068 } 00069 00070 #endif /* LINKMANAGER_H_ */