34 : m_forwarder(forwarder)
35 , m_isConfigured(false)
43 processConfig(std::forward<decltype(args)>(args)...);
58 m_isConfigured =
true;
62 TablesConfigSection::processConfig(
const ConfigSection& section,
bool isDryRun,
const std::string&)
66 if (csMaxPacketsNode) {
67 nCsMaxPackets = ConfigFile::parseNumber<size_t>(*csMaxPacketsNode,
"cs_max_packets",
"tables");
70 unique_ptr<cs::Policy> csPolicy;
73 std::string policyName = csPolicyNode->get_value<std::string>();
75 if (csPolicy ==
nullptr) {
80 unique_ptr<fw::UnsolicitedDataPolicy> unsolicitedDataPolicy;
81 OptionalConfigSection unsolicitedDataPolicyNode = section.get_child_optional(
"cs_unsolicited_policy");
82 if (unsolicitedDataPolicyNode) {
83 std::string policyName = unsolicitedDataPolicyNode->get_value<std::string>();
85 if (unsolicitedDataPolicy ==
nullptr) {
90 unsolicitedDataPolicy = make_unique<fw::DefaultUnsolicitedDataPolicy>();
94 if (strategyChoiceSection) {
95 processStrategyChoiceSection(*strategyChoiceSection, isDryRun);
99 if (networkRegionSection) {
100 processNetworkRegionSection(*networkRegionSection, isDryRun);
109 if (cs.
size() == 0 && csPolicy !=
nullptr) {
115 m_isConfigured =
true;
119 TablesConfigSection::processStrategyChoiceSection(
const ConfigSection& section,
bool isDryRun)
123 std::map<Name, Name> choices;
124 for (
const auto& prefixAndStrategy : section) {
125 Name prefix(prefixAndStrategy.first);
126 Name strategy(prefixAndStrategy.second.get_value<std::string>());
128 if (!Strategy::canCreate(strategy)) {
130 "Unknown strategy '" + prefixAndStrategy.second.get_value<std::string>() +
131 "' for prefix '" + prefix.
toUri() +
"' in section 'strategy_choice'"));
134 if (!choices.emplace(prefix, strategy).second) {
136 "Duplicate strategy choice for prefix '" + prefix.
toUri() +
"' in section 'strategy_choice'"));
145 for (
const auto& prefixAndStrategy : choices) {
146 if (!sc.
insert(prefixAndStrategy.first, prefixAndStrategy.second)) {
148 "Failed to set strategy '" + prefixAndStrategy.second.toUri() +
"' for prefix '" +
149 prefixAndStrategy.first.toUri() +
"' in section 'strategy_choice'"));
156 TablesConfigSection::processNetworkRegionSection(
const ConfigSection& section,
bool isDryRun)
164 for (
const auto& pair : section) {
165 nrt.insert(
Name(pair.first));
static unique_ptr< Policy > create(const std::string &policyName)
configuration file parsing utility
Main class of NFD's forwarding engine.
void ensureConfigured()
apply default configuration, if tables section was omitted in configuration file
StrategyChoice & getStrategyChoice()
boost::optional< const ConfigSection & > OptionalConfigSection
an optional config file section
InsertResult insert(const Name &prefix, const Name &strategyName)
Set strategy of prefix to be strategyName.
size_t size() const
get number of stored packets
Copyright (c) 2011-2015 Regents of the University of California.
void addSectionHandler(const std::string §ionName, ConfigSectionHandler subscriber)
setup notification of configuration file sections
static unique_ptr< UnsolicitedDataPolicy > create(const std::string &policyName)
void setPolicy(unique_ptr< Policy > policy)
change replacement policy
void setLimit(size_t nMaxPackets)
change capacity (in number of packets)
boost::property_tree::ptree ConfigSection
a config file section
Represents an absolute name.
implements the Content Store
Represents the Strategy Choice table.
NetworkRegionTable & getNetworkRegionTable()
const size_t DEFAULT_CS_MAX_PACKETS
void toUri(std::ostream &os, name::UriFormat format=name::UriFormat::DEFAULT) const
Write URI representation of the name to the output stream.
void setConfigFile(ConfigFile &configFile)
void setUnsolicitedDataPolicy(unique_ptr< fw::UnsolicitedDataPolicy > policy)
TablesConfigSection(Forwarder &forwarder)