model: A couple of tricks and fixes in NDN.cxx, so it will play nice with python bindings

Refs #1011 (http://redmine.named-data.net/issues/1011)
diff --git a/bindings/scan-header.h b/bindings/scan-header.h
new file mode 100644
index 0000000..7d35e18
--- /dev/null
+++ b/bindings/scan-header.h
@@ -0,0 +1,58 @@
+/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/* 
+ * Copyright (c) 2013, Regents of the University of California
+ *                     Alexander Afanasyev
+ * 
+ * GNU 3.0 license, See the LICENSE file for more information
+ * 
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ns3/ndnSIM-module.h"
+
+using namespace ns3;
+using namespace ndn;
+
+static inline void
+__dummy_function_on_interest_callback_instantiation (Ptr<const Name>, Ptr<const Interest>)
+{
+}
+
+static inline void
+__dummy_function_on_data_callback_instantiation (Ptr<const Interest>, Ptr<const ContentObject>)
+{
+}
+
+static inline void
+__dummy_function_on_timeout_callback_instantiation (Ptr<const Interest>)
+{
+}
+
+static inline void
+__dummy_function_to_force_ndn_api_face_callback_instantiations ()
+{
+  ApiFace face (0);
+  Ptr<Interest> interest;
+  Ptr<Name> prefix;
+
+  face.ExpressInterest (interest,
+                        MakeCallback (__dummy_function_on_data_callback_instantiation),
+                        MakeCallback (__dummy_function_on_timeout_callback_instantiation)
+                        );
+
+  face.SetInterestFilter (prefix,
+                          MakeCallback (__dummy_function_on_interest_callback_instantiation));
+
+  std::string tmp ("bla");
+  char &test = tmp[0];
+}
+
+
+// /// @cond include_hidden
+// #ifdef PYTHON_SCAN
+// struct CallbackVoidNameInterest : public Callback<void, Ptr<const Name>, Ptr<const Interest> > { };
+// struct CallbackVoidInterestContentObject : public Callback<void, Ptr<const Interest>, Ptr<const ContentObject> > { };
+// struct CallbackVoidInterest : public Callback<void, Ptr<const Interest> > { };
+// #endif
+// /// @endcond
+
diff --git a/ndn.cxx/blob.h b/ndn.cxx/blob.h
index f00d08e..4b488b3 100644
--- a/ndn.cxx/blob.h
+++ b/ndn.cxx/blob.h
@@ -16,16 +16,31 @@
 #include "ns3/ndn-common.h"
 
 #include <vector>
-#include <cstddef>
 
 NDN_NAMESPACE_BEGIN
 
 /**
  * @brief Class representing a general-use binary blob
  */
-class Blob : public std::vector<char>
+class Blob
 {
 public:
+  typedef std::vector<char> base;
+  
+  typedef base::value_type             value_type;
+  typedef base::pointer                pointer;
+  typedef base::const_pointer          const_pointer;
+  typedef base::reference              reference;
+  typedef base::const_reference        const_reference;
+  typedef base::iterator               iterator;
+  typedef base::const_iterator         const_iterator;
+  typedef base::const_reverse_iterator const_reverse_iterator;
+  typedef base::reverse_iterator       reverse_iterator;
+  typedef base::size_type              size_type;
+  typedef base::difference_type        difference_type;
+  typedef base::allocator_type         allocator_type;
+  
+public:
   /**
    * @brief Creates an empty blob
    */
@@ -33,8 +48,13 @@
   {
   }
 
+  Blob (const std::string &data)
+    : m_data (data.begin (), data.end ())
+  {
+  }
+
   Blob (const void *buf, size_t length)
-    : std::vector<char> (reinterpret_cast<const char*> (buf), reinterpret_cast<const char*> (buf) + length)
+    : m_data (reinterpret_cast<const char*> (buf), reinterpret_cast<const char*> (buf) + length)
   {
   }
   
@@ -44,7 +64,7 @@
   inline char*
   buf ()
   {
-    return &front ();
+    return &m_data.front ();
   }
 
   /**
@@ -53,10 +73,57 @@
   inline const char*
   buf () const
   {
-    return &front ();
+    return &m_data.front ();
   }
+
+  iterator begin () { return m_data.begin (); }
+  const_iterator begin () const { return m_data.begin (); }
+  iterator end () { return m_data.end (); }
+  const_iterator end () const { return m_data.end (); }
+  size_t size () const { return m_data.size (); }
+
+  void swap (Blob &x) { m_data.swap (x.m_data); }
+  void push_back (value_type val) { m_data.push_back (val); }
+
+  bool empty () const { return m_data.empty (); }
+
+  Blob &
+  operator = (const Blob &other) { m_data = other.m_data; return *this; }
+
+  reference operator [] (size_type pos) { return m_data [pos]; }
+  const_reference operator [] (size_type pos) const { return m_data [pos]; }
+
+  char getItem (size_type pos) const { return m_data [pos]; }
+
+  void clear () { m_data.clear (); }
+
+private:
+  friend bool operator == (const Blob &a, const Blob &b);
+  friend bool operator <  (const Blob &a, const Blob &b);
+  friend bool operator <= (const Blob &a, const Blob &b);
+  friend bool operator >  (const Blob &a, const Blob &b);
+  friend bool operator >= (const Blob &a, const Blob &b);
+
+private:
+  std::vector< char > m_data;
 };
 
+inline bool operator == (const Blob &a, const Blob &b)  { return a.m_data == b.m_data; }
+inline bool operator <  (const Blob &a, const Blob &b)  { return a.m_data <  b.m_data; }
+inline bool operator <= (const Blob &a, const Blob &b)  { return a.m_data <= b.m_data; }
+inline bool operator >  (const Blob &a, const Blob &b)  { return a.m_data >  b.m_data; }
+inline bool operator >= (const Blob &a, const Blob &b)  { return a.m_data >= b.m_data; }
+
 NDN_NAMESPACE_END
 
+#include <boost/functional/hash.hpp>
+namespace boost
+{
+inline std::size_t
+hash_value (const ns3::ndn::Blob v)
+{
+  return boost::hash_range (v.begin(), v.end());
+}
+}
+
 #endif // NDN_BLOB_H
diff --git a/ndn.cxx/exclude.cc b/ndn.cxx/exclude.cc
index 16c78bc..f8137eb 100644
--- a/ndn.cxx/exclude.cc
+++ b/ndn.cxx/exclude.cc
@@ -150,6 +150,11 @@
   return *this;
 }
 
+void
+Exclude::appendExclude (const name::Component &name, bool any)
+{
+  m_exclude.insert (std::make_pair (name, any));
+}
 
 std::ostream&
 operator << (std::ostream &os, const Exclude &exclude)
diff --git a/ndn.cxx/name-component.cc b/ndn.cxx/name-component.cc
index 8aa522c..084d6be 100644
--- a/ndn.cxx/name-component.cc
+++ b/ndn.cxx/name-component.cc
@@ -23,19 +23,19 @@
 
 Component::Component (const std::string &uri)
 {
-  copy (uri.begin (), uri.end (), back_inserter (*this));
+  copy (uri.begin (), uri.end (), std::back_inserter (*this));
 }
 
 Component::Component (std::string::const_iterator begin, std::string::const_iterator end)
 {
-  copy (begin, end, back_inserter (*this));
+  copy (begin, end, std::back_inserter (*this));
 }
 
 Component::Component (const void *buf, size_t length)
 {
   copy (static_cast<const char*> (buf),
         static_cast<const char*> (buf)+length,
-        back_inserter (*this));
+        std::back_inserter (*this));
 }
 
 Component &
@@ -43,7 +43,7 @@
 {
   try
     {
-      Uri::fromEscaped (uri.begin (), uri.end (), back_inserter (*this));
+      Uri::fromEscaped (uri.begin (), uri.end (), std::back_inserter (*this));
     }
   catch (error::Uri &err)
     {
@@ -61,7 +61,7 @@
 {
   try
     {
-      Uri::fromEscaped (begin, end, back_inserter (*this));
+      Uri::fromEscaped (begin, end, std::back_inserter (*this));
     }
   catch (error::Uri &err)
     {
diff --git a/ndn.cxx/name-component.h b/ndn.cxx/name-component.h
index e1b7296..7f523e0 100644
--- a/ndn.cxx/name-component.h
+++ b/ndn.cxx/name-component.h
@@ -11,11 +11,7 @@
 #ifndef NDN_NAME_COMPONENT_H
 #define NDN_NAME_COMPONENT_H
 
-#include <string>
-#include <vector>
-
 #include "blob.h"
-#include <stdint.h>
 
 NDN_NAMESPACE_BEGIN
 
@@ -24,7 +20,7 @@
 /**
  * @brief Class to representing binary blob of NDN name component
  *
- * This class is based on std::vector<char> and just provides several helpers
+ * This class is based on Blob (std::vector<char>) and just provides several helpers
  * to work with name components, as well as operator to apply canonical
  * ordering on name components
  */
@@ -290,8 +286,12 @@
 /**
  * @brief Stream output operator (output in escaped URI format)
  */
-std::ostream&
-operator <<(std::ostream &os, const Component &name);
+inline std::ostream&
+operator <<(std::ostream &os, const Component &name)
+{
+  name.toUri (os);
+  return os;
+}
 
 } // name
 
diff --git a/ndn.cxx/ndn-api-face.h b/ndn.cxx/ndn-api-face.h
index 4b88f51..78f482a 100644
--- a/ndn.cxx/ndn-api-face.h
+++ b/ndn.cxx/ndn-api-face.h
@@ -117,16 +117,7 @@
   ApiFacePriv *m_this;
 };
 
-
-/// @cond include_hidden
-#ifdef PYTHON_SCAN
-struct CallbackVoidNameInterest : public Callback<void, Ptr<const Name>, Ptr<const Interest> > { };
-struct CallbackVoidInterestContentObject : public Callback<void, Ptr<const Interest>, Ptr<const ContentObject> > { };
-struct CallbackVoidInterest : public Callback<void, Ptr<const Interest> > { };
-#endif
-/// @endcond
-
-}
-}
+} // ndn
+} // ns3
 
 #endif // NDN_API_HANDLER_H
diff --git a/wscript b/wscript
index fb00647..f192ace 100644
--- a/wscript
+++ b/wscript
@@ -137,9 +137,9 @@
         "model/ndn-name-components.h",
         "model/ndn-name.h",
 
-        "ndn.cxx/name.h",
-        "ndn.cxx/name-component.h",
         "ndn.cxx/blob.h",
+        "ndn.cxx/name-component.h",
+        "ndn.cxx/name.h",
         "ndn.cxx/exclude.h",
         "ndn.cxx/ndn-api-face.h",