26 #ifndef NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP
27 #define NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP
31 #include <ndn-cxx/encoding/nfd-constants.hpp>
32 #include <boost/range/adaptor/map.hpp>
33 #include <boost/range/algorithm/copy.hpp>
56 Registry& registry = getRegistry();
57 BOOST_ASSERT(registry.count(
id) == 0);
58 registry[id] = &make_unique<PF>;
64 static unique_ptr<ProtocolFactory>
65 create(
const std::string&
id);
69 static std::set<std::string>
76 class Error :
public std::runtime_error
81 :
std::runtime_error(what)
94 static const std::string&
110 BOOST_THROW_EXCEPTION(
Error(
"processConfig is not implemented"));
115 const std::set<std::string>&
136 ndn::nfd::FacePersistency persistency,
137 bool wantLocalFieldsEnabled,
141 virtual std::vector<shared_ptr<const Channel>>
145 template<
typename ChannelMap>
146 static std::vector<shared_ptr<const Channel>>
149 std::vector<shared_ptr<const Channel>> channels;
150 boost::copy(channelMap | boost::adaptors::map_values, std::back_inserter(channels));
155 typedef std::function<unique_ptr<ProtocolFactory>()> CreateFunc;
156 typedef std::map<std::string, CreateFunc> Registry;
177 #define NFD_REGISTER_PROTOCOL_FACTORY(PF) \
178 static class NfdAuto ## PF ## ProtocolFactoryRegistrationClass \
181 NfdAuto ## PF ## ProtocolFactoryRegistrationClass() \
183 ::nfd::face::ProtocolFactory::registerType<PF>(); \
185 } g_nfdAuto ## PF ## ProtocolFactoryRegistrationVariable
187 #endif // NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP
static std::set< std::string > listRegistered()
virtual ~ProtocolFactory()=default
std::set< std::string > providedSchemes
FaceUri schemes provided by this ProtocolFactory.
virtual std::vector< shared_ptr< const Channel > > getChannels() const =0
static void registerType(const std::string &id=PF::getId())
register a protocol factory type
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
static unique_ptr< ProtocolFactory > create(const std::string &id)
Error(const std::string &what)
virtual void createFace(const FaceUri &uri, ndn::nfd::FacePersistency persistency, bool wantLocalFieldsEnabled, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure)=0
Try to create Face using the supplied FaceUri.
virtual void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)
process face_system subsection that corresponds to this ProtocolFactory type
function< void(uint32_t status, const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when the face fails to be created.
provide support for an underlying protocol
const std::set< std::string > & getProvidedSchemes()
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback that is invoked when the face is created (as a response to incoming connec...
static const std::string & getId()
Base class for all exceptions thrown by protocol factories.