43 : m_faceTable(faceTable)
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;
98 processConfig(std::forward<decltype(args)>(args)...);
103 FaceSystem::processConfig(
const ConfigSection& configSection,
bool isDryRun,
const std::string&)
109 auto generalSection = configSection.get_child_optional(CFGSEC_GENERAL);
110 if (generalSection) {
111 for (
const auto& pair : *generalSection) {
112 const std::string& key = pair.first;
113 if (key ==
"enable_congestion_marking") {
123 for (
const auto& pair : m_factories) {
124 const std::string& sectionName = pair.first;
128 factory->
processConfig(configSection.get_child_optional(sectionName), context);
132 m_factoryByScheme[scheme] = factory;
133 if (oldProvidedSchemes.erase(scheme) == 0) {
135 " provides " << scheme <<
" FaceUri scheme");
138 for (
const std::string& scheme : oldProvidedSchemes) {
139 m_factoryByScheme.erase(scheme);
141 " no longer provides " << scheme <<
" FaceUri scheme");
147 auto netdevBoundSection = configSection.get_child_optional(CFGSEC_NETDEVBOUND);
148 m_netdevBound->processConfig(netdevBoundSection, context);
151 std::set<std::string> seenSections;
152 for (
const auto& pair : configSection) {
153 const std::string& sectionName = pair.first;
156 if (!seenSections.insert(sectionName).second) {
160 if (sectionName == CFGSEC_GENERAL || sectionName == CFGSEC_NETDEVBOUND ||
161 m_factories.count(sectionName) > 0) {
static std::set< std::string > listRegistered()
Get all registered protocol factory ids.
bool wantCongestionMarking
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"
const std::string CFGSEC_NETDEVBOUND
ProtocolFactory * getFactoryById(const std::string &id)
#define NFD_LOG_INIT(name)
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)
Process face_system subsection that corresponds to this protocol factory id.
GeneralConfig generalConfig
configuration file parsing utility
void add(shared_ptr< Face > face)
add a face
ProtocolFactory * getFactoryByScheme(const std::string &scheme)
entry point of the face system
std::set< const ProtocolFactory * > listProtocolFactories() const
FaceSystem(FaceTable &faceTable, shared_ptr< ndn::net::NetworkMonitor > netmon)
Provides support for an underlying protocol.
const std::string CFGSEC_FACESYSTEM
Copyright (c) 2011-2015 Regents of the University of California.
void addSectionHandler(const std::string §ionName, ConfigSectionHandler subscriber)
setup notification of configuration file sections
void setConfigFile(ConfigFile &configFile)
register handler for face_system section of NFD configuration file
Parameters to ProtocolFactory constructor.
boost::property_tree::ptree ConfigSection
a config file section
bool hasFactoryForScheme(const std::string &scheme) const
context for processing a config section in ProtocolFactory
const std::set< std::string > & getProvidedSchemes() const
Get FaceUri schemes accepted by this protocol factory.
static unique_ptr< ProtocolFactory > create(const std::string &id, const CtorParams ¶ms)
Create a protocol factory instance.
const std::string CFGSEC_GENERAL
const std::string CFGSEC_GENERAL_FQ