lokinet/llarp/tooling/hive_context.cpp
2021-02-02 13:16:34 -05:00

31 lines
721 B
C++

#include <tooling/hive_context.hpp>
#include <tooling/hive_router.hpp>
namespace tooling
{
HiveContext::HiveContext(RouterHive* hive) : m_hive(hive)
{}
std::shared_ptr<llarp::AbstractRouter>
HiveContext::makeRouter(llarp_ev_loop_ptr netloop, std::shared_ptr<llarp::Logic> logic)
{
return std::make_shared<HiveRouter>(netloop, logic, makeVPNPlatform(), m_hive);
}
HiveRouter*
HiveContext::getRouterAsHiveRouter()
{
if (not router)
return nullptr;
HiveRouter* hiveRouter = dynamic_cast<HiveRouter*>(router.get());
if (hiveRouter == nullptr)
throw std::runtime_error("HiveContext has a router not of type HiveRouter");
return hiveRouter;
}
} // namespace tooling