28 #include <boost/range/adaptor/map.hpp> 29 #include <boost/range/algorithm/copy.hpp> 34 ProtocolFactory::Registry&
35 ProtocolFactory::getRegistry()
37 static Registry registry;
41 unique_ptr<ProtocolFactory>
44 Registry& registry = getRegistry();
45 auto found = registry.find(
id);
46 if (
found == registry.end()) {
50 return found->second(params);
56 std::set<std::string> factoryIds;
57 boost::copy(getRegistry() | boost::adaptors::map_keys,
58 std::inserter(factoryIds, factoryIds.end()));
66 BOOST_ASSERT(
addFace !=
nullptr);
67 BOOST_ASSERT(
netmon !=
nullptr);
76 doProcessConfig(configSection, context);
94 doCreateFace(req, onCreated, onFailure);
102 onFailure(406,
"Unsupported protocol");
107 const shared_ptr<const ndn::net::NetworkInterface>& netif)
110 return doCreateNetdevBoundFace(remote, netif);
114 ProtocolFactory::doCreateNetdevBoundFace(
const FaceUri&,
115 const shared_ptr<const ndn::net::NetworkInterface>&)
117 NDN_THROW(
Error(
"This protocol factory does not support netdev-bound faces"));
120 std::vector<shared_ptr<const Channel>>
123 return doGetChannels();
126 std::vector<shared_ptr<const Channel>>
127 ProtocolFactory::doGetChannels()
const static std::set< std::string > listRegistered()
Get all registered protocol factory ids.
shared_ptr< ndn::net::NetworkMonitor > netmon
NetworkMonitor for listing available network interfaces and monitoring their changes.
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)
Process face_system subsection that corresponds to this protocol factory id.
std::vector< shared_ptr< const Channel > > getChannels() const
Get list of open channels (listening + non-listening)
static bool canCanonize(const std::string &scheme)
ProtocolFactory(const CtorParams ¶ms)
std::function< void(uint32_t status, const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when a face fails to be created.
boost::optional< const ConfigSection & > OptionalConfigSection
an optional config file section
shared_ptr< Face > createNetdevBoundFace(const FaceUri &remote, const shared_ptr< const ndn::net::NetworkInterface > &netdev)
Create a netdev-bound face.
FaceCreatedCallback addFace
callback when a new face is created
Copyright (c) 2011-2015 Regents of the University of California.
virtual ~ProtocolFactory()=0
Parameters to ProtocolFactory constructor.
represents the underlying protocol and address used by a Face
Base class for all exceptions thrown by ProtocolFactory subclasses.
context for processing a config section in ProtocolFactory
const std::string & getScheme() const
get scheme (protocol)
static unique_ptr< ProtocolFactory > create(const std::string &id, const CtorParams ¶ms)
Create a protocol factory instance.
Encapsulates a face creation request and all its parameters.
optional< FaceUri > localUri
std::function< void(const shared_ptr< Face > &)> FaceCreatedCallback
Prototype for the callback that is invoked when a face is created (in response to an incoming connect...
bool isCanonical() const
determine whether this FaceUri is in canonical form
void createFace(const CreateFaceRequest &req, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure)
Create a unicast face.