Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | ba4fbbe | 2017-07-03 01:06:30 -0400 | [diff] [blame^] | 2 | /* |
Davide Pesavento | e178989 | 2017-02-26 15:50:52 -0500 | [diff] [blame] | 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Jeff Thompson | 571f352 | 2013-07-07 22:39:31 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Junxiao Shi | b8901b2 | 2014-12-13 23:29:10 -0700 | [diff] [blame] | 22 | /** \file |
| 23 | * \brief import common constructs for ndn-cxx library internal use |
Davide Pesavento | ba4fbbe | 2017-07-03 01:06:30 -0400 | [diff] [blame^] | 24 | * \warning This file is an implementation detail of ndn-cxx library. |
| 25 | * Aliases imported in this file MUST NOT be used outside of ndn-cxx. |
Junxiao Shi | b8901b2 | 2014-12-13 23:29:10 -0700 | [diff] [blame] | 26 | */ |
| 27 | |
Jeff Thompson | 571f352 | 2013-07-07 22:39:31 -0700 | [diff] [blame] | 28 | #ifndef NDN_COMMON_HPP |
| 29 | #define NDN_COMMON_HPP |
| 30 | |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 31 | #include "ndn-cxx-config.hpp" |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 32 | |
Junxiao Shi | 9984850 | 2014-10-13 19:22:22 -0700 | [diff] [blame] | 33 | // ndn-cxx specific macros declared in this and other headers must have NDN_CXX_ prefix |
| 34 | // to avoid conflicts with other projects that include ndn-cxx headers. |
Jiewen Tan | 9913596 | 2014-09-20 02:18:53 -0700 | [diff] [blame] | 35 | #ifdef NDN_CXX_HAVE_TESTS |
Junxiao Shi | 9984850 | 2014-10-13 19:22:22 -0700 | [diff] [blame] | 36 | #define NDN_CXX_VIRTUAL_WITH_TESTS virtual |
| 37 | #define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED public |
| 38 | #define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE public |
| 39 | #define NDN_CXX_PROTECTED_WITH_TESTS_ELSE_PRIVATE protected |
Jiewen Tan | 9913596 | 2014-09-20 02:18:53 -0700 | [diff] [blame] | 40 | #else |
Junxiao Shi | 9984850 | 2014-10-13 19:22:22 -0700 | [diff] [blame] | 41 | #define NDN_CXX_VIRTUAL_WITH_TESTS |
| 42 | #define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED protected |
| 43 | #define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE private |
| 44 | #define NDN_CXX_PROTECTED_WITH_TESTS_ELSE_PRIVATE private |
Jiewen Tan | 9913596 | 2014-09-20 02:18:53 -0700 | [diff] [blame] | 45 | #endif |
| 46 | |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 47 | // require C++11 |
| 48 | #if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__) |
Davide Pesavento | aa82eb6 | 2016-04-22 19:08:40 +0200 | [diff] [blame] | 49 | # error "ndn-cxx applications must be compiled using the C++11 standard (-std=c++11)" |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 50 | #endif |
| 51 | |
Junxiao Shi | 4b46998 | 2015-12-03 18:20:19 +0000 | [diff] [blame] | 52 | #include <algorithm> |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 53 | #include <cstddef> |
| 54 | #include <cstdint> |
Davide Pesavento | e178989 | 2017-02-26 15:50:52 -0500 | [diff] [blame] | 55 | #include <exception> |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 56 | #include <functional> |
Davide Pesavento | e178989 | 2017-02-26 15:50:52 -0500 | [diff] [blame] | 57 | #include <iosfwd> |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 58 | #include <limits> |
| 59 | #include <memory> |
| 60 | #include <stdexcept> |
| 61 | #include <string> |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 62 | #include <type_traits> |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame] | 63 | #include <unistd.h> |
Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 64 | #include <utility> |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame] | 65 | |
Steve DiBenedetto | c145d49 | 2014-03-11 16:35:45 -0600 | [diff] [blame] | 66 | #if defined(__GNUC__) || defined(__clang__) |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 67 | # define DEPRECATED(func) func __attribute__ ((deprecated)) |
Steve DiBenedetto | c145d49 | 2014-03-11 16:35:45 -0600 | [diff] [blame] | 68 | #elif defined(_MSC_VER) |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 69 | # define DEPRECATED(func) __declspec(deprecated) func |
Steve DiBenedetto | c145d49 | 2014-03-11 16:35:45 -0600 | [diff] [blame] | 70 | #else |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 71 | # pragma message("DEPRECATED not implemented") |
| 72 | # define DEPRECATED(func) func |
Steve DiBenedetto | c145d49 | 2014-03-11 16:35:45 -0600 | [diff] [blame] | 73 | #endif |
| 74 | |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 75 | namespace ndn { |
| 76 | |
Alexander Afanasyev | 1950885 | 2014-01-29 01:01:51 -0800 | [diff] [blame] | 77 | using std::shared_ptr; |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 78 | using std::unique_ptr; |
Alexander Afanasyev | b78bc4d | 2014-04-09 21:20:52 -0700 | [diff] [blame] | 79 | using std::weak_ptr; |
Alexander Afanasyev | 6a05b4b | 2014-07-18 17:23:00 -0700 | [diff] [blame] | 80 | using std::bad_weak_ptr; |
Alexander Afanasyev | 1950885 | 2014-01-29 01:01:51 -0800 | [diff] [blame] | 81 | using std::make_shared; |
| 82 | using std::enable_shared_from_this; |
| 83 | |
Alexander Afanasyev | 1515131 | 2014-02-16 00:53:51 -0800 | [diff] [blame] | 84 | using std::static_pointer_cast; |
| 85 | using std::dynamic_pointer_cast; |
| 86 | using std::const_pointer_cast; |
| 87 | |
Alexander Afanasyev | 1950885 | 2014-01-29 01:01:51 -0800 | [diff] [blame] | 88 | using std::function; |
| 89 | using std::bind; |
Alexander Afanasyev | b67090a | 2014-04-29 22:31:01 -0700 | [diff] [blame] | 90 | using std::ref; |
| 91 | using std::cref; |
Alexander Afanasyev | 1950885 | 2014-01-29 01:01:51 -0800 | [diff] [blame] | 92 | |
| 93 | } // namespace ndn |
| 94 | |
Junxiao Shi | 95fdebe | 2014-11-08 23:45:03 -0700 | [diff] [blame] | 95 | using namespace std::placeholders; |
Davide Pesavento | ba4fbbe | 2017-07-03 01:06:30 -0400 | [diff] [blame^] | 96 | |
| 97 | /// \cond |
| 98 | // Bug 2109 workaround |
Junxiao Shi | 95fdebe | 2014-11-08 23:45:03 -0700 | [diff] [blame] | 99 | #define BOOST_BIND_NO_PLACEHOLDERS |
| 100 | #include <boost/is_placeholder.hpp> |
| 101 | namespace boost { |
| 102 | #define NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(N) \ |
| 103 | template<> \ |
| 104 | struct is_placeholder<typename std::remove_const<decltype(_##N)>::type> \ |
| 105 | { \ |
| 106 | enum _vt { \ |
| 107 | value = N \ |
| 108 | }; \ |
| 109 | }; |
| 110 | NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(1) |
| 111 | NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(2) |
| 112 | NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(3) |
| 113 | NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(4) |
| 114 | NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(5) |
| 115 | NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(6) |
| 116 | NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(7) |
| 117 | NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(8) |
| 118 | NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(9) |
| 119 | #undef NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER |
| 120 | } // namespace boost |
Davide Pesavento | ba4fbbe | 2017-07-03 01:06:30 -0400 | [diff] [blame^] | 121 | /// \endcond |
Junxiao Shi | 95fdebe | 2014-11-08 23:45:03 -0700 | [diff] [blame] | 122 | |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 123 | #include <boost/assert.hpp> |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 124 | #include <boost/concept_check.hpp> |
Davide Pesavento | dfe9c6b | 2014-08-25 21:17:10 +0200 | [diff] [blame] | 125 | #include <boost/noncopyable.hpp> |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 126 | #include <boost/throw_exception.hpp> |
Alexander Afanasyev | 1950885 | 2014-01-29 01:01:51 -0800 | [diff] [blame] | 127 | |
| 128 | namespace ndn { |
Alexander Afanasyev | 233750e | 2014-02-16 00:50:07 -0800 | [diff] [blame] | 129 | using boost::noncopyable; |
Davide Pesavento | aa82eb6 | 2016-04-22 19:08:40 +0200 | [diff] [blame] | 130 | } // namespace ndn |
Jeff Thompson | 51dd5fd | 2013-07-10 19:27:18 -0700 | [diff] [blame] | 131 | |
Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 132 | #include "util/backports.hpp" |
| 133 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 134 | #endif // NDN_COMMON_HPP |