From eb87c28200683f0becbab48dcd27fcdafa5346d0 Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Wed, 15 Mar 2023 21:07:02 -0400 Subject: [PATCH] detail: stop importing std::function into ndn namespace Change-Id: I536774e974627abbf4e8b868ebb948b90ea5d4a6 --- ndn-cxx/detail/common.hpp | 2 -- ndn-cxx/encoding/block.cpp | 2 ++ ndn-cxx/encoding/encoder.hpp | 4 +++- ndn-cxx/face.hpp | 18 +++++++++--------- ndn-cxx/impl/common-pch.hpp | 1 + ndn-cxx/interest.cpp | 1 + ndn-cxx/link.cpp | 4 +++- ndn-cxx/link.hpp | 4 +++- ndn-cxx/meta-info.cpp | 1 + ndn-cxx/mgmt/dispatcher.cpp | 4 +++- ndn-cxx/mgmt/nfd/controller.hpp | 6 +++--- ndn-cxx/net/dns.hpp | 10 +++++----- ndn-cxx/net/ethernet.cpp | 3 ++- ndn-cxx/net/face-uri.hpp | 4 ++-- ndn-cxx/net/impl/netlink-message.hpp | 1 + ndn-cxx/signature-info.cpp | 1 + ndn-cxx/util/segment-fetcher.cpp | 1 + ndn-cxx/util/signal/signal.hpp | 7 ++++--- tests/unit/face.t.cpp | 8 ++++---- 19 files changed, 49 insertions(+), 33 deletions(-) diff --git a/ndn-cxx/detail/common.hpp b/ndn-cxx/detail/common.hpp index 1136bd0e..daf5f7a5 100644 --- a/ndn-cxx/detail/common.hpp +++ b/ndn-cxx/detail/common.hpp @@ -49,7 +49,6 @@ #define NDN_CXX_PROTECTED_WITH_TESTS_ELSE_PRIVATE private #endif -#include #include #include #include @@ -72,7 +71,6 @@ using std::static_pointer_cast; using std::dynamic_pointer_cast; using std::const_pointer_cast; -using std::function; using std::to_string; using namespace std::string_literals; diff --git a/ndn-cxx/encoding/block.cpp b/ndn-cxx/encoding/block.cpp index 6b14d878..6c525c53 100644 --- a/ndn-cxx/encoding/block.cpp +++ b/ndn-cxx/encoding/block.cpp @@ -31,6 +31,8 @@ #include #include + +#include #include namespace ndn { diff --git a/ndn-cxx/encoding/encoder.hpp b/ndn-cxx/encoding/encoder.hpp index 27177ad1..82b5ea31 100644 --- a/ndn-cxx/encoding/encoder.hpp +++ b/ndn-cxx/encoding/encoder.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2013-2022 Regents of the University of California. + * Copyright (c) 2013-2023 Regents of the University of California. * * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * @@ -24,6 +24,8 @@ #include "ndn-cxx/encoding/block.hpp" +#include + namespace ndn { namespace encoding { diff --git a/ndn-cxx/face.hpp b/ndn-cxx/face.hpp index 0a16feab..b9153989 100644 --- a/ndn-cxx/face.hpp +++ b/ndn-cxx/face.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2013-2022 Regents of the University of California. + * Copyright (c) 2013-2023 Regents of the University of California. * * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * @@ -47,42 +47,42 @@ using RecordId = uint64_t; /** * @brief Callback invoked when an expressed Interest is satisfied by a Data packet */ -typedef function DataCallback; +using DataCallback = std::function; /** * @brief Callback invoked when a Nack is received in response to an expressed Interest */ -typedef function NackCallback; +using NackCallback = std::function; /** * @brief Callback invoked when an expressed Interest times out */ -typedef function TimeoutCallback; +using TimeoutCallback = std::function; /** * @brief Callback invoked when an incoming Interest matches the specified InterestFilter */ -typedef function InterestCallback; +using InterestCallback = std::function; /** * @brief Callback invoked when registerPrefix or setInterestFilter command succeeds */ -typedef function RegisterPrefixSuccessCallback; +using RegisterPrefixSuccessCallback = std::function; /** * @brief Callback invoked when registerPrefix or setInterestFilter command fails */ -typedef function RegisterPrefixFailureCallback; +using RegisterPrefixFailureCallback = std::function; /** * @brief Callback invoked when unregistering a prefix succeeds */ -typedef function UnregisterPrefixSuccessCallback; +using UnregisterPrefixSuccessCallback = std::function; /** * @brief Callback invoked when unregistering a prefix fails */ -typedef function UnregisterPrefixFailureCallback; +using UnregisterPrefixFailureCallback = std::function; /** * @brief Provide a communication channel with local or remote NDN forwarder diff --git a/ndn-cxx/impl/common-pch.hpp b/ndn-cxx/impl/common-pch.hpp index 539d977c..61dd2c1d 100644 --- a/ndn-cxx/impl/common-pch.hpp +++ b/ndn-cxx/impl/common-pch.hpp @@ -28,6 +28,7 @@ #include "ndn-cxx/detail/common.hpp" // STL headers to precompile +#include #include #include #include diff --git a/ndn-cxx/interest.cpp b/ndn-cxx/interest.cpp index cd802cda..ad6c5c01 100644 --- a/ndn-cxx/interest.cpp +++ b/ndn-cxx/interest.cpp @@ -29,6 +29,7 @@ #include +#include #include #include diff --git a/ndn-cxx/link.cpp b/ndn-cxx/link.cpp index 9110bf84..c1ac3fb9 100644 --- a/ndn-cxx/link.cpp +++ b/ndn-cxx/link.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2013-2022 Regents of the University of California. + * Copyright (c) 2013-2023 Regents of the University of California. * * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * @@ -21,6 +21,8 @@ #include "ndn-cxx/link.hpp" +#include + namespace ndn { BOOST_CONCEPT_ASSERT((boost::EqualityComparable)); diff --git a/ndn-cxx/link.hpp b/ndn-cxx/link.hpp index 02c0406e..116ffba2 100644 --- a/ndn-cxx/link.hpp +++ b/ndn-cxx/link.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2013-2022 Regents of the University of California. + * Copyright (c) 2013-2023 Regents of the University of California. * * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * @@ -24,6 +24,8 @@ #include "ndn-cxx/data.hpp" +#include + namespace ndn { /** diff --git a/ndn-cxx/meta-info.cpp b/ndn-cxx/meta-info.cpp index f95b69d9..2fde11ee 100644 --- a/ndn-cxx/meta-info.cpp +++ b/ndn-cxx/meta-info.cpp @@ -22,6 +22,7 @@ #include "ndn-cxx/meta-info.hpp" #include "ndn-cxx/encoding/block-helpers.hpp" +#include #include namespace ndn { diff --git a/ndn-cxx/mgmt/dispatcher.cpp b/ndn-cxx/mgmt/dispatcher.cpp index 2973abec..4bb1b7a4 100644 --- a/ndn-cxx/mgmt/dispatcher.cpp +++ b/ndn-cxx/mgmt/dispatcher.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2013-2021 Regents of the University of California. + * Copyright (c) 2013-2023 Regents of the University of California. * * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * @@ -23,6 +23,8 @@ #include "ndn-cxx/lp/tags.hpp" #include "ndn-cxx/util/logger.hpp" +#include + NDN_LOG_INIT(ndn.mgmt.Dispatcher); namespace ndn { diff --git a/ndn-cxx/mgmt/nfd/controller.hpp b/ndn-cxx/mgmt/nfd/controller.hpp index 1d56b562..7fdeb55a 100644 --- a/ndn-cxx/mgmt/nfd/controller.hpp +++ b/ndn-cxx/mgmt/nfd/controller.hpp @@ -53,17 +53,17 @@ public: /** * \brief Callback on command success. */ - using CommandSucceedCallback = function; + using CommandSucceedCallback = std::function; /** * \brief Callback on command failure. */ - using CommandFailCallback = function; + using CommandFailCallback = std::function; /** * \brief Callback on dataset retrieval failure. */ - using DatasetFailCallback = function; + using DatasetFailCallback = std::function; /** * \brief Construct a Controller that uses \p face as transport and \p keyChain to sign commands. diff --git a/ndn-cxx/net/dns.hpp b/ndn-cxx/net/dns.hpp index e3f8b7c9..a2db537e 100644 --- a/ndn-cxx/net/dns.hpp +++ b/ndn-cxx/net/dns.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2013-2021 Regents of the University of California. + * Copyright (c) 2013-2023 Regents of the University of California. * * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * @@ -30,8 +30,8 @@ namespace ndn { namespace dns { -typedef boost::asio::ip::address IpAddress; -typedef function AddressSelector; +using IpAddress = boost::asio::ip::address; +using AddressSelector = std::function; struct AnyAddress { @@ -66,8 +66,8 @@ public: using std::runtime_error::runtime_error; }; -typedef function SuccessCallback; -typedef function ErrorCallback; +using SuccessCallback = std::function; +using ErrorCallback = std::function; /** \brief Asynchronously resolve host * diff --git a/ndn-cxx/net/ethernet.cpp b/ndn-cxx/net/ethernet.cpp index 65cb118e..cced947e 100644 --- a/ndn-cxx/net/ethernet.cpp +++ b/ndn-cxx/net/ethernet.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022 Regents of the University of California, + * Copyright (c) 2014-2023 Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -29,6 +29,7 @@ #include +#include #include #include #include diff --git a/ndn-cxx/net/face-uri.hpp b/ndn-cxx/net/face-uri.hpp index bca98c93..412a4ea3 100644 --- a/ndn-cxx/net/face-uri.hpp +++ b/ndn-cxx/net/face-uri.hpp @@ -152,8 +152,8 @@ public: // canonical FaceUri bool isCanonical() const; - typedef function CanonizeSuccessCallback; - typedef function CanonizeFailureCallback; + using CanonizeSuccessCallback = std::function; + using CanonizeFailureCallback = std::function; /** \brief Asynchronously convert this FaceUri to canonical form. * \param onSuccess function to call after this FaceUri is converted to canonical form diff --git a/ndn-cxx/net/impl/netlink-message.hpp b/ndn-cxx/net/impl/netlink-message.hpp index ba888563..ed2567b2 100644 --- a/ndn-cxx/net/impl/netlink-message.hpp +++ b/ndn-cxx/net/impl/netlink-message.hpp @@ -35,6 +35,7 @@ #include #include +#include #include #include #include diff --git a/ndn-cxx/signature-info.cpp b/ndn-cxx/signature-info.cpp index 0e8eed40..bba5682d 100644 --- a/ndn-cxx/signature-info.cpp +++ b/ndn-cxx/signature-info.cpp @@ -24,6 +24,7 @@ #include "ndn-cxx/util/concepts.hpp" #include "ndn-cxx/util/string-helper.hpp" +#include #include namespace ndn { diff --git a/ndn-cxx/util/segment-fetcher.cpp b/ndn-cxx/util/segment-fetcher.cpp index 02d566fc..dcacf944 100644 --- a/ndn-cxx/util/segment-fetcher.cpp +++ b/ndn-cxx/util/segment-fetcher.cpp @@ -31,6 +31,7 @@ #include #include +#include #include namespace ndn { diff --git a/ndn-cxx/util/signal/signal.hpp b/ndn-cxx/util/signal/signal.hpp index b60ef83d..054529fa 100644 --- a/ndn-cxx/util/signal/signal.hpp +++ b/ndn-cxx/util/signal/signal.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2013-2022 Regents of the University of California. + * Copyright (c) 2013-2023 Regents of the University of California. * * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * @@ -52,9 +52,10 @@ template class Signal : noncopyable { public: // API for anyone - /** \brief Represents a function that can connect to the signal. + /** + * \brief Represents a function that can connect to the signal. */ - typedef function Handler; + using Handler = std::function; Signal(); diff --git a/tests/unit/face.t.cpp b/tests/unit/face.t.cpp index 0ee95b4c..7e5b7be4 100644 --- a/tests/unit/face.t.cpp +++ b/tests/unit/face.t.cpp @@ -56,8 +56,8 @@ protected: * \return whether the prefix registration succeeded. */ bool - runPrefixReg(function f) + runPrefixReg(std::function f) { boost::logic::tribool result = boost::logic::indeterminate; f([&] (auto) { result = true; }, @@ -72,8 +72,8 @@ protected: * \return whether the prefix unregistration succeeded. */ bool - runPrefixUnreg(function f) + runPrefixUnreg(std::function f) { boost::logic::tribool result = boost::logic::indeterminate; f([&] { result = true; },