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>
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>&
156 virtual std::vector<shared_ptr<const Channel>>
163 template<
typename ChannelMap>
164 static std::vector<shared_ptr<const Channel>>
167 std::vector<shared_ptr<const Channel>> channels;
168 boost::copy(channelMap | boost::adaptors::map_values, std::back_inserter(channels));
173 using CreateFunc = std::function<unique_ptr<ProtocolFactory>(
const CtorParams&)>;
174 using Registry = std::map<std::string, CreateFunc>;
188 shared_ptr<ndn::net::NetworkMonitor>
netmon;
198 #define NFD_REGISTER_PROTOCOL_FACTORY(PF) \ 199 static class NfdAuto ## PF ## ProtocolFactoryRegistrationClass \ 202 NfdAuto ## PF ## ProtocolFactoryRegistrationClass() \ 204 ::nfd::face::ProtocolFactory::registerType<PF>(); \ 206 } g_nfdAuto ## PF ## ProtocolFactoryRegistrationVariable 208 #endif // NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP std::set< std::string > providedSchemes
FaceUri schemes provided by this ProtocolFactory.
FaceCreatedCallback addFace
static std::set< std::string > listRegistered()
Get registered protocol factory ids.
ProtocolFactoryCtorParams CtorParams
shared_ptr< ndn::net::NetworkMonitor > netmon
NetworkMonitor for listing available network interfaces and monitoring their changes.
virtual void createFace(const CreateFaceRequest &req, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure)=0
Try to create a unicast face using the supplied parameters.
virtual std::vector< shared_ptr< const Channel > > getChannels() const =0
static void registerType(const std::string &id=PF::getId())
Register a protocol factory type.
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
std::function< void(const shared_ptr< Face > &face)> FaceCreatedCallback
Prototype for the callback that is invoked when a face is created (in response to an incoming connect...
static const std::string & getId()
Get id for this ProtocolFactory.
shared_ptr< ndn::net::NetworkMonitor > netmon
FaceCreatedCallback addFace
callback when a new face is created
Parameters used to set Transport properties or LinkService options on a newly created face...
Provides support for an underlying protocol.
Copyright (c) 2011-2015 Regents of the University of California.
virtual ~ProtocolFactory()=default
Error(const std::string &what)
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
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
virtual void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)=0
Process face_system subsection that corresponds to this ProtocolFactory type.
static std::vector< shared_ptr< const Channel > > getChannelsFromMap(const ChannelMap &channelMap)
const std::set< std::string > & getProvidedSchemes()
Get FaceUri schemes accepted by this ProtocolFactory.