Skip to content

Commit

Permalink
Reduce unnecessary inclusions of detail/common.hpp
Browse files Browse the repository at this point in the history
Change-Id: I79dcd05297594ccd4489d8cddddb879655373cc0
  • Loading branch information
Pesa committed Jan 26, 2024
1 parent 2e71e98 commit 3de7c52
Show file tree
Hide file tree
Showing 37 changed files with 169 additions and 126 deletions.
6 changes: 4 additions & 2 deletions ndn-cxx/detail/cancel-handle.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand All @@ -22,7 +22,9 @@
#ifndef NDN_CXX_DETAIL_CANCEL_HANDLE_HPP
#define NDN_CXX_DETAIL_CANCEL_HANDLE_HPP

#include "ndn-cxx/detail/common.hpp"
#include <functional>
#include <type_traits>
#include <utility>

/**
* \brief Contains implementation details that are not part of the ndn-cxx public API.
Expand Down
5 changes: 3 additions & 2 deletions ndn-cxx/detail/cf-releaser-osx.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand All @@ -22,13 +22,14 @@
#ifndef NDN_CXX_DETAIL_CF_RELEASER_OSX_HPP
#define NDN_CXX_DETAIL_CF_RELEASER_OSX_HPP

#include "ndn-cxx/detail/common.hpp"
#include "ndn-cxx/detail/config.hpp"

#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
#error "This file should not be included ..."
#endif

#include <CoreFoundation/CoreFoundation.h>
#include <cstddef>

namespace ndn::detail {

Expand Down
3 changes: 2 additions & 1 deletion ndn-cxx/detail/cf-string-osx.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand All @@ -20,6 +20,7 @@
*/

#include "ndn-cxx/detail/cf-string-osx.hpp"
#include "ndn-cxx/detail/common.hpp"

namespace ndn::detail::cfstring {

Expand Down
7 changes: 5 additions & 2 deletions ndn-cxx/detail/cf-string-osx.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand All @@ -22,14 +22,17 @@
#ifndef NDN_CXX_DETAIL_CF_STRING_OSX_HPP
#define NDN_CXX_DETAIL_CF_STRING_OSX_HPP

#include "ndn-cxx/detail/common.hpp"
#include "ndn-cxx/detail/config.hpp"

#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
#error "This file should not be included ..."
#endif

#include "ndn-cxx/detail/cf-releaser-osx.hpp"

#include <cstdint>
#include <string>

/**
* @file
*
Expand Down
15 changes: 8 additions & 7 deletions ndn-cxx/detail/tag-host.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand All @@ -22,10 +22,11 @@
#ifndef NDN_CXX_DETAIL_TAG_HOST_HPP
#define NDN_CXX_DETAIL_TAG_HOST_HPP

#include "ndn-cxx/detail/common.hpp"
#include "ndn-cxx/tag.hpp"

#include <map>
#include <memory>
#include <type_traits>

namespace ndn {

Expand All @@ -41,7 +42,7 @@ class TagHost
* \retval nullptr if no Tag of type T is stored
*/
template<typename T>
shared_ptr<T>
std::shared_ptr<T>
getTag() const;

/**
Expand All @@ -51,7 +52,7 @@ class TagHost
*/
template<typename T>
void
setTag(shared_ptr<T> tag) const;
setTag(std::shared_ptr<T> tag) const;

/**
* \brief Remove a tag item.
Expand All @@ -63,11 +64,11 @@ class TagHost
removeTag() const;

private:
mutable std::map<int, shared_ptr<Tag>> m_tags;
mutable std::map<int, std::shared_ptr<Tag>> m_tags;
};

template<typename T>
shared_ptr<T>
std::shared_ptr<T>
TagHost::getTag() const
{
static_assert(std::is_convertible_v<T*, Tag*>, "T must inherit from ndn::Tag");
Expand All @@ -80,7 +81,7 @@ TagHost::getTag() const

template<typename T>
void
TagHost::setTag(shared_ptr<T> tag) const
TagHost::setTag(std::shared_ptr<T> tag) const
{
static_assert(std::is_convertible_v<T*, Tag*>, "T must inherit from ndn::Tag");

Expand Down
4 changes: 2 additions & 2 deletions ndn-cxx/encoding/buffer-stream.cpp
Original file line number Diff line number Diff line change
@@ -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-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand Down Expand Up @@ -54,7 +54,7 @@ OBufferStream::~OBufferStream() noexcept
}
}

shared_ptr<Buffer>
std::shared_ptr<Buffer>
OBufferStream::buf()
{
if (is_open()) {
Expand Down
6 changes: 3 additions & 3 deletions ndn-cxx/encoding/buffer-stream.hpp
Original file line number Diff line number Diff line change
@@ -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-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand Down Expand Up @@ -76,11 +76,11 @@ class OBufferStream : public boost::iostreams::stream<detail::BufferSink>
/**
* @brief Return a shared pointer to the underlying buffer.
*/
shared_ptr<Buffer>
std::shared_ptr<Buffer>
buf();

private:
shared_ptr<Buffer> m_buffer;
std::shared_ptr<Buffer> m_buffer;
};

} // namespace ndn
Expand Down
13 changes: 7 additions & 6 deletions ndn-cxx/encoding/buffer.hpp
Original file line number Diff line number Diff line change
@@ -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-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand All @@ -24,15 +24,16 @@
#ifndef NDN_CXX_ENCODING_BUFFER_HPP
#define NDN_CXX_ENCODING_BUFFER_HPP

#include "ndn-cxx/detail/common.hpp"

#include <cstdint>
#include <initializer_list>
#include <iosfwd>
#include <memory>
#include <vector>

namespace ndn {

/**
* @brief General-purpose automatically managed/resized buffer
* @brief General-purpose automatically managed/resized buffer.
*
* In most respect, the Buffer class is equivalent to a `std::vector<uint8_t>`, and it in fact
* uses the latter as a base class. In addition to that, it provides the get<T>() helper method
Expand Down Expand Up @@ -135,8 +136,8 @@ std::ostream&
boost_test_print_type(std::ostream&, const Buffer&);
/** \endcond */

using BufferPtr = shared_ptr<Buffer>;
using ConstBufferPtr = shared_ptr<const Buffer>;
using BufferPtr = std::shared_ptr<Buffer>;
using ConstBufferPtr = std::shared_ptr<const Buffer>;

} // namespace ndn

Expand Down
4 changes: 1 addition & 3 deletions ndn-cxx/encoding/encoding-buffer-fwd.hpp
Original file line number Diff line number Diff line change
@@ -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-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand All @@ -22,8 +22,6 @@
#ifndef NDN_CXX_ENCODING_ENCODING_BUFFER_FWD_HPP
#define NDN_CXX_ENCODING_ENCODING_BUFFER_FWD_HPP

#include "ndn-cxx/detail/common.hpp"

namespace ndn {
namespace encoding {

Expand Down
5 changes: 4 additions & 1 deletion ndn-cxx/net/dns.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand All @@ -27,6 +27,9 @@

#include <boost/asio/ip/address.hpp>

#include <functional>
#include <string>

namespace ndn::dns {

using AddressSelector = std::function<bool(const boost::asio::ip::address&)>;
Expand Down
27 changes: 15 additions & 12 deletions ndn-cxx/net/face-uri.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California,
* Copyright (c) 2013-2024 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
Expand All @@ -26,6 +26,8 @@
*/

#include "ndn-cxx/net/face-uri.hpp"

#include "ndn-cxx/detail/common.hpp"
#include "ndn-cxx/net/dns.hpp"
#include "ndn-cxx/util/string-helper.hpp"

Expand Down Expand Up @@ -116,23 +118,23 @@ FaceUri::FaceUri(const boost::asio::ip::udp::endpoint& endpoint)
m_isV6 = endpoint.address().is_v6();
m_scheme = m_isV6 ? "udp6" : "udp4";
m_host = endpoint.address().to_string();
m_port = to_string(endpoint.port());
m_port = std::to_string(endpoint.port());
}

FaceUri::FaceUri(const boost::asio::ip::tcp::endpoint& endpoint)
{
m_isV6 = endpoint.address().is_v6();
m_scheme = m_isV6 ? "tcp6" : "tcp4";
m_host = endpoint.address().to_string();
m_port = to_string(endpoint.port());
m_port = std::to_string(endpoint.port());
}

FaceUri::FaceUri(const boost::asio::ip::tcp::endpoint& endpoint, std::string_view scheme)
{
m_isV6 = endpoint.address().is_v6();
m_scheme = scheme;
m_host = endpoint.address().to_string();
m_port = to_string(endpoint.port());
m_port = std::to_string(endpoint.port());
}

#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS
Expand All @@ -155,7 +157,7 @@ FaceUri::fromFd(int fd)
{
FaceUri uri;
uri.m_scheme = "fd";
uri.m_host = to_string(fd);
uri.m_host = std::to_string(fd);
return uri;
}

Expand All @@ -174,7 +176,7 @@ FaceUri::fromUdpDev(const boost::asio::ip::udp::endpoint& endpoint, std::string_
FaceUri uri;
uri.m_scheme = endpoint.address().is_v6() ? "udp6+dev" : "udp4+dev";
uri.m_host = ifname;
uri.m_port = to_string(endpoint.port());
uri.m_port = std::to_string(endpoint.port());
return uri;
}

Expand Down Expand Up @@ -203,7 +205,8 @@ FaceUri::print(std::ostream& os) const
}


/** \brief A CanonizeProvider provides FaceUri canonization functionality for a group of schemes.
/**
* \brief A CanonizeProvider provides FaceUri canonization functionality for a group of schemes.
*/
class CanonizeProvider : noncopyable
{
Expand Down Expand Up @@ -296,7 +299,7 @@ class IpHostCanonizeProvider : public CanonizeProvider
}

// make a copy because caller may modify faceUri
auto uri = make_shared<FaceUri>(faceUri);
auto uri = std::make_shared<FaceUri>(faceUri);
boost::system::error_code ec;
auto ipAddress = boost::asio::ip::make_address(unescapeHost(faceUri.getHost()), ec);
if (!ec) {
Expand Down Expand Up @@ -343,7 +346,7 @@ class IpHostCanonizeProvider : public CanonizeProvider

private:
void
onDnsSuccess(const shared_ptr<FaceUri>& faceUri,
onDnsSuccess(const std::shared_ptr<FaceUri>& faceUri,
const FaceUri::CanonizeSuccessCallback& onSuccess,
const FaceUri::CanonizeFailureCallback& onFailure,
const boost::asio::ip::address& ipAddress) const
Expand Down Expand Up @@ -372,7 +375,7 @@ class IpHostCanonizeProvider : public CanonizeProvider
}

void
onDnsFailure(const shared_ptr<FaceUri>&,
onDnsFailure(const std::shared_ptr<FaceUri>&,
const FaceUri::CanonizeFailureCallback& onFailure,
const std::string& reason) const
{
Expand Down Expand Up @@ -558,15 +561,15 @@ using CanonizeProviders = boost::mp11::mp_list<UdpCanonizeProvider,
UdpDevCanonizeProvider>;
static_assert(boost::mp11::mp_is_set<CanonizeProviders>());

using CanonizeProviderTable = std::map<std::string, shared_ptr<CanonizeProvider>>;
using CanonizeProviderTable = std::map<std::string, std::shared_ptr<CanonizeProvider>>;

struct CanonizeProviderTableInitializer
{
template<typename CP>
void
operator()(boost::mp11::mp_identity<CP>)
{
shared_ptr<CanonizeProvider> cp = make_shared<CP>();
std::shared_ptr<CanonizeProvider> cp = std::make_shared<CP>();
auto schemes = cp->getSchemes();
BOOST_ASSERT(!schemes.empty());

Expand Down
5 changes: 3 additions & 2 deletions ndn-cxx/net/network-address.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand All @@ -24,7 +24,8 @@
#ifndef NDN_CXX_NET_NETWORK_ADDRESS_HPP
#define NDN_CXX_NET_NETWORK_ADDRESS_HPP

#include "ndn-cxx/detail/common.hpp"
#include <cstdint>
#include <iosfwd>

#include <boost/asio/ip/address.hpp>

Expand Down
Loading

0 comments on commit 3de7c52

Please sign in to comment.