26 #ifndef NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP 27 #define NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP 32 #include <boost/range/adaptor/map.hpp> 33 #include <boost/range/algorithm/copy.hpp> 34 #include <ndn-cxx/encoding/nfd-constants.hpp> 49 shared_ptr<ndn::net::NetworkMonitor>
netmon;
72 Registry& registry = getRegistry();
73 BOOST_ASSERT(registry.count(
id) == 0);
74 registry[id] = &make_unique<PF, const CtorParams&>;
80 static unique_ptr<ProtocolFactory>
81 create(
const std::string&
id,
const CtorParams& params);
85 static std::set<std::string>
91 class Error :
public std::runtime_error
96 :
std::runtime_error(what)
109 static const std::string&
126 const std::set<std::string>&
129 return providedSchemes;
158 virtual std::vector<shared_ptr<const Channel>>
159 getChannels()
const = 0;
165 template<
typename ChannelMap>
166 static std::vector<shared_ptr<const Channel>>
169 std::vector<shared_ptr<const Channel>> channels;
170 boost::copy(channelMap | boost::adaptors::map_values, std::back_inserter(channels));
175 using CreateFunc = std::function<unique_ptr<ProtocolFactory>(
const CtorParams&)>;
176 using Registry = std::map<std::string, CreateFunc>;
191 shared_ptr<ndn::net::NetworkMonitor>
netmon;
201 #define NFD_REGISTER_PROTOCOL_FACTORY(PF) \ 202 static class NfdAuto ## PF ## ProtocolFactoryRegistrationClass \ 205 NfdAuto ## PF ## ProtocolFactoryRegistrationClass() \ 207 ::nfd::face::ProtocolFactory::registerType<PF>(); \ 209 } g_nfdAuto ## PF ## ProtocolFactoryRegistrationVariable 211 #endif // NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP FaceCreatedCallback addFace
callback when a new face is created
std::set< std::string > providedSchemes
FaceUri schemes provided by this ProtocolFactory.
FaceCreatedCallback addFace
shared_ptr< ndn::net::NetworkMonitor > netmon
NetworkMonitor for listing available network interfaces and monitoring their changes.
static void registerType(const std::string &id=PF::getId())
Register a protocol factory type.
ndn::nfd::FacePersistency persistency
ndn::optional< FaceUri > localUri
context for processing a config section in ProtocolFactory
static std::vector< shared_ptr< const Channel > > getChannelsFromMap(const ChannelMap &channelMap)
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
boost::optional< const ConfigSection & > OptionalConfigSection
an optional config file section
Error(const std::string &what)
function< void(uint32_t status, const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when a face fails to be created.
Provides support for an underlying protocol.
Parameters to ProtocolFactory constructor.
shared_ptr< ndn::net::NetworkMonitor > netmon
const std::set< std::string > & getProvidedSchemes()
Get FaceUri schemes accepted by this ProtocolFactory.
Parameters to ProtocolFactory::createFace.
Base class for all exceptions thrown by ProtocolFactory subclasses.
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback that is invoked when a face is created (in response to an incoming connect...