lokinet/llarp/tooling/hive_context.hpp

29 lines
741 B
C++
Raw Normal View History

#pragma once
#include <llarp.hpp>
#include "hive_router.hpp"
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
{
HiveContext(RouterHive* hive);
2021-02-02 18:16:34 +00:00
std::shared_ptr<llarp::AbstractRouter>
2021-03-02 22:49:25 +00:00
makeRouter(const llarp::EventLoop_ptr& loop) override;
/// 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;
};
} // namespace tooling