43 : m_faceTable(faceTable)
44 , m_netmon(
std::move(netmon))
46 auto pfCtorParams = this->makePFCtorParams();
52 m_netdevBound = make_unique<NetdevBound>(pfCtorParams, *
this);
56 FaceSystem::makePFCtorParams()
58 auto addFace = [
this] (
auto face) { m_faceTable.
add(std::move(face)); };
59 return {addFace, m_netmon};
64 std::set<const ProtocolFactory*>
67 std::set<const ProtocolFactory*> factories;
68 for (
const auto& p : m_factories) {
69 factories.insert(p.second.get());
77 auto found = m_factories.find(
id);
78 return found == m_factories.end() ? nullptr : found->second.get();
84 auto found = m_factoryByScheme.find(scheme);
85 return found == m_factoryByScheme.end() ? nullptr : found->second;
91 return m_factoryByScheme.count(scheme) > 0;
97 configFile.
addSectionHandler(CFGSEC_FACESYSTEM, bind(&FaceSystem::processConfig,
this, _1, _2, _3));
101 FaceSystem::processConfig(
const ConfigSection& configSection,
bool isDryRun,
const std::string&)
107 auto generalSection = configSection.get_child_optional(CFGSEC_GENERAL);
108 if (generalSection) {
109 for (
const auto& pair : *generalSection) {
110 const std::string& key = pair.first;
111 if (key ==
"enable_congestion_marking") {
115 NDN_THROW(
ConfigFile::Error(
"Unrecognized option " + CFGSEC_GENERAL_FQ +
"." + key));
121 for (
const auto& pair : m_factories) {
122 const std::string& sectionName = pair.first;
126 factory->
processConfig(configSection.get_child_optional(sectionName), context);
130 m_factoryByScheme[scheme] = factory;
131 if (oldProvidedSchemes.erase(scheme) == 0) {
133 " provides " << scheme <<
" FaceUri scheme");
136 for (
const std::string& scheme : oldProvidedSchemes) {
137 m_factoryByScheme.erase(scheme);
139 " no longer provides " << scheme <<
" FaceUri scheme");
145 auto netdevBoundSection = configSection.get_child_optional(CFGSEC_NETDEVBOUND);
146 m_netdevBound->processConfig(netdevBoundSection, context);
149 std::set<std::string> seenSections;
150 for (
const auto& pair : configSection) {
151 const std::string& sectionName = pair.first;
154 if (!seenSections.insert(sectionName).second) {
155 NDN_THROW(
ConfigFile::Error(
"Duplicate section " + CFGSEC_FACESYSTEM +
"." + sectionName));
158 if (sectionName == CFGSEC_GENERAL || sectionName == CFGSEC_NETDEVBOUND ||
159 m_factories.count(sectionName) > 0) {
163 NDN_THROW(
ConfigFile::Error(
"Unrecognized option " + CFGSEC_FACESYSTEM +
"." + sectionName));
void addSectionHandler(const std::string §ionName, ConfigSectionHandler subscriber)
setup notification of configuration file sections
static std::set< std::string > listRegistered()
Get all registered protocol factory ids.
const std::string CFGSEC_NETDEVBOUND
FaceSystem(FaceTable &faceTable, shared_ptr< ndn::net::NetworkMonitor > netmon)
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)
Process face_system subsection that corresponds to this protocol factory id.
configuration file parsing utility
bool hasFactoryForScheme(const std::string &scheme) const
ProtocolFactory * getFactoryByScheme(const std::string &scheme)
void setConfigFile(ConfigFile &configFile)
register handler for face_system section of NFD configuration file
static bool parseYesNo(const ConfigSection &node, const std::string &key, const std::string §ionName)
parse a config option that can be either "yes" or "no"
std::set< const ProtocolFactory * > listProtocolFactories() const
context for processing a config section in ProtocolFactory
boost::property_tree::ptree ConfigSection
a config file section
const std::string CFGSEC_FACESYSTEM
void add(shared_ptr< Face > face)
add a face
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
GeneralConfig generalConfig
const std::set< std::string > & getProvidedSchemes() const
Get FaceUri schemes accepted by this protocol factory.
Provides support for an underlying protocol.
Parameters to ProtocolFactory constructor.
#define NFD_LOG_INIT(name)
bool wantCongestionMarking
ProtocolFactory * getFactoryById(const std::string &id)
const std::string CFGSEC_GENERAL
static unique_ptr< ProtocolFactory > create(const std::string &id, const CtorParams ¶ms)
Create a protocol factory instance.
const std::string CFGSEC_GENERAL_FQ