37 : m_faceTable(faceTable)
47 std::set<const ProtocolFactory*>
50 std::set<const ProtocolFactory*> factories;
51 for (
const auto& p : m_factories) {
52 factories.insert(p.second.get());
60 auto found = m_factories.find(
id);
61 return found == m_factories.end() ?
nullptr : found->second.get();
67 auto found = m_factoryByScheme.find(scheme);
68 return found == m_factoryByScheme.end() ?
nullptr : found->second;
74 configFile.
addSectionHandler(
"face_system", bind(&FaceSystem::processConfig,
this, _1, _2, _3));
78 FaceSystem::processConfig(
const ConfigSection& configSection,
bool isDryRun,
const std::string& filename)
80 ConfigContext context;
81 context.isDryRun = isDryRun;
86 for (
const auto& pair : m_factories) {
87 const std::string& sectionName = pair.first;
91 factory->
processConfig(configSection.get_child_optional(sectionName), context);
95 m_factoryByScheme[scheme] = factory;
96 if (oldProvidedSchemes.erase(scheme) == 0) {
98 " provides " << scheme <<
" FaceUri scheme");
101 for (
const std::string& scheme : oldProvidedSchemes) {
102 m_factoryByScheme.erase(scheme);
104 " no longer provides " << scheme <<
" FaceUri scheme");
110 std::set<std::string> seenSections;
111 for (
const auto& pair : configSection) {
112 const std::string& sectionName = pair.first;
115 if (!seenSections.insert(sectionName).second) {
116 BOOST_THROW_EXCEPTION(ConfigFile::Error(
"Duplicate section face_system." + sectionName));
119 if (m_factories.count(sectionName) > 0) {
125 BOOST_THROW_EXCEPTION(ConfigFile::Error(
"Unrecognized option face_system." + sectionName));
void addSectionHandler(const std::string §ionName, ConfigSectionHandler subscriber)
setup notification of configuration file sections
static std::set< std::string > listRegistered()
configuration file parsing utility
ProtocolFactory * getFactoryByScheme(const std::string &scheme)
void setConfigFile(ConfigFile &configFile)
register handler for face_system section of NFD configuration file
std::vector< NetworkInterfaceInfo > listNetworkInterfaces()
List configured network interfaces on the system and their info.
void add(shared_ptr< Face > face)
add a face
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
static unique_ptr< ProtocolFactory > create(const std::string &id)
boost::property_tree::ptree ConfigSection
a config file section
virtual void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context)
process face_system subsection that corresponds to this ProtocolFactory type
provide support for an underlying protocol
#define NFD_LOG_INIT(name)
#define NFD_LOG_TRACE(expression)
const std::set< std::string > & getProvidedSchemes()
FaceSystem(FaceTable &faceTable)
ProtocolFactory * getFactoryById(const std::string &id)
std::set< const ProtocolFactory * > listProtocolFactories() const