2020-06-29 15:44:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <llarp.hpp>
|
2020-07-01 19:46:52 +00:00
|
|
|
#include <tooling/hive_router.hpp>
|
2020-06-29 15:44:13 +00:00
|
|
|
|
|
|
|
namespace tooling
|
|
|
|
{
|
|
|
|
/// HiveContext is a subclass of llarp::Context which allows RouterHive to
|
|
|
|
/// perform custom behavior which might be undesirable in production code.
|
|
|
|
struct HiveContext : public llarp::Context
|
|
|
|
{
|
2020-07-01 19:46:52 +00:00
|
|
|
HiveContext(RouterHive* hive);
|
|
|
|
|
2020-06-29 15:44:13 +00:00
|
|
|
std::unique_ptr<llarp::AbstractRouter>
|
|
|
|
makeRouter(
|
|
|
|
llarp_ev_loop_ptr netloop,
|
|
|
|
std::shared_ptr<llarp::Logic> logic) override;
|
2020-07-01 19:46:52 +00:00
|
|
|
|
|
|
|
/// Get this context's router as a HiveRouter.
|
|
|
|
///
|
|
|
|
/// Returns nullptr if there is no router or throws an exception if the
|
|
|
|
/// router is somehow not an instance of HiveRouter.
|
|
|
|
HiveRouter*
|
|
|
|
getRouterAsHiveRouter();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
RouterHive* m_hive = nullptr;
|
2020-06-29 15:44:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace tooling
|