blob: 5e6724af26e4d328df3549381f21db459fb925c2 [file] [log] [blame]
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shia37405d2015-01-26 10:50:58 -07003 * Copyright (c) 2014-2015, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070010 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Junxiao Shi5dd26c32014-07-20 23:15:14 -070024 */
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080025
26#ifndef NFD_COMMON_HPP
27#define NFD_COMMON_HPP
28
Junxiao Shi61c5ef32014-01-24 20:59:30 -070029#include "config.hpp"
30
Junxiao Shi88884492014-02-15 15:57:43 -070031#ifdef WITH_TESTS
32#define VIRTUAL_WITH_TESTS virtual
33#define PUBLIC_WITH_TESTS_ELSE_PROTECTED public
34#define PUBLIC_WITH_TESTS_ELSE_PRIVATE public
35#define PROTECTED_WITH_TESTS_ELSE_PRIVATE protected
36#else
37#define VIRTUAL_WITH_TESTS
38#define PUBLIC_WITH_TESTS_ELSE_PROTECTED protected
39#define PUBLIC_WITH_TESTS_ELSE_PRIVATE private
40#define PROTECTED_WITH_TESTS_ELSE_PRIVATE private
41#endif
42
Junxiao Shi1c93cae2014-12-09 22:52:17 -070043/** \def DECL_OVERRIDE
44 * \brief expands to 'override' if compiler supports this feature, otherwise expands to nothing
45 */
46#ifdef HAVE_CXX_OVERRIDE
47#define DECL_OVERRIDE override
48#else
49#define DECL_OVERRIDE
50#endif
51
Junxiao Shi5dd26c32014-07-20 23:15:14 -070052#include <cstddef>
Alexander Afanasyev8552a382014-05-15 20:13:42 -070053#include <list>
Junxiao Shia37405d2015-01-26 10:50:58 -070054#include <map>
Alexander Afanasyev8552a382014-05-15 20:13:42 -070055#include <set>
Junxiao Shi651b75e2014-07-17 20:15:09 -070056#include <queue>
Junxiao Shia37405d2015-01-26 10:50:58 -070057#include <unordered_map>
58#include <unordered_set>
Alexander Afanasyev8552a382014-05-15 20:13:42 -070059#include <vector>
Alexander Afanasyevce812302015-04-14 14:06:29 -070060#include <string>
Alexander Afanasyev8552a382014-05-15 20:13:42 -070061
Alexander Afanasyev4a771362014-04-24 21:29:33 -070062#include <ndn-cxx/common.hpp>
63#include <ndn-cxx/interest.hpp>
64#include <ndn-cxx/data.hpp>
Davide Pesavento94279412015-02-27 01:29:32 +010065#include <ndn-cxx/util/face-uri.hpp>
Junxiao Shi1e064172014-12-14 19:37:46 -070066#include <ndn-cxx/util/signal.hpp>
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080067
Alexander Afanasyev8552a382014-05-15 20:13:42 -070068#include <boost/algorithm/string.hpp>
69#include <boost/asio.hpp>
Alexander Afanasyev920af2f2014-01-25 22:56:11 -080070#include <boost/assert.hpp>
Steve DiBenedettobf6a93d2014-03-21 14:03:02 -060071#include <boost/lexical_cast.hpp>
Davide Pesavento52a18f92014-04-10 00:55:01 +020072#include <boost/noncopyable.hpp>
Alexander Afanasyev8552a382014-05-15 20:13:42 -070073#include <boost/property_tree/ptree.hpp>
Spyridon Mastorakis149e02c2015-07-27 13:22:22 -070074#include <boost/throw_exception.hpp>
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080075
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080076namespace nfd {
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080077
Junxiao Shi5dd26c32014-07-20 23:15:14 -070078using std::size_t;
79
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080080using boost::noncopyable;
Davide Pesavento52a18f92014-04-10 00:55:01 +020081
Davide Pesaventoab1e8f22014-10-21 22:45:33 +020082using std::shared_ptr;
83using std::unique_ptr;
84using std::weak_ptr;
Davide Pesaventoab1e8f22014-10-21 22:45:33 +020085using std::make_shared;
86using std::enable_shared_from_this;
87
88using std::static_pointer_cast;
89using std::dynamic_pointer_cast;
90using std::const_pointer_cast;
91
92using std::function;
93using std::bind;
94using std::ref;
95using std::cref;
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080096
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080097using ndn::Interest;
98using ndn::Data;
99using ndn::Name;
100using ndn::Exclude;
101using ndn::Block;
Davide Pesavento94279412015-02-27 01:29:32 +0100102using ndn::util::FaceUri;
Davide Pesavento52a18f92014-04-10 00:55:01 +0200103
Alexander Afanasyev18bbf812014-01-29 01:40:23 -0800104namespace tlv {
Junxiao Shi67f11ac2014-10-19 09:29:13 -0700105// Don't write "namespace tlv = ndn::tlv", because NFD can add other members into this namespace.
106using namespace ndn::tlv;
107} // namespace tlv
Alexander Afanasyev18bbf812014-01-29 01:40:23 -0800108
Davide Pesavento52a18f92014-04-10 00:55:01 +0200109namespace name = ndn::name;
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -0700110namespace time = ndn::time;
Junxiao Shi1e064172014-12-14 19:37:46 -0700111namespace signal = ndn::util::signal;
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -0700112
Alexander Afanasyev18bbf812014-01-29 01:40:23 -0800113} // namespace nfd
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -0800114
Alexander Afanasyevce812302015-04-14 14:06:29 -0700115// Some platforms are missing std::to_string (issue #2743)
116#ifndef HAVE_STD_TO_STRING
117namespace std {
118template<typename V>
119inline std::string
120to_string(const V& v)
121{
122 return boost::lexical_cast<std::string>(v);
123}
124} // namespace std
125#endif // HAVE_STD_TO_STRING
126
127
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -0800128#endif // NFD_COMMON_HPP