src: Small style corrections
Change-Id: I51d073e33f92c491667c2e3ac7ceab388db61a2e
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index 8949b42..0328ecd 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -35,7 +35,6 @@
#include "adjacent.hpp"
#include "utility/name-helper.hpp"
-
namespace nlsr {
using namespace std;
@@ -60,7 +59,7 @@
bool
ConfFileProcessor::load(istream& input)
{
- boost::property_tree::ptree pt;
+ ConfigSection pt;
bool ret = true;
try {
boost::property_tree::read_info(input, pt);
@@ -71,11 +70,10 @@
std::cerr << m_confFileName << std::endl;
return false;
}
- for (boost::property_tree::ptree::const_iterator tn = pt.begin();
+
+ for (ConfigSection::const_iterator tn = pt.begin();
tn != pt.end(); ++tn) {
- std::string section = tn->first;
- boost::property_tree::ptree SectionAttributeTree = tn ->second;
- ret = processSection(section, SectionAttributeTree);
+ ret = processSection(tn->first, tn->second);
if (ret == false) {
break;
}
@@ -84,49 +82,47 @@
}
bool
-ConfFileProcessor::processSection(const std::string& section,
- boost::property_tree::ptree SectionAttributeTree)
+ConfFileProcessor::processSection(const std::string& sectionName, const ConfigSection& section)
{
bool ret = true;
- if (section == "general")
+ if (sectionName == "general")
{
- ret = processConfSectionGeneral(SectionAttributeTree);
+ ret = processConfSectionGeneral(section);
}
- else if (section == "neighbors")
+ else if (sectionName == "neighbors")
{
- ret = processConfSectionNeighbors(SectionAttributeTree);
+ ret = processConfSectionNeighbors(section);
}
- else if (section == "hyperbolic")
+ else if (sectionName == "hyperbolic")
{
- ret = processConfSectionHyperbolic(SectionAttributeTree);
+ ret = processConfSectionHyperbolic(section);
}
- else if (section == "fib")
+ else if (sectionName == "fib")
{
- ret = processConfSectionFib(SectionAttributeTree);
+ ret = processConfSectionFib(section);
}
- else if (section == "advertising")
+ else if (sectionName == "advertising")
{
- ret = processConfSectionAdvertising(SectionAttributeTree);
+ ret = processConfSectionAdvertising(section);
}
- else if (section == "security")
+ else if (sectionName == "security")
{
- ret = processConfSectionSecurity(SectionAttributeTree);
+ ret = processConfSectionSecurity(section);
}
else
{
- std::cerr << "Wrong configuration Command: " << section << std::endl;
+ std::cerr << "Wrong configuration section: " << sectionName << std::endl;
}
return ret;
}
bool
-ConfFileProcessor::processConfSectionGeneral(boost::property_tree::ptree
- SectionAttributeTree)
+ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
{
try {
- std::string network = SectionAttributeTree.get<string>("network");
- std::string site = SectionAttributeTree.get<string>("site");
- std::string router = SectionAttributeTree.get<string>("router");
+ std::string network = section.get<string>("network");
+ std::string site = section.get<string>("site");
+ std::string router = section.get<string>("router");
ndn::Name networkName(network);
if (!networkName.empty()) {
m_nlsr.getConfParameter().setNetwork(networkName);
@@ -158,7 +154,7 @@
}
try {
- int32_t lsaRefreshTime = SectionAttributeTree.get<int32_t>("lsa-refresh-time");
+ int32_t lsaRefreshTime = section.get<int32_t>("lsa-refresh-time");
if (lsaRefreshTime >= LSA_REFRESH_TIME_MIN &&
lsaRefreshTime <= LSA_REFRESH_TIME_MAX) {
m_nlsr.getConfParameter().setLsaRefreshTime(lsaRefreshTime);
@@ -176,7 +172,7 @@
}
try {
- std::string logLevel = SectionAttributeTree.get<string>("log-level");
+ std::string logLevel = section.get<string>("log-level");
if ( boost::iequals(logLevel, "info") || boost::iequals(logLevel, "debug")) {
m_nlsr.getConfParameter().setLogLevel(logLevel);
}
@@ -192,7 +188,7 @@
}
try {
- std::string logDir = SectionAttributeTree.get<string>("log-dir");
+ std::string logDir = section.get<string>("log-dir");
if (boost::filesystem::exists(logDir)) {
if (boost::filesystem::is_directory(logDir)) {
std::string testFileName=logDir+"/test.log";
@@ -225,7 +221,7 @@
return false;
}
try {
- std::string seqDir = SectionAttributeTree.get<string>("seq-dir");
+ std::string seqDir = section.get<string>("seq-dir");
if (boost::filesystem::exists(seqDir)) {
if (boost::filesystem::is_directory(seqDir)) {
std::string testFileName=seqDir+"/test.seq";
@@ -262,11 +258,10 @@
}
bool
-ConfFileProcessor::processConfSectionNeighbors(boost::property_tree::ptree
- SectionAttributeTree)
+ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
{
try {
- int retrials = SectionAttributeTree.get<int>("hello-retries");
+ int retrials = section.get<int>("hello-retries");
if (retrials >= HELLO_RETRIES_MIN && retrials <= HELLO_RETRIES_MAX) {
m_nlsr.getConfParameter().setInterestRetryNumber(retrials);
}
@@ -282,7 +277,7 @@
return false;
}
try {
- int timeOut = SectionAttributeTree.get<int>("hello-timeout");
+ int timeOut = section.get<int>("hello-timeout");
if (timeOut >= HELLO_TIMEOUT_MIN && timeOut <= HELLO_TIMEOUT_MAX) {
m_nlsr.getConfParameter().setInterestResendTime(timeOut);
}
@@ -297,7 +292,7 @@
std::cerr << ex.what() << std::endl;
}
try {
- int interval = SectionAttributeTree.get<int>("hello-interval");
+ int interval = section.get<int>("hello-interval");
if (interval >= HELLO_INTERVAL_MIN && interval <= HELLO_INTERVAL_MAX) {
m_nlsr.getConfParameter().setInfoInterestInterval(interval);
}
@@ -311,13 +306,13 @@
catch (const std::exception& ex) {
std::cerr << ex.what() << std::endl;
}
- for (boost::property_tree::ptree::const_iterator tn =
- SectionAttributeTree.begin(); tn != SectionAttributeTree.end(); ++tn) {
+ for (ConfigSection::const_iterator tn =
+ section.begin(); tn != section.end(); ++tn) {
if (tn->first == "neighbor")
{
try {
- boost::property_tree::ptree CommandAttriTree = tn->second;
+ ConfigSection CommandAttriTree = tn->second;
std::string name = CommandAttriTree.get<std::string>("name");
std::string faceUri = CommandAttriTree.get<std::string>("face-uri");
double linkCost = CommandAttriTree.get<double>("link-cost",
@@ -342,12 +337,11 @@
}
bool
-ConfFileProcessor::processConfSectionHyperbolic(boost::property_tree::ptree
- SectionAttributeTree)
+ConfFileProcessor::processConfSectionHyperbolic(const ConfigSection& section)
{
std::string state;
try {
- state= SectionAttributeTree.get<string>("state","off");
+ state= section.get<string>("state","off");
if (boost::iequals(state, "off")) {
m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_OFF);
}
@@ -374,8 +368,8 @@
* in the network may use hyperbolic routing calculation for FIB generation.
* So each router need to advertise its hyperbolic coordinates in the network
*/
- double radius = SectionAttributeTree.get<double>("radius");
- double angle = SectionAttributeTree.get<double>("angle");
+ double radius = section.get<double>("radius");
+ double angle = section.get<double>("angle");
if (!m_nlsr.getConfParameter().setCorR(radius)) {
return false;
}
@@ -392,12 +386,11 @@
}
bool
-ConfFileProcessor::processConfSectionFib(boost::property_tree::ptree
- SectionAttributeTree)
+ConfFileProcessor::processConfSectionFib(const ConfigSection& section)
{
try {
int maxFacesPerPrefixNumber =
- SectionAttributeTree.get<int>("max-faces-per-prefix");
+ section.get<int>("max-faces-per-prefix");
if (maxFacesPerPrefixNumber >= MAX_FACES_PER_PREFIX_MIN &&
maxFacesPerPrefixNumber <= MAX_FACES_PER_PREFIX_MAX)
{
@@ -417,11 +410,10 @@
}
bool
-ConfFileProcessor::processConfSectionAdvertising(boost::property_tree::ptree
- SectionAttributeTree)
+ConfFileProcessor::processConfSectionAdvertising(const ConfigSection& section)
{
- for (boost::property_tree::ptree::const_iterator tn =
- SectionAttributeTree.begin(); tn != SectionAttributeTree.end(); ++tn) {
+ for (ConfigSection::const_iterator tn =
+ section.begin(); tn != section.end(); ++tn) {
if (tn->first == "prefix") {
try {
std::string prefix = tn->second.data();
@@ -444,7 +436,7 @@
}
bool
-ConfFileProcessor::processConfSectionSecurity(boost::property_tree::ptree section)
+ConfFileProcessor::processConfSectionSecurity(const ConfigSection& section)
{
ConfigSection::const_iterator it = section.begin();
@@ -483,4 +475,4 @@
return true;
}
-}//namespace NLSR
+} // namespace nlsr
diff --git a/src/conf-file-processor.hpp b/src/conf-file-processor.hpp
index cc715b0..8fbf8e7 100644
--- a/src/conf-file-processor.hpp
+++ b/src/conf-file-processor.hpp
@@ -45,34 +45,33 @@
processConfFile();
private:
+ typedef boost::property_tree::ptree ConfigSection;
+
bool
load(std::istream& input);
bool
- processSection(const std::string& section,
- boost::property_tree::ptree SectionAttributeTree);
+ processSection(const std::string& sectionName, const ConfigSection& section);
bool
- processConfSectionGeneral(boost::property_tree::ptree SectionAttributeTree);
+ processConfSectionGeneral(const ConfigSection& section);
bool
- processConfSectionNeighbors(boost::property_tree::ptree SectionAttributeTree);
+ processConfSectionNeighbors(const ConfigSection& section);
bool
- processConfSectionHyperbolic(boost::property_tree::ptree SectionAttributeTree);
+ processConfSectionHyperbolic(const ConfigSection& section);
bool
- processConfSectionFib(boost::property_tree::ptree SectionAttributeTree);
+ processConfSectionFib(const ConfigSection& section);
bool
- processConfSectionAdvertising(boost::property_tree::ptree SectionAttributeTree);
+ processConfSectionAdvertising(const ConfigSection& section);
bool
- processConfSectionSecurity(boost::property_tree::ptree SectionAttributeTree);
+ processConfSectionSecurity(const ConfigSection& section);
private:
- typedef boost::property_tree::ptree ConfigSection;
-
std::string m_confFileName;
Nlsr& m_nlsr;
};
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index c5aea44..55e8044 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -99,7 +99,7 @@
bool
Lsdb::installNameLsa(NameLsa& nlsa)
{
- ndn::time::seconds timeToExpire = ndn::time::seconds(m_lsaRefreshTime);
+ ndn::time::seconds timeToExpire = m_lsaRefreshTime;
NameLsa* chkNameLsa = findNameLsa(nlsa.getKey());
if (chkNameLsa == 0) {
addNameLsa(nlsa);
@@ -305,7 +305,7 @@
bool
Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
{
- ndn::time::seconds timeToExpire = ndn::time::seconds(m_lsaRefreshTime);
+ ndn::time::seconds timeToExpire = m_lsaRefreshTime;
CoordinateLsa* chkCorLsa = findCoordinateLsa(clsa.getKey());
if (chkCorLsa == 0) {
_LOG_DEBUG("New Coordinate LSA. Adding to LSDB");
@@ -511,7 +511,7 @@
bool
Lsdb::installAdjLsa(AdjLsa& alsa)
{
- ndn::time::seconds timeToExpire = ndn::time::seconds(m_lsaRefreshTime);
+ ndn::time::seconds timeToExpire = m_lsaRefreshTime;
AdjLsa* chkAdjLsa = findAdjLsa(alsa.getKey());
if (chkAdjLsa == 0) {
_LOG_DEBUG("New Adj LSA. Adding to LSDB");
@@ -614,7 +614,7 @@
void
Lsdb::setLsaRefreshTime(int lrt)
{
- m_lsaRefreshTime = lrt;
+ m_lsaRefreshTime = ndn::time::seconds(lrt);
}
void
@@ -644,7 +644,7 @@
// schedule refreshing event again
chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(chkNameLsa->getKey(),
chkNameLsa->getLsSeqNo(),
- ndn::time::seconds(m_lsaRefreshTime)));
+ m_lsaRefreshTime));
// publish routing update
//ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
//lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
@@ -683,7 +683,7 @@
// schedule refreshing event again
chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(chkAdjLsa->getKey(),
chkAdjLsa->getLsSeqNo(),
- ndn::time::seconds(m_lsaRefreshTime)));
+ m_lsaRefreshTime));
// publish routing update
//ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
//lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
@@ -726,7 +726,7 @@
chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(
chkCorLsa->getKey(),
chkCorLsa->getLsSeqNo(),
- ndn::time::seconds(m_lsaRefreshTime)));
+ m_lsaRefreshTime));
// publish routing update
//ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
//lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
@@ -1015,4 +1015,4 @@
return false;
}
-}//namespace nlsr
+} // namespace nlsr
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 64de8ec..6bfc849 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -218,7 +218,7 @@
std::list<AdjLsa> m_adjLsdb;
std::list<CoordinateLsa> m_corLsdb;
- int m_lsaRefreshTime;
+ ndn::time::seconds m_lsaRefreshTime;
std::string m_thisRouterPrefix;
};