From a0e6b60e8f1c7f61097afc6c5371d0bf8f19c2cf Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Thu, 21 Jan 2021 19:47:04 -0500 Subject: [PATCH] Cleanup includes in common.hpp Change-Id: I1bb08a44726de5c880e6bc2f016506e6083e919b --- core/common.hpp | 10 +---- tests/chunks/producer.t.cpp | 40 +++++++++---------- tools/chunks/catchunks/consumer.hpp | 4 +- tools/chunks/catchunks/discover-version.hpp | 24 +++++------ tools/chunks/catchunks/main.cpp | 6 ++- .../catchunks/pipeline-interests-adaptive.hpp | 7 ++-- tools/chunks/catchunks/pipeline-interests.cpp | 4 +- tools/chunks/putchunks/main.cpp | 8 +++- tools/dissect/main.cpp | 33 ++++++--------- tools/dissect/ndn-dissect.cpp | 3 +- tools/dump/main.cpp | 6 ++- tools/peek/ndnpeek/main.cpp | 6 ++- tools/peek/ndnpoke/main.cpp | 6 ++- tools/ping/client/main.cpp | 7 +++- tools/ping/client/ping.hpp | 12 +++--- tools/ping/server/main.cpp | 7 +++- tools/ping/server/ping-server.hpp | 8 ++-- 17 files changed, 105 insertions(+), 86 deletions(-) diff --git a/core/common.hpp b/core/common.hpp index 07971f1..dd6d4fb 100644 --- a/core/common.hpp +++ b/core/common.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2020, Regents of the University of California, + * Copyright (c) 2014-2021, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -43,20 +43,15 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include -#include -#include -#include #include #include @@ -66,7 +61,6 @@ #include #include #include -#include #include namespace ndn { @@ -80,8 +74,6 @@ using std::size_t; using boost::noncopyable; -namespace signal = util::signal; - } // namespace ndn #endif // NDN_TOOLS_CORE_COMMON_HPP diff --git a/tests/chunks/producer.t.cpp b/tests/chunks/producer.t.cpp index 6934fa4..ef53422 100644 --- a/tests/chunks/producer.t.cpp +++ b/tests/chunks/producer.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2016-2020, Regents of the University of California, + * Copyright (c) 2016-2021, Regents of the University of California, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University. * @@ -26,6 +26,7 @@ #include "tools/chunks/putchunks/producer.hpp" #include "tests/test-common.hpp" +#include "tests/io-fixture.hpp" #include "tests/key-chain-fixture.hpp" #include @@ -42,32 +43,26 @@ namespace tests { using namespace ndn::tests; -class ProducerFixture : public KeyChainFixture +class ProducerFixture : public IoFixture, public KeyChainFixture { protected: ProducerFixture() - : face(io, {true, true}) - , prefix("/ndn/chunks/test") - , version(1449227841747) - , keyLocatorName(m_keyChain.createIdentity("/ProducerFixture").getDefaultKey().getName()) - , testString(std::string( - "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget " - "dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, " - "nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, " - "sem. Nulla consequat massa Donec pede justo,")) { options.maxSegmentSize = 40; options.isQuiet = true; } protected: - boost::asio::io_service io; - util::DummyClientFace face; - Name prefix; + util::DummyClientFace face{m_io, {true, true}}; + Name prefix = "/ndn/chunks/test"; Producer::Options options; - uint64_t version; - Name keyLocatorName; - std::istringstream testString; + uint64_t version = 1449227841747; + Name keyLocatorName = m_keyChain.createIdentity("/ProducerFixture").getDefaultKey().getName(); + std::istringstream testString{ + "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget " + "dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, " + "nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, " + "sem. Nulla consequat massa Donec pede justo,"s}; }; BOOST_AUTO_TEST_SUITE(Chunks) @@ -94,8 +89,9 @@ BOOST_AUTO_TEST_CASE(InputData) Producer prod(prefix, face, m_keyChain, input, options); size_t expectedSize = std::ceil(static_cast(testStrings[i].size()) / options.maxSegmentSize); - if (testStrings[i].empty()) + if (testStrings[i].empty()) { expectedSize = 1; + } BOOST_CHECK_EQUAL(prod.m_store.size(), expectedSize); } @@ -104,7 +100,7 @@ BOOST_AUTO_TEST_CASE(InputData) BOOST_AUTO_TEST_CASE(RequestSegmentUnspecifiedVersion) { Producer producer(prefix, face, m_keyChain, testString, options); - io.poll(); + m_io.poll(); size_t nSegments = std::ceil(static_cast(testString.str().size()) / options.maxSegmentSize); // version request @@ -137,7 +133,7 @@ BOOST_AUTO_TEST_CASE(RequestSegmentUnspecifiedVersion) BOOST_AUTO_TEST_CASE(RequestSegmentSpecifiedVersion) { Producer producer(prefix.appendVersion(version), face, m_keyChain, testString, options); - io.poll(); + m_io.poll(); size_t nSegments = std::ceil(static_cast(testString.str().size()) / options.maxSegmentSize); // version request @@ -171,7 +167,7 @@ BOOST_AUTO_TEST_CASE(RequestSegmentSpecifiedVersion) BOOST_AUTO_TEST_CASE(RequestNotExistingSegment) { Producer producer(prefix, face, m_keyChain, testString, options); - io.poll(); + m_io.poll(); size_t nSegments = std::ceil(static_cast(testString.str().size()) / options.maxSegmentSize); // version request @@ -198,7 +194,7 @@ BOOST_AUTO_TEST_CASE(RequestNotExistingSegment) BOOST_AUTO_TEST_CASE(RequestMetadata) { Producer producer(prefix.appendVersion(version), face, m_keyChain, testString, options); - io.poll(); + m_io.poll(); // ask for metadata with a valid discovery interest face.receive(MetadataObject::makeDiscoveryInterest(Name(prefix).getPrefix(-1))); diff --git a/tools/chunks/catchunks/consumer.hpp b/tools/chunks/catchunks/consumer.hpp index 9972d76..3f6f77e 100644 --- a/tools/chunks/catchunks/consumer.hpp +++ b/tools/chunks/catchunks/consumer.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2016-2020, Regents of the University of California, + * Copyright (c) 2016-2021, Regents of the University of California, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University. * @@ -34,6 +34,8 @@ #include #include +#include + namespace ndn { namespace chunks { diff --git a/tools/chunks/catchunks/discover-version.hpp b/tools/chunks/catchunks/discover-version.hpp index aaf409a..62a5e42 100644 --- a/tools/chunks/catchunks/discover-version.hpp +++ b/tools/chunks/catchunks/discover-version.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2016-2019, Regents of the University of California, + * Copyright (c) 2016-2021, Regents of the University of California, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University. * @@ -31,6 +31,8 @@ #include "options.hpp" +#include + namespace ndn { namespace chunks { @@ -44,23 +46,19 @@ class DataFetcher; */ class DiscoverVersion { -public: // signals - /** - * @brief Signal emitted when the versioned name of Data is found. - */ - signal::Signal onDiscoverySuccess; - - /** - * @brief Signal emitted when a failure occurs. - */ - signal::Signal onDiscoveryFailure; - public: DiscoverVersion(Face& face, const Name& prefix, const Options& options); /** - * @brief identify the latest Data version published. + * @brief Signal emitted when the versioned name of Data is found. */ + util::Signal onDiscoverySuccess; + + /** + * @brief Signal emitted when a failure occurs. + */ + util::Signal onDiscoveryFailure; + void run(); diff --git a/tools/chunks/catchunks/main.cpp b/tools/chunks/catchunks/main.cpp index cfb4124..faa7ed6 100644 --- a/tools/chunks/catchunks/main.cpp +++ b/tools/chunks/catchunks/main.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2016-2020, Regents of the University of California, + * Copyright (c) 2016-2021, Regents of the University of California, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University. * @@ -40,6 +40,10 @@ #include #include +#include +#include +#include + namespace ndn { namespace chunks { diff --git a/tools/chunks/catchunks/pipeline-interests-adaptive.hpp b/tools/chunks/catchunks/pipeline-interests-adaptive.hpp index 914143c..158656e 100644 --- a/tools/chunks/catchunks/pipeline-interests-adaptive.hpp +++ b/tools/chunks/catchunks/pipeline-interests-adaptive.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2016-2019, Regents of the University of California, + * Copyright (c) 2016-2021, Regents of the University of California, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University. * @@ -32,6 +32,7 @@ #include "pipeline-interests.hpp" #include +#include #include #include @@ -94,7 +95,7 @@ public: * The callback function should be: `void(nanoseconds age, double cwnd)`, where `age` is the * time since the pipeline started and `cwnd` is the new congestion window size (in segments). */ - signal::Signal afterCwndChange; + util::Signal afterCwndChange; struct RttSample { @@ -108,7 +109,7 @@ public: /** * @brief Signals when a new RTT sample has been taken. */ - signal::Signal afterRttMeasurement; + util::Signal afterRttMeasurement; protected: DECLARE_SIGNAL_EMIT(afterCwndChange) diff --git a/tools/chunks/catchunks/pipeline-interests.cpp b/tools/chunks/catchunks/pipeline-interests.cpp index ad8b818..9f2e3b5 100644 --- a/tools/chunks/catchunks/pipeline-interests.cpp +++ b/tools/chunks/catchunks/pipeline-interests.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2016-2019, Regents of the University of California, + * Copyright (c) 2016-2021, Regents of the University of California, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University. * @@ -31,6 +31,8 @@ #include "pipeline-interests.hpp" #include "data-fetcher.hpp" +#include + namespace ndn { namespace chunks { diff --git a/tools/chunks/putchunks/main.cpp b/tools/chunks/putchunks/main.cpp index 5e1dd9f..e1b0ea5 100644 --- a/tools/chunks/putchunks/main.cpp +++ b/tools/chunks/putchunks/main.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2016-2019, Regents of the University of California, + * Copyright (c) 2016-2021, Regents of the University of California, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University. * @@ -30,11 +30,15 @@ #include "core/version.hpp" #include "producer.hpp" -namespace po = boost::program_options; +#include +#include +#include namespace ndn { namespace chunks { +namespace po = boost::program_options; + static void usage(std::ostream& os, const std::string& programName, const po::options_description& desc) { diff --git a/tools/dissect/main.cpp b/tools/dissect/main.cpp index a2a7034..fb14692 100644 --- a/tools/dissect/main.cpp +++ b/tools/dissect/main.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2019, Regents of the University of California. + * Copyright (c) 2014-2021, Regents of the University of California. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -21,16 +21,16 @@ #include "core/version.hpp" #include -#include #include +#include #include -namespace po = boost::program_options; - namespace ndn { namespace dissect { +namespace po = boost::program_options; + static void usage(std::ostream& os, const std::string& appName, const po::options_description& options) { @@ -43,34 +43,27 @@ usage(std::ostream& os, const std::string& appName, const po::options_descriptio static int main(int argc, char* argv[]) { + std::string inputFileName; + po::options_description visibleOptions; visibleOptions.add_options() - ("help,h", "Print help and exit.") - ("version,V", "Print version and exit.") + ("help,h", "print help and exit") + ("version,V", "print version and exit") ; - std::string inputFileName; po::options_description hiddenOptions; hiddenOptions.add_options() ("input-file", po::value(&inputFileName)); - ; - po::positional_options_description positionalArguments; - positionalArguments - .add("input-file", -1); po::options_description allOptions; - allOptions - .add(visibleOptions) - .add(hiddenOptions) - ; + allOptions.add(visibleOptions).add(hiddenOptions); + + po::positional_options_description pos; + pos.add("input-file", -1); po::variables_map vm; try { - po::store(po::command_line_parser(argc, argv) - .options(allOptions) - .positional(positionalArguments) - .run(), - vm); + po::store(po::command_line_parser(argc, argv).options(allOptions).positional(pos).run(), vm); po::notify(vm); } catch (const po::error& e) { diff --git a/tools/dissect/ndn-dissect.cpp b/tools/dissect/ndn-dissect.cpp index c072c69..907eef6 100644 --- a/tools/dissect/ndn-dissect.cpp +++ b/tools/dissect/ndn-dissect.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2013-2019, Regents of the University of California. + * Copyright (c) 2013-2021, Regents of the University of California. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -24,6 +24,7 @@ #include "ndn-dissect.hpp" #include +#include #include #include diff --git a/tools/dump/main.cpp b/tools/dump/main.cpp index 86a9a85..49ea5b0 100644 --- a/tools/dump/main.cpp +++ b/tools/dump/main.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2011-2019, Regents of the University of California. + * Copyright (c) 2011-2021, Regents of the University of California. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -22,6 +22,10 @@ #include +#include +#include +#include + #include namespace ndn { diff --git a/tools/peek/ndnpeek/main.cpp b/tools/peek/ndnpeek/main.cpp index 5a8bc19..ff9f2af 100644 --- a/tools/peek/ndnpeek/main.cpp +++ b/tools/peek/ndnpeek/main.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2019, Regents of the University of California, + * Copyright (c) 2014-2021, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -32,6 +32,10 @@ #include +#include +#include +#include + #include #include #include diff --git a/tools/peek/ndnpoke/main.cpp b/tools/peek/ndnpoke/main.cpp index 00686ff..482cf80 100644 --- a/tools/peek/ndnpoke/main.cpp +++ b/tools/peek/ndnpoke/main.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2019, Regents of the University of California, + * Copyright (c) 2014-2021, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -29,6 +29,10 @@ #include "ndnpoke.hpp" #include "core/version.hpp" +#include +#include +#include + namespace ndn { namespace peek { diff --git a/tools/ping/client/main.cpp b/tools/ping/client/main.cpp index 76d72ff..590c2db 100644 --- a/tools/ping/client/main.cpp +++ b/tools/ping/client/main.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2019, Arizona Board of Regents. + * Copyright (c) 2014-2021, Arizona Board of Regents. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -27,6 +27,11 @@ #include "statistics-collector.hpp" #include "tracer.hpp" +#include +#include +#include +#include + namespace ndn { namespace ping { namespace client { diff --git a/tools/ping/client/ping.hpp b/tools/ping/client/ping.hpp index aeab96f..48f2485 100644 --- a/tools/ping/client/ping.hpp +++ b/tools/ping/client/ping.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2015-2019, Arizona Board of Regents. + * Copyright (c) 2015-2021, Arizona Board of Regents. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -26,6 +26,8 @@ #include "core/common.hpp" +#include + namespace ndn { namespace ping { namespace client { @@ -62,7 +64,7 @@ public: * @param seq ping sequence number * @param rtt round trip time */ - signal::Signal afterData; + util::Signal afterData; /** * @brief Signals on the return of a Nack @@ -71,19 +73,19 @@ public: * @param rtt round trip time * @param header the received Network NACK header */ - signal::Signal afterNack; + util::Signal afterNack; /** * @brief Signals on timeout of a packet * * @param seq ping sequence number */ - signal::Signal afterTimeout; + util::Signal afterTimeout; /** * @brief Signals when finished pinging */ - signal::Signal afterFinish; + util::Signal afterFinish; /** * @brief Start sending ping interests diff --git a/tools/ping/server/main.cpp b/tools/ping/server/main.cpp index dcce849..d43f1d2 100644 --- a/tools/ping/server/main.cpp +++ b/tools/ping/server/main.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2015-2019, Arizona Board of Regents. + * Copyright (c) 2015-2021, Arizona Board of Regents. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -26,6 +26,11 @@ #include "ping-server.hpp" #include "tracer.hpp" +#include +#include +#include +#include + namespace ndn { namespace ping { namespace server { diff --git a/tools/ping/server/ping-server.hpp b/tools/ping/server/ping-server.hpp index 46df6f9..f13769c 100644 --- a/tools/ping/server/ping-server.hpp +++ b/tools/ping/server/ping-server.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2015-2019, Arizona Board of Regents. + * Copyright (c) 2015-2021, Arizona Board of Regents. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -25,6 +25,8 @@ #include "core/common.hpp" +#include + namespace ndn { namespace ping { namespace server { @@ -55,12 +57,12 @@ public: * * @param name incoming interest name */ - signal::Signal afterReceive; + util::Signal afterReceive; /** * @brief Signals when finished pinging */ - signal::Signal afterFinish; + util::Signal afterFinish; /** @brief starts ping server *