Reduce inclusions of <boost/asio.hpp> in public headers
And especially, stop including it from the precompiled header
"common-pch.hpp". This is a necessary step in order to avoid
conflicts between net/if.h (pulled in by Asio) and linux/if.h
(required by future commits).
Change-Id: I0207be0d2be796d8ef369062a8d5195fedfef6b0
diff --git a/src/common-pch.hpp b/src/common-pch.hpp
index b82f79d..06e8912 100644
--- a/src/common-pch.hpp
+++ b/src/common-pch.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2014 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,37 +22,35 @@
#ifndef NDN_COMMON_PCH_HPP
#define NDN_COMMON_PCH_HPP
-// If compiler supports precompiled header, this header should be compiled and include
-// before anything else
+// If the compiler supports precompiled headers, this header should be compiled
+// and included before anything else
#include "common.hpp"
// STL headers to precompile
-#include <vector>
-#include <list>
-#include <set>
-#include <algorithm>
-#include <map>
-#include <sstream>
#include <fstream>
-#include <exception>
+#include <list>
#include <map>
+#include <set>
+#include <sstream>
+#include <unordered_map>
+#include <unordered_set>
+#include <vector>
-// Other useful headers to precompile
-#include <boost/lexical_cast.hpp>
-#include <boost/asio.hpp>
+// Boost headers to precompile
+#include <boost/algorithm/string.hpp>
#include <boost/chrono.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/info_parser.hpp>
#include <boost/filesystem.hpp>
-#include <boost/regex.hpp>
-#include <boost/algorithm/string.hpp>
-
-#include <boost/iostreams/detail/ios.hpp>
#include <boost/iostreams/categories.hpp>
#include <boost/iostreams/stream.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/info_parser.hpp>
+#include <boost/regex.hpp>
+#include <boost/system/error_code.hpp>
+// Other useful headers to precompile
#include "security/cryptopp.hpp"
#endif // NDN_COMMON_PCH_HPP
diff --git a/src/transport/stream-transport.hpp b/src/transport/stream-transport.hpp
index 5ec91b0..a0c7ca3 100644
--- a/src/transport/stream-transport.hpp
+++ b/src/transport/stream-transport.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -24,6 +24,7 @@
#include "transport.hpp"
+#include <boost/asio.hpp>
#include <list>
namespace ndn {
diff --git a/src/transport/transport.hpp b/src/transport/transport.hpp
index 663d50e..1095f14 100644
--- a/src/transport/transport.hpp
+++ b/src/transport/transport.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2014 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -25,7 +25,14 @@
#include "../common.hpp"
#include "../encoding/block.hpp"
-#include <boost/asio.hpp>
+#include <boost/system/error_code.hpp>
+
+// forward declaration
+namespace boost {
+namespace asio {
+class io_service;
+} // namespace asio
+} // namespace boost
namespace ndn {
diff --git a/src/util/dns.cpp b/src/util/dns.cpp
index 0adfbd2..73fd8b1 100644
--- a/src/util/dns.cpp
+++ b/src/util/dns.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -20,9 +20,11 @@
*/
#include "dns.hpp"
-
#include "scheduler.hpp"
+#include <boost/asio/io_service.hpp>
+#include <boost/asio/ip/udp.hpp>
+
namespace ndn {
namespace dns {
diff --git a/src/util/dns.hpp b/src/util/dns.hpp
index 64d3865..fec923b 100644
--- a/src/util/dns.hpp
+++ b/src/util/dns.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -25,7 +25,13 @@
#include "../util/time.hpp"
#include <boost/asio/ip/address.hpp>
-#include <boost/asio/io_service.hpp>
+
+// forward declaration
+namespace boost {
+namespace asio {
+class io_service;
+} // namespace asio
+} // namespace boost
namespace ndn {
namespace dns {
diff --git a/src/util/dummy-client-face.cpp b/src/util/dummy-client-face.cpp
index 1db5b8d..8cdb9dc 100644
--- a/src/util/dummy-client-face.cpp
+++ b/src/util/dummy-client-face.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 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 "../management/nfd-controller.hpp"
#include "../management/nfd-control-response.hpp"
+#include <boost/asio/io_service.hpp>
+
namespace ndn {
namespace util {
diff --git a/src/util/monotonic_deadline_timer.hpp b/src/util/monotonic_deadline_timer.hpp
index 6572ca4..c2b28cf 100644
--- a/src/util/monotonic_deadline_timer.hpp
+++ b/src/util/monotonic_deadline_timer.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2014 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -26,9 +26,10 @@
#ifndef NDN_UTIL_MONOTONIC_DEADLINE_TIMER_HPP
#define NDN_UTIL_MONOTONIC_DEADLINE_TIMER_HPP
-#include <boost/asio.hpp>
#include "time.hpp"
+#include <boost/asio/basic_deadline_timer.hpp>
+
namespace boost {
namespace asio {
diff --git a/src/util/network-monitor.hpp b/src/util/network-monitor.hpp
index f3fc6b8..dae4941 100644
--- a/src/util/network-monitor.hpp
+++ b/src/util/network-monitor.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -24,7 +24,12 @@
#include "signal.hpp"
-#include <boost/asio/io_service.hpp>
+// forward declaration
+namespace boost {
+namespace asio {
+class io_service;
+} // namespace asio
+} // namespace boost
namespace ndn {
namespace util {
diff --git a/tests/integrated/network-monitor.cpp b/tests/integrated/network-monitor.cpp
index 9ed4bb3..cbc0e8a 100644
--- a/tests/integrated/network-monitor.cpp
+++ b/tests/integrated/network-monitor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -25,11 +25,13 @@
#include "util/network-monitor.hpp"
-#include "boost-test.hpp"
-#include <cstdlib>
-#include <iostream>
#include "util/time.hpp"
+#include "boost-test.hpp"
+
+#include <boost/asio/io_service.hpp>
+#include <iostream>
+
namespace ndn {
namespace util {
diff --git a/tests/unit-tests/unit-test-time-fixture.hpp b/tests/unit-tests/unit-test-time-fixture.hpp
index 9c349fb..8d7ac17 100644
--- a/tests/unit-tests/unit-test-time-fixture.hpp
+++ b/tests/unit-tests/unit-test-time-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,7 +23,8 @@
#define NDN_TESTS_UNIT_TESTS_UNIT_TEST_TIME_FIXTURE_HPP
#include "util/time-unit-test-clock.hpp"
-#include <boost/asio.hpp>
+
+#include <boost/asio/io_service.hpp>
namespace ndn {
namespace tests {
diff --git a/tests/unit-tests/util/dns.t.cpp b/tests/unit-tests/util/dns.t.cpp
index 630295b..be94ba9 100644
--- a/tests/unit-tests/util/dns.t.cpp
+++ b/tests/unit-tests/util/dns.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 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 "boost-test.hpp"
#include "../network-configuration-detector.hpp"
+
+#include <boost/asio.hpp>
#include <boost/lexical_cast.hpp>
namespace ndn {