42 : m_faceTable(faceTable)
43 , m_netmon(std::move(netmon))
45 auto pfCtorParams = this->makePFCtorParams();
51 m_netdevBound = make_unique<NetdevBound>(pfCtorParams, *
this);
55 FaceSystem::makePFCtorParams()
57 auto addFace = [
this] (
auto face) { m_faceTable.
add(std::move(face)); };
58 return {addFace, m_netmon};
63 std::set<const ProtocolFactory*>
66 std::set<const ProtocolFactory*> factories;
67 for (
const auto& p : m_factories) {
68 factories.insert(p.second.get());
76 auto found = m_factories.find(
id);
77 return found == m_factories.end() ? nullptr : found->second.get();
83 auto found = m_factoryByScheme.find(scheme);
84 return found == m_factoryByScheme.end() ? nullptr : found->second;
90 return m_factoryByScheme.count(scheme) > 0;
97 processConfig(std::forward<decltype(args)>(args)...);
102 FaceSystem::processConfig(
const ConfigSection& configSection,
bool isDryRun,
const std::string&)
104 ConfigContext context;
105 context.isDryRun = isDryRun;
108 auto generalSection = configSection.get_child_optional(
CFGSEC_GENERAL);
109 if (generalSection) {
110 for (
const auto& pair : *generalSection) {
111 const std::string& key = pair.first;
112 if (key ==
"enable_congestion_marking") {
122 for (
const auto& [sectionName, factory] : m_factories) {
123 std::set<std::string> oldProvidedSchemes = factory->getProvidedSchemes();
124 factory->processConfig(configSection.get_child_optional(sectionName), context);
127 for (
const auto& scheme : factory->getProvidedSchemes()) {
128 m_factoryByScheme[scheme] = factory.get();
129 if (oldProvidedSchemes.erase(scheme) == 0) {
131 " provides " << scheme <<
" FaceUri scheme");
134 for (
const auto& scheme : oldProvidedSchemes) {
135 m_factoryByScheme.erase(scheme);
137 " no longer provides " << scheme <<
" FaceUri scheme");
144 m_netdevBound->processConfig(netdevBoundSection, context);
147 std::set<std::string> seenSections;
148 for (
const auto& pair : configSection) {
149 const std::string& sectionName = pair.first;
152 if (!seenSections.insert(sectionName).second) {
153 NDN_THROW(ConfigFile::Error(
"Duplicate section " +
CFGSEC_FACESYSTEM +
"." + sectionName));
157 m_factories.count(sectionName) > 0) {
161 NDN_THROW(ConfigFile::Error(
"Unrecognized option " +
CFGSEC_FACESYSTEM +
"." + sectionName));
Configuration file parsing utility.
void addSectionHandler(const std::string §ionName, ConfigSectionHandler subscriber)
Setup notification of configuration file sections.
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".
void add(shared_ptr< Face > face)
Add a face.
std::set< const ProtocolFactory * > listProtocolFactories() const
Returns all ProtocolFactory objects owned by the face system.
FaceSystem(FaceTable &faceTable, shared_ptr< ndn::net::NetworkMonitor > netmon)
bool hasFactoryForScheme(const std::string &scheme) const
void setConfigFile(ConfigFile &configFile)
Register handler for the face_system section of NFD's configuration file.
ProtocolFactory * getFactoryById(const std::string &id)
ProtocolFactory * getFactoryByScheme(const std::string &scheme)
Provides support for an underlying protocol.
static std::set< std::string > listRegistered()
Get all registered protocol factory IDs.
static unique_ptr< ProtocolFactory > create(const std::string &id, const CtorParams ¶ms)
Create a protocol factory instance.
#define NFD_LOG_INIT(name)
const std::string CFGSEC_FACESYSTEM
const std::string CFGSEC_GENERAL
const std::string CFGSEC_GENERAL_FQ
const std::string CFGSEC_NETDEVBOUND
boost::property_tree::ptree ConfigSection
A configuration file section.
Parameters to ProtocolFactory constructor.