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));
static std::set< std::string > listRegistered()
Get registered protocol factory ids.
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)
FaceSystem(FaceTable &faceTable, shared_ptr< ndn::net::NetworkMonitor > netmon)
std::set< const ProtocolFactory * > listProtocolFactories() const
#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
context for processing a config section in ProtocolFactory
static unique_ptr< ProtocolFactory > create(const std::string &id, const CtorParams ¶ms)
Create a protocol factory instance.
virtual void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)=0
Process face_system subsection that corresponds to this ProtocolFactory type.
#define NFD_LOG_INIT(name)
const std::set< std::string > & getProvidedSchemes()
Get FaceUri schemes accepted by this ProtocolFactory.