net: add NetworkMonitorStub
refs #4024
Change-Id: I20da6f3351f51667b045987dc07e88ba814a4456
diff --git a/src/net/network-monitor.cpp b/src/net/network-monitor.cpp
index c4a2e2e..a45ff57 100644
--- a/src/net/network-monitor.cpp
+++ b/src/net/network-monitor.cpp
@@ -27,21 +27,31 @@
#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS)
#include "detail/network-monitor-impl-osx.hpp"
+#define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplOsx
#elif defined(NDN_CXX_HAVE_RTNETLINK)
#include "detail/network-monitor-impl-rtnl.hpp"
+#define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplRtnl
#else
#include "detail/network-monitor-impl-noop.hpp"
+#define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplNoop
#endif
namespace ndn {
namespace net {
NetworkMonitor::NetworkMonitor(boost::asio::io_service& io)
- : m_impl(make_unique<Impl>(*this, io))
+ : NetworkMonitor(make_unique<NETWORK_MONITOR_IMPL_TYPE>(io))
{
}
-NetworkMonitor::~NetworkMonitor() = default;
+NetworkMonitor::NetworkMonitor(unique_ptr<NetworkMonitorImpl> impl)
+ : m_impl(std::move(impl))
+ , onEnumerationCompleted(m_impl->onEnumerationCompleted)
+ , onInterfaceAdded(m_impl->onInterfaceAdded)
+ , onInterfaceRemoved(m_impl->onInterfaceRemoved)
+ , onNetworkStateChanged(m_impl->onNetworkStateChanged)
+{
+}
uint32_t
NetworkMonitor::getCapabilities() const
@@ -49,17 +59,24 @@
return m_impl->getCapabilities();
}
-shared_ptr<NetworkInterface>
+shared_ptr<const NetworkInterface>
NetworkMonitor::getNetworkInterface(const std::string& ifname) const
{
return m_impl->getNetworkInterface(ifname);
}
-std::vector<shared_ptr<NetworkInterface>>
+std::vector<shared_ptr<const NetworkInterface>>
NetworkMonitor::listNetworkInterfaces() const
{
return m_impl->listNetworkInterfaces();
}
+shared_ptr<NetworkInterface>
+NetworkMonitorImpl::makeNetworkInterface()
+{
+ // cannot use make_shared because NetworkInterface constructor is private
+ return shared_ptr<NetworkInterface>(new NetworkInterface);
+}
+
} // namespace net
} // namespace ndn