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)
89 ConfigContext context;
90 context.isDryRun = isDryRun;
93 auto generalSection = configSection.get_child_optional(
"general");
95 for (
const auto& pair : *generalSection) {
96 const std::string& key = pair.first;
97 if (key ==
"enable_congestion_marking") {
101 BOOST_THROW_EXCEPTION(
ConfigFile::Error(
"Unrecognized option face_system.general." + key));
107 for (
const auto& pair : m_factories) {
108 const std::string& sectionName = pair.first;
109 ProtocolFactory* factory = pair.second.get();
111 std::set<std::string> oldProvidedSchemes = factory->getProvidedSchemes();
112 factory->processConfig(configSection.get_child_optional(sectionName), context);
115 for (
const std::string& scheme : factory->getProvidedSchemes()) {
116 m_factoryByScheme[scheme] = factory;
117 if (oldProvidedSchemes.erase(scheme) == 0) {
119 " provides " << scheme <<
" FaceUri scheme");
122 for (
const std::string& scheme : oldProvidedSchemes) {
123 m_factoryByScheme.erase(scheme);
125 " no longer provides " << scheme <<
" FaceUri scheme");
131 std::set<std::string> seenSections;
132 for (
const auto& pair : configSection) {
133 const std::string& sectionName = pair.first;
136 if (!seenSections.insert(sectionName).second) {
137 BOOST_THROW_EXCEPTION(ConfigFile::Error(
"Duplicate section face_system." + sectionName));
140 if (sectionName ==
"general" || m_factories.count(sectionName) > 0) {
146 BOOST_THROW_EXCEPTION(ConfigFile::Error(
"Unrecognized option face_system." + sectionName));
static std::set< std::string > listRegistered()
Get registered protocol factory ids.
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"
ProtocolFactory * getFactoryById(const std::string &id)
configuration file parsing utility
void add(shared_ptr< Face > face)
add a face
ProtocolFactory * getFactoryByScheme(const std::string &scheme)
std::set< const ProtocolFactory * > listProtocolFactories() const
FaceSystem(FaceTable &faceTable, shared_ptr< ndn::net::NetworkMonitor > netmon)
#define NFD_LOG_TRACE(expression)
Provides support for an underlying protocol.
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
static unique_ptr< ProtocolFactory > create(const std::string &id, const CtorParams ¶ms)
Create a protocol factory instance.
#define NFD_LOG_INIT(name)