src: Creating daemon/common.hpp for all generic includes and import of commonly used abstractions to ndn namespace

This commit also update CS interface (find should return
shared_ptr<Data>, CS entry is internal to CS, the design diagrams are
corrected too).

Change-Id: Ib6377b6d9b8478640ac35d3cfb6c9180cc57c4fe
diff --git a/daemon/common.hpp b/daemon/common.hpp
new file mode 100644
index 0000000..05553b6
--- /dev/null
+++ b/daemon/common.hpp
@@ -0,0 +1,30 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NFD_COMMON_HPP
+#define NFD_COMMON_HPP
+
+#include <ndn-cpp-dev/interest.hpp>
+#include <ndn-cpp-dev/data.hpp>
+
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
+#include <boost/bind.hpp>
+
+#include <vector>
+
+namespace ndn {
+
+using boost::noncopyable;
+using boost::shared_ptr;
+using boost::make_shared;
+using boost::function;
+using boost::bind;
+
+} // namespace ndn
+
+#endif // NFD_COMMON_HPP
diff --git a/daemon/table/cs-entry.hpp b/daemon/table/cs-entry.hpp
index adb2b8c..1726d87 100644
--- a/daemon/table/cs-entry.hpp
+++ b/daemon/table/cs-entry.hpp
@@ -4,9 +4,11 @@
  * See COPYING for copyright and distribution information.
  */
 
-#ifndef NFD_TABLE_CS_ENTRY_H
-#define NFD_TABLE_CS_ENTRY_H
-#include <boost/utility.hpp>
+#ifndef NFD_TABLE_CS_ENTRY_HPP
+#define NFD_TABLE_CS_ENTRY_HPP
+
+#include "common.hpp"
+
 namespace ndn {
 namespace cs {
 
@@ -14,10 +16,11 @@
  *  \brief represents a CS entry
  */
 
-class Entry : boost::noncopyable
+class Entry : noncopyable
 {
 };
 
-};//namespace cs
-};//namespace ndn
-#endif//NFD_TABLE_CS_ENTRY_H
+} // namespace cs
+} // namespace ndn
+
+#endif // NFD_TABLE_CS_ENTRY_HPP
diff --git a/daemon/table/cs.cpp b/daemon/table/cs.cpp
index fdf5168..d437dbd 100644
--- a/daemon/table/cs.cpp
+++ b/daemon/table/cs.cpp
@@ -7,6 +7,7 @@
 // XXX This is a fake CS that does not cache anything.
 
 #include "cs.hpp"
+
 namespace ndn {
 
 Cs::Cs()
@@ -18,16 +19,16 @@
 }
 
 bool
-Cs::insert(boost::shared_ptr<Data> data)
+Cs::insert(shared_ptr<Data> data)
 {
   return false;
 }
   
-boost::shared_ptr<cs::Entry>
+shared_ptr<Data>
 Cs::find(const Interest& interest)
 {
-  return boost::shared_ptr<cs::Entry>();
+  return shared_ptr<Data>();
 }
 
 
-};//namespace ndn
+} //namespace ndn
diff --git a/daemon/table/cs.hpp b/daemon/table/cs.hpp
index 67283b6..c1c3e37 100644
--- a/daemon/table/cs.hpp
+++ b/daemon/table/cs.hpp
@@ -4,18 +4,18 @@
  * See COPYING for copyright and distribution information.
  */
 
-#ifndef NFD_TABLE_CS_H
-#define NFD_TABLE_CS_H
-#include <boost/shared_ptr.hpp>
-#include <ndn-cpp-dev/interest.hpp>
-#include <ndn-cpp-dev/data.hpp>
+#ifndef NFD_TABLE_CS_HPP
+#define NFD_TABLE_CS_HPP
+
+#include "common.hpp"
 #include "cs-entry.hpp"
+
 namespace ndn {
 
 /** \class Cs
  *  \brief represents the ContentStore
  */
-class Cs : boost::noncopyable
+class Cs : noncopyable
 {
 public:
   Cs();
@@ -30,14 +30,15 @@
    *  \return{ whether the Data is added }
    */
   bool
-  insert(boost::shared_ptr<Data> data);
+  insert(shared_ptr<Data> data);
   
   /** \brief finds the best match Data for an Interest
    *  \return{ the best match, if any; otherwise null }
    */
-  boost::shared_ptr<cs::Entry>
+  shared_ptr<Data>
   find(const Interest& interest);
 };
 
-};//namespace ndn
-#endif//NFD_TABLE_CS_H
+} // namespace ndn
+
+#endif // NFD_TABLE_CS_HPP
diff --git a/daemon/util/event-emitter.hpp b/daemon/util/event-emitter.hpp
index fa7de00..4499eaa 100644
--- a/daemon/util/event-emitter.hpp
+++ b/daemon/util/event-emitter.hpp
@@ -4,11 +4,11 @@
  * See COPYING for copyright and distribution information.
  */
 
-#ifndef NFD_UTIL_EVENT_EMITTER_H
-#define NFD_UTIL_EVENT_EMITTER_H
-#include <vector>
-#include <boost/utility.hpp>
-#include <boost/function.hpp>
+#ifndef NFD_UTIL_EVENT_EMITTER_HPP
+#define NFD_UTIL_EVENT_EMITTER_HPP
+
+#include "common.hpp"
+
 namespace ndn {
 
 struct empty {};
@@ -30,11 +30,11 @@
 // four arguments
 template<typename T1 = empty, typename T2 = empty,
     typename T3 = empty, typename T4 = empty>
-class EventEmitter : boost::noncopyable
+class EventEmitter : noncopyable
 {
 public:
   /// represents a handler that can subscribe to the event
-  typedef boost::function<void(const T1&, const T2&,
+  typedef function<void(const T1&, const T2&,
                                const T3&, const T4&)> Handler;
   
   /// adds an subscription
@@ -61,10 +61,10 @@
 
 // zero argument
 template<>
-class EventEmitter<empty, empty, empty, empty> : boost::noncopyable
+class EventEmitter<empty, empty, empty, empty> : noncopyable
 {
 public:
-  typedef boost::function<void()> Handler;
+  typedef function<void()> Handler;
   
   void
   operator+=(Handler handler);
@@ -85,10 +85,10 @@
 
 // one argument
 template<typename T1>
-class EventEmitter<T1, empty, empty, empty> : boost::noncopyable
+class EventEmitter<T1, empty, empty, empty> : noncopyable
 {
 public:
-  typedef boost::function<void(const T1&)> Handler;
+  typedef function<void(const T1&)> Handler;
   
   void
   operator+=(Handler handler);
@@ -109,10 +109,10 @@
 
 // two arguments
 template<typename T1, typename T2>
-class EventEmitter<T1, T2, empty, empty> : boost::noncopyable
+class EventEmitter<T1, T2, empty, empty> : noncopyable
 {
 public:
-  typedef boost::function<void(const T1&, const T2&)> Handler;
+  typedef function<void(const T1&, const T2&)> Handler;
   
   void
   operator+=(Handler handler);
@@ -133,11 +133,10 @@
 
 // three arguments
 template<typename T1, typename T2, typename T3>
-class EventEmitter<T1, T2, T3, empty> : boost::noncopyable
+class EventEmitter<T1, T2, T3, empty> : noncopyable
 {
 public:
-  typedef boost::function<void(const T1&, const T2&,
-                               const T3&)> Handler;
+  typedef function<void(const T1&, const T2&, const T3&)> Handler;
   
   void
   operator+=(Handler handler);
@@ -321,5 +320,6 @@
 }
 
 
-};//namespace ndn
-#endif//NFD_UTIL_EVENT_EMITTER_H
+} // namespace ndn
+
+#endif // NFD_UTIL_EVENT_EMITTER_HPP
diff --git a/tests/table/cs.cpp b/tests/table/cs.cpp
index 31a7ea2..3cb9993 100644
--- a/tests/table/cs.cpp
+++ b/tests/table/cs.cpp
@@ -5,8 +5,9 @@
  */
 
 #include "table/cs.hpp"
-#include <boost/make_shared.hpp>
+
 #include <boost/test/unit_test.hpp>
+
 namespace ndn {
 
 BOOST_AUTO_TEST_SUITE(TableCs)
@@ -15,12 +16,13 @@
 {
   Cs cs;
   
-  boost::shared_ptr<Data> data = boost::make_shared<Data>();
+  shared_ptr<Data> data = make_shared<Data>();
   BOOST_CHECK_EQUAL(cs.insert(data), false);
   
   Interest interest;
-  BOOST_CHECK_EQUAL(cs.find(interest).get(), static_cast<cs::Entry*>(0));
+  BOOST_CHECK_EQUAL(static_cast<bool>(cs.find(interest)), false);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
-};//namespace ndn
+
+} // namespace ndn
diff --git a/tests/util/event-emitter.cpp b/tests/util/event-emitter.cpp
index 057b920..e49c5e9 100644
--- a/tests/util/event-emitter.cpp
+++ b/tests/util/event-emitter.cpp
@@ -4,12 +4,13 @@
  * See COPYING for copyright and distribution information.
  */
 
-#include <util/event-emitter.hpp>
-#include <boost/bind.hpp>
 #include <boost/test/unit_test.hpp>
+
+#include "util/event-emitter.hpp"
+
 namespace ndn {
 
-class EventEmitterTester : boost::noncopyable
+class EventEmitterTester : noncopyable
 {
 public:
   EventEmitterTester();
@@ -129,8 +130,8 @@
   EventEmitterTester eet1;
   EventEmitterTester eet2;
   EventEmitter<> ee;
-  ee += boost::bind(&EventEmitterTester::f0, &eet1);
-  ee += boost::bind(&EventEmitterTester::f0, &eet2);
+  ee += bind(&EventEmitterTester::f0, &eet1);
+  ee += bind(&EventEmitterTester::f0, &eet2);
   ee();
   
   BOOST_CHECK_EQUAL(eet1.m_hit, 1);
@@ -141,7 +142,7 @@
 {
   EventEmitterTester eet;
   EventEmitter<> ee;
-  ee += boost::bind(&EventEmitterTester::f0, &eet);
+  ee += bind(&EventEmitterTester::f0, &eet);
   ee();
   
   BOOST_CHECK_EQUAL(eet.m_hit, 1);
@@ -151,7 +152,7 @@
 {
   EventEmitterTester eet;
   EventEmitter<int> ee;
-  ee += boost::bind(&EventEmitterTester::f1, &eet, _1);
+  ee += bind(&EventEmitterTester::f1, &eet, _1);
   ee(11);
   
   BOOST_CHECK_EQUAL(eet.m_hit, 1);
@@ -162,7 +163,7 @@
 {
   EventEmitterTester eet;
   EventEmitter<int,int> ee;
-  ee += boost::bind(&EventEmitterTester::f2, &eet, _1, _2);
+  ee += bind(&EventEmitterTester::f2, &eet, _1, _2);
   ee(21, 22);
   
   BOOST_CHECK_EQUAL(eet.m_hit, 1);
@@ -174,7 +175,7 @@
 {
   EventEmitterTester eet;
   EventEmitter<int,int,int> ee;
-  ee += boost::bind(&EventEmitterTester::f3, &eet, _1, _2, _3);
+  ee += bind(&EventEmitterTester::f3, &eet, _1, _2, _3);
   ee(31, 32, 33);
   
   BOOST_CHECK_EQUAL(eet.m_hit, 1);
@@ -187,7 +188,7 @@
 {
   EventEmitterTester eet;
   EventEmitter<int,int,int,int> ee;
-  ee += boost::bind(&EventEmitterTester::f4, &eet, _1, _2, _3, _4);
+  ee += bind(&EventEmitterTester::f4, &eet, _1, _2, _3, _4);
   ee(41, 42, 43, 44);
   
   BOOST_CHECK_EQUAL(eet.m_hit, 1);
@@ -226,4 +227,5 @@
 }
 
 BOOST_AUTO_TEST_SUITE_END()
-};//namespace ndn
+
+} // namespace ndn
diff --git a/wscript b/wscript
index c3b46b1..8f1f372 100644
--- a/wscript
+++ b/wscript
@@ -56,6 +56,7 @@
         features = "cxx",
         source = bld.path.ant_glob(['daemon/**/*.cpp'], excl=['daemon/main.cpp']),
         use = 'BOOST NDN_CPP',
+        includes = [".", "daemon"],
         )
 
     bld(target = "nfd",