diff --git a/src/ndn-traffic-server.cpp b/src/ndn-traffic-server.cpp index f4c9fea..ce2c2e3 100644 --- a/src/ndn-traffic-server.cpp +++ b/src/ndn-traffic-server.cpp @@ -28,9 +28,11 @@ #include #include +#include #include #include #include +#include #include #include @@ -39,14 +41,13 @@ #include #include #include -#include -using namespace ndn::time_literals; -using namespace std::string_literals; +using namespace std::chrono_literals; namespace ndntg { -namespace time = ndn::time; +using namespace ndn::time_literals; +using namespace std::string_literals; class NdnTrafficServer : boost::noncopyable { @@ -64,9 +65,9 @@ public: } void - setContentDelay(time::milliseconds delay) + setContentDelay(std::chrono::milliseconds delay) { - BOOST_ASSERT(delay >= 0_ms); + BOOST_ASSERT(delay >= 0ms); m_contentDelay = delay; } @@ -146,7 +147,7 @@ private: if (!m_name.empty()) { os << "Name=" << m_name << ", "; } - if (m_contentDelay >= 0_ms) { + if (m_contentDelay >= 0ms) { os << "ContentDelay=" << m_contentDelay.count() << ", "; } if (m_freshnessPeriod >= 0_ms) { @@ -180,10 +181,10 @@ private: m_name = value; } else if (parameter == "ContentDelay") { - m_contentDelay = time::milliseconds(std::stoul(value)); + m_contentDelay = std::chrono::milliseconds(std::stoul(value)); } else if (parameter == "FreshnessPeriod") { - m_freshnessPeriod = time::milliseconds(std::stoul(value)); + m_freshnessPeriod = ndn::time::milliseconds(std::stoul(value)); } else if (parameter == "ContentType") { m_contentType = std::stoul(value); @@ -212,8 +213,8 @@ private: public: std::string m_name; - time::milliseconds m_contentDelay = -1_ms; - time::milliseconds m_freshnessPeriod = -1_ms; + std::chrono::milliseconds m_contentDelay{-1}; + ndn::time::milliseconds m_freshnessPeriod{-1}; std::optional m_contentType; std::optional m_contentLength; std::string m_content; @@ -296,10 +297,10 @@ private: m_logger.log(logLine, true, false); } - if (pattern.m_contentDelay > 0_ms) - boost::this_thread::sleep_for(pattern.m_contentDelay); - if (m_contentDelay > 0_ms) - boost::this_thread::sleep_for(m_contentDelay); + if (pattern.m_contentDelay > 0ms) + std::this_thread::sleep_for(pattern.m_contentDelay); + if (m_contentDelay > 0ms) + std::this_thread::sleep_for(m_contentDelay); m_face.put(data); } @@ -344,7 +345,7 @@ private: std::string m_configurationFile; std::string m_timestampFormat; std::optional m_nMaximumInterests; - time::milliseconds m_contentDelay = 0_ms; + std::chrono::milliseconds m_contentDelay{0}; std::vector m_trafficPatterns; std::vector m_registeredPrefixes; @@ -381,7 +382,7 @@ main(int argc, char* argv[]) visibleOptions.add_options() ("help,h", "print this help message and exit") ("count,c", po::value(), "maximum number of Interests to respond to") - ("delay,d", po::value()->default_value(0), + ("delay,d", po::value()->default_value(0), "wait this amount of milliseconds before responding to each Interest") ("timestamp-format,t", po::value(×tampFormat), "format string for timestamp output") ("quiet,q", po::bool_switch(), "turn off logging of Interest reception and Data generation") @@ -434,8 +435,8 @@ main(int argc, char* argv[]) } if (vm.count("delay") > 0) { - ndn::time::milliseconds delay(vm["delay"].as()); - if (delay < 0_ms) { + std::chrono::milliseconds delay(vm["delay"].as()); + if (delay < 0ms) { std::cerr << "ERROR: the argument for option '--delay' cannot be negative\n"; return 2; } diff --git a/wscript b/wscript index e49a083..b2544c5 100644 --- a/wscript +++ b/wscript @@ -24,8 +24,7 @@ def configure(conf): conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.1', '--cflags', '--libs'], uselib_store='NDN_CXX', pkg_config_path=pkg_config_path) - boost_libs = ['date_time', 'filesystem', 'program_options', 'thread'] - conf.check_boost(lib=boost_libs, mt=True) + conf.check_boost(lib='date_time filesystem program_options', mt=True) conf.check_compiler_flags()