37 : m_faceTable(faceTable)
38 , m_netmon(
std::move(netmon))
40 auto pfCtorParams = this->makePFCtorParams();
48 FaceSystem::makePFCtorParams()
51 return {addFace, m_netmon};
56 std::set<const ProtocolFactory*>
59 std::set<const ProtocolFactory*> factories;
60 for (
const auto& p : m_factories) {
61 factories.insert(p.second.get());
69 auto found = m_factories.find(
id);
70 return found == m_factories.end() ?
nullptr : found->second.get();
76 auto found = m_factoryByScheme.find(scheme);
77 return found == m_factoryByScheme.end() ?
nullptr : found->second;
83 configFile.
addSectionHandler(
"face_system", bind(&FaceSystem::processConfig,
this, _1, _2, _3));
87 FaceSystem::processConfig(
const ConfigSection& configSection,
bool isDryRun,
const std::string& filename)
93 for (
const auto& pair : m_factories) {
94 const std::string& sectionName = pair.first;
98 factory->
processConfig(configSection.get_child_optional(sectionName), context);
102 m_factoryByScheme[scheme] = factory;
103 if (oldProvidedSchemes.erase(scheme) == 0) {
105 " provides " << scheme <<
" FaceUri scheme");
108 for (
const std::string& scheme : oldProvidedSchemes) {
109 m_factoryByScheme.erase(scheme);
111 " no longer provides " << scheme <<
" FaceUri scheme");
117 std::set<std::string> seenSections;
118 for (
const auto& pair : configSection) {
119 const std::string& sectionName = pair.first;
122 if (!seenSections.insert(sectionName).second) {
123 BOOST_THROW_EXCEPTION(
ConfigFile::Error(
"Duplicate section face_system." + sectionName));
126 if (m_factories.count(sectionName) > 0) {
132 BOOST_THROW_EXCEPTION(
ConfigFile::Error(
"Unrecognized option face_system." + sectionName));
void addSectionHandler(const std::string §ionName, ConfigSectionHandler subscriber)
setup notification of configuration file sections
static std::set< std::string > listRegistered()
Get registered protocol factory ids.
FaceSystem(FaceTable &faceTable, shared_ptr< ndn::net::NetworkMonitor > netmon)
configuration file parsing utility
ProtocolFactory * getFactoryByScheme(const std::string &scheme)
void setConfigFile(ConfigFile &configFile)
register handler for face_system section of NFD configuration file
context for processing a config section in ProtocolFactory
void add(shared_ptr< Face > face)
add a face
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
virtual void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)=0
Process face_system subsection that corresponds to this ProtocolFactory type.
boost::property_tree::ptree ConfigSection
a config file section
Provides support for an underlying protocol.
Parameters to ProtocolFactory constructor.
#define NFD_LOG_INIT(name)
#define NFD_LOG_TRACE(expression)
const std::set< std::string > & getProvidedSchemes()
Get FaceUri schemes accepted by this ProtocolFactory.
ProtocolFactory * getFactoryById(const std::string &id)
static unique_ptr< ProtocolFactory > create(const std::string &id, const CtorParams ¶ms)
Create a protocol factory instance.
std::set< const ProtocolFactory * > listProtocolFactories() const