26 #ifndef NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP
27 #define NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP
33 #include <boost/range/adaptor/map.hpp>
34 #include <boost/range/algorithm/copy.hpp>
54 shared_ptr<ndn::net::NetworkMonitor>
netmon;
80 BOOST_ASSERT(!
id.empty());
81 auto r = getRegistry().insert_or_assign(
id, [] (
auto&&... p) {
82 return make_unique<PF>(std::forward<decltype(p)>(p)...);
84 BOOST_VERIFY(r.second);
91 static unique_ptr<ProtocolFactory>
97 [[nodiscard]]
static std::set<std::string>
104 class Error :
public std::runtime_error
107 using std::runtime_error::runtime_error;
122 static const std::string&
129 const std::set<std::string>&
176 const shared_ptr<const ndn::net::NetworkInterface>& netdev);
180 std::vector<shared_ptr<const Channel>>
184 template<
typename ChannelMap>
185 static std::vector<shared_ptr<const Channel>>
188 std::vector<shared_ptr<const Channel>> channels;
189 boost::copy(channelMap | boost::adaptors::map_values, std::back_inserter(channels));
214 doCreateFace(
const CreateFaceRequest& req,
233 virtual shared_ptr<Face>
234 doCreateNetdevBoundFace(
const FaceUri& remote,
235 const shared_ptr<const ndn::net::NetworkInterface>& netif);
242 virtual std::vector<shared_ptr<const Channel>>
243 doGetChannels()
const;
246 using CreateFunc = std::function<unique_ptr<ProtocolFactory>(
const CtorParams&)>;
247 using Registry = std::map<std::string, CreateFunc>;
261 shared_ptr<ndn::net::NetworkMonitor>
netmon;
270 #define NFD_REGISTER_PROTOCOL_FACTORY(PF) \
271 static class NfdAuto ## PF ## ProtocolFactoryRegistrationClass \
274 NfdAuto ## PF ## ProtocolFactoryRegistrationClass() \
276 ::nfd::face::ProtocolFactory::registerType<PF>(); \
278 } g_nfdAuto ## PF ## ProtocolFactoryRegistrationVariable
Context for processing a config section in ProtocolFactory.
Base class for all exceptions thrown by ProtocolFactory subclasses.
Provides support for an underlying protocol.
shared_ptr< Face > createNetdevBoundFace(const FaceUri &remote, const shared_ptr< const ndn::net::NetworkInterface > &netdev)
Create a netdev-bound face.
ProtocolFactory(const CtorParams ¶ms)
static std::vector< shared_ptr< const Channel > > getChannelsFromMap(const ChannelMap &channelMap)
void createFace(const CreateFaceRequest &req, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure)
Create a unicast face.
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)
Process face_system subsection that corresponds to this protocol factory id.
std::set< std::string > providedSchemes
FaceUri schemes provided by this protocol factory.
FaceCreatedCallback addFace
callback when a new face is created
static const std::string & getId() noexcept
Get the ID of this protocol factory.
static std::set< std::string > listRegistered()
Get all registered protocol factory IDs.
ProtocolFactoryCtorParams CtorParams
shared_ptr< ndn::net::NetworkMonitor > netmon
NetworkMonitor for listing available network interfaces and monitoring their changes.
std::vector< shared_ptr< const Channel > > getChannels() const
Get list of open channels (listening + non-listening)
const std::set< std::string > & getProvidedSchemes() const noexcept
Get FaceUri schemes accepted by this protocol factory.
virtual ~ProtocolFactory()=0
static void registerType(const std::string &id=PF::getId())
Register a protocol factory type.
static unique_ptr< ProtocolFactory > create(const std::string &id, const CtorParams ¶ms)
Create a protocol factory instance.
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.
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...
boost::optional< const ConfigSection & > OptionalConfigSection
An optional configuration file section.
Parameters used to set Transport properties or LinkService options on a newly created face.
Encapsulates a face creation request and all its parameters.
std::optional< FaceUri > localUri
Parameters to ProtocolFactory constructor.
FaceCreatedCallback addFace
shared_ptr< ndn::net::NetworkMonitor > netmon