blob: 7b5d4c8c598cf5526c687abdbd8249de04b955f0 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventoba4fbbe2017-07-03 01:06:30 -04002/*
Davide Pesaventoe1789892017-02-26 15:50:52 -05003 * Copyright (c) 2013-2017 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * 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 Thompson571f3522013-07-07 22:39:31 -070020 */
21
Junxiao Shib8901b22014-12-13 23:29:10 -070022/** \file
23 * \brief import common constructs for ndn-cxx library internal use
Davide Pesaventoba4fbbe2017-07-03 01:06:30 -040024 * \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 Shib8901b22014-12-13 23:29:10 -070026 */
27
Jeff Thompson571f3522013-07-07 22:39:31 -070028#ifndef NDN_COMMON_HPP
29#define NDN_COMMON_HPP
30
Alexander Afanasyev766cea72014-04-24 19:16:42 -070031#include "ndn-cxx-config.hpp"
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070032
Junxiao Shi99848502014-10-13 19:22:22 -070033// 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 Tan99135962014-09-20 02:18:53 -070035#ifdef NDN_CXX_HAVE_TESTS
Junxiao Shi99848502014-10-13 19:22:22 -070036#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 Tan99135962014-09-20 02:18:53 -070040#else
Junxiao Shi99848502014-10-13 19:22:22 -070041#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 Tan99135962014-09-20 02:18:53 -070045#endif
46
Davide Pesaventodfe9c6b2014-08-25 21:17:10 +020047// require C++11
48#if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__)
Davide Pesaventoaa82eb62016-04-22 19:08:40 +020049# error "ndn-cxx applications must be compiled using the C++11 standard (-std=c++11)"
Davide Pesaventodfe9c6b2014-08-25 21:17:10 +020050#endif
51
Junxiao Shi4b469982015-12-03 18:20:19 +000052#include <algorithm>
Davide Pesaventodfe9c6b2014-08-25 21:17:10 +020053#include <cstddef>
54#include <cstdint>
Davide Pesaventoe1789892017-02-26 15:50:52 -050055#include <exception>
Davide Pesaventodfe9c6b2014-08-25 21:17:10 +020056#include <functional>
Davide Pesaventoe1789892017-02-26 15:50:52 -050057#include <iosfwd>
Davide Pesaventodfe9c6b2014-08-25 21:17:10 +020058#include <limits>
59#include <memory>
60#include <stdexcept>
61#include <string>
Junxiao Shic2b8d242014-11-04 08:35:29 -070062#include <type_traits>
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080063#include <unistd.h>
Davide Pesavento409cc202015-09-19 14:13:16 +020064#include <utility>
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080065
Alexander Afanasyev49bb1fb2014-07-21 12:54:01 -070066namespace ndn {
67
Alexander Afanasyev19508852014-01-29 01:01:51 -080068using std::shared_ptr;
Davide Pesaventodfe9c6b2014-08-25 21:17:10 +020069using std::unique_ptr;
Alexander Afanasyevb78bc4d2014-04-09 21:20:52 -070070using std::weak_ptr;
Alexander Afanasyev6a05b4b2014-07-18 17:23:00 -070071using std::bad_weak_ptr;
Alexander Afanasyev19508852014-01-29 01:01:51 -080072using std::make_shared;
73using std::enable_shared_from_this;
74
Alexander Afanasyev15151312014-02-16 00:53:51 -080075using std::static_pointer_cast;
76using std::dynamic_pointer_cast;
77using std::const_pointer_cast;
78
Alexander Afanasyev19508852014-01-29 01:01:51 -080079using std::function;
80using std::bind;
Alexander Afanasyevb67090a2014-04-29 22:31:01 -070081using std::ref;
82using std::cref;
Alexander Afanasyev19508852014-01-29 01:01:51 -080083
84} // namespace ndn
85
Junxiao Shi95fdebe2014-11-08 23:45:03 -070086using namespace std::placeholders;
Davide Pesaventoba4fbbe2017-07-03 01:06:30 -040087
88/// \cond
89// Bug 2109 workaround
Junxiao Shi95fdebe2014-11-08 23:45:03 -070090#define BOOST_BIND_NO_PLACEHOLDERS
91#include <boost/is_placeholder.hpp>
92namespace boost {
93#define NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(N) \
94 template<> \
95 struct is_placeholder<typename std::remove_const<decltype(_##N)>::type> \
96 { \
97 enum _vt { \
98 value = N \
99 }; \
100 };
101NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(1)
102NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(2)
103NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(3)
104NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(4)
105NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(5)
106NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(6)
107NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(7)
108NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(8)
109NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER(9)
110#undef NDN_CXX_SPECIALIZE_BOOST_IS_PLACEHOLDER_FOR_STD_PLACEHOLDER
111} // namespace boost
Davide Pesaventoba4fbbe2017-07-03 01:06:30 -0400112/// \endcond
Junxiao Shi95fdebe2014-11-08 23:45:03 -0700113
Davide Pesaventodfe9c6b2014-08-25 21:17:10 +0200114#include <boost/assert.hpp>
Junxiao Shic2b8d242014-11-04 08:35:29 -0700115#include <boost/concept_check.hpp>
Davide Pesaventodfe9c6b2014-08-25 21:17:10 +0200116#include <boost/noncopyable.hpp>
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700117#include <boost/throw_exception.hpp>
Alexander Afanasyev19508852014-01-29 01:01:51 -0800118
119namespace ndn {
Alexander Afanasyev233750e2014-02-16 00:50:07 -0800120using boost::noncopyable;
Davide Pesaventoaa82eb62016-04-22 19:08:40 +0200121} // namespace ndn
Jeff Thompson51dd5fd2013-07-10 19:27:18 -0700122
Davide Pesavento409cc202015-09-19 14:13:16 +0200123#include "util/backports.hpp"
124
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -0700125#endif // NDN_COMMON_HPP