lokinet/llarp/link/factory.cpp

44 lines
901 B
C++
Raw Permalink Normal View History

#include "factory.hpp"
#include <llarp/iwp/iwp.hpp>
2019-08-07 16:33:29 +00:00
namespace llarp
{
LinkFactory::LinkType
LinkFactory::TypeFromName(std::string_view str)
2019-08-07 16:33:29 +00:00
{
if (str == "iwp")
2019-08-07 16:33:29 +00:00
return LinkType::eLinkIWP;
if (str == "mempipe")
2019-08-07 16:33:29 +00:00
return LinkType::eLinkMempipe;
return LinkType::eLinkUnknown;
}
std::string
LinkFactory::NameFromType(LinkFactory::LinkType tp)
{
switch (tp)
2019-08-07 16:33:29 +00:00
{
case LinkType::eLinkIWP:
return "iwp";
case LinkType::eLinkMempipe:
return "mempipe";
default:
return "unspec";
}
}
LinkFactory::Factory
LinkFactory::Obtain(LinkFactory::LinkType tp, bool permitInbound)
{
switch (tp)
2019-08-07 16:33:29 +00:00
{
2019-08-22 20:53:27 +00:00
case LinkType::eLinkIWP:
if (permitInbound)
2019-08-22 20:53:27 +00:00
return llarp::iwp::NewInboundLink;
return llarp::iwp::NewOutboundLink;
2019-08-07 16:33:29 +00:00
default:
return nullptr;
}
}
} // namespace llarp