Small source movements (ccn_* to ccn/). Small change of NameBuilder implementation

diff --git a/model/ccn/README b/model/ccn/README
new file mode 100644
index 0000000..6b9ef69
--- /dev/null
+++ b/model/ccn/README
@@ -0,0 +1,2 @@
+This directory contains files borrowed and adapted from CCNx implementation
+
diff --git a/model/ccn_ccn.h b/model/ccn/ccn.h
similarity index 100%
rename from model/ccn_ccn.h
rename to model/ccn/ccn.h
diff --git a/model/ccn_buf_decoder.cc b/model/ccn/ccn_buf_decoder.c
similarity index 99%
rename from model/ccn_buf_decoder.cc
rename to model/ccn/ccn_buf_decoder.c
index 8c1c5f0..5e1d713 100644
--- a/model/ccn_buf_decoder.cc
+++ b/model/ccn/ccn_buf_decoder.c
@@ -29,7 +29,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include "ccn_ccn.h"
+#include "ccn.h"
 #include "ccn_charbuf.h"
 #include "ccn_coding.h"
 #include "ccn_indexbuf.h"
diff --git a/model/ccn_buf_encoder.cc b/model/ccn/ccn_buf_encoder.c
similarity index 98%
rename from model/ccn_buf_encoder.cc
rename to model/ccn/ccn_buf_encoder.c
index d43f8e3..cc34551 100644
--- a/model/ccn_buf_encoder.cc
+++ b/model/ccn/ccn_buf_encoder.c
@@ -32,7 +32,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/time.h>
-#include "ccn_ccn.h"
+#include "ccn.h"
 #include "ccn_charbuf.h"
 #include "ccn_coding.h"
 #include "ccn_indexbuf.h"
diff --git a/model/ccn_charbuf.cc b/model/ccn/ccn_charbuf.c
similarity index 100%
rename from model/ccn_charbuf.cc
rename to model/ccn/ccn_charbuf.c
diff --git a/model/ccn_charbuf.h b/model/ccn/ccn_charbuf.h
similarity index 100%
rename from model/ccn_charbuf.h
rename to model/ccn/ccn_charbuf.h
diff --git a/model/ccn_coding.cc b/model/ccn/ccn_coding.c
similarity index 100%
rename from model/ccn_coding.cc
rename to model/ccn/ccn_coding.c
diff --git a/model/ccn_coding.h b/model/ccn/ccn_coding.h
similarity index 100%
rename from model/ccn_coding.h
rename to model/ccn/ccn_coding.h
diff --git a/model/ccn_indexbuf.cc b/model/ccn/ccn_indexbuf.c
similarity index 100%
rename from model/ccn_indexbuf.cc
rename to model/ccn/ccn_indexbuf.c
diff --git a/model/ccn_indexbuf.h b/model/ccn/ccn_indexbuf.h
similarity index 100%
rename from model/ccn_indexbuf.h
rename to model/ccn/ccn_indexbuf.h
diff --git a/model/ccn_name_util.cc b/model/ccn/ccn_name_util.c
similarity index 98%
rename from model/ccn_name_util.cc
rename to model/ccn/ccn_name_util.c
index 87baa11..94f3991 100644
--- a/model/ccn_name_util.cc
+++ b/model/ccn/ccn_name_util.c
@@ -25,7 +25,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include "ccn_random.h"
-#include "ccn_ccn.h"
+#include "ccn.h"
 
 /**
  * @file ccn_name_util.c
diff --git a/model/ccn_name_util.h b/model/ccn/ccn_name_util.h
similarity index 100%
rename from model/ccn_name_util.h
rename to model/ccn/ccn_name_util.h
diff --git a/model/ccn_random.cc b/model/ccn/ccn_random.c
similarity index 100%
rename from model/ccn_random.cc
rename to model/ccn/ccn_random.c
diff --git a/model/ccn_random.h b/model/ccn/ccn_random.h
similarity index 100%
rename from model/ccn_random.h
rename to model/ccn/ccn_random.h
diff --git a/model/ndn_contentpacket.h b/model/ndn_contentpacket.h
index 6e7a2e3..bd8abd0 100644
--- a/model/ndn_contentpacket.h
+++ b/model/ndn_contentpacket.h
@@ -23,7 +23,7 @@
 
 #include "ns3/header.h"
 #include <ns3/packet.h>
-#include "ccn_ccn.h"
+#include "ccn/ccn.h"
 
 namespace ns3
 {
diff --git a/model/ndn_interestpacket.cc b/model/ndn_interestpacket.cc
index 5c5fd39..66deaf2 100644
--- a/model/ndn_interestpacket.cc
+++ b/model/ndn_interestpacket.cc
@@ -62,7 +62,7 @@
     InterestPacket::AddNonce(uint32_t nonce)
     {
         NonceHeader tHeader (nonce);
-        AddHeader (tHeader);    
+        AddHeader (tHeader);
     }
     
     uint32_t
diff --git a/model/ndn_namebuilder.cc b/model/ndn_namebuilder.cc
index df22e62..8f65647 100644
--- a/model/ndn_namebuilder.cc
+++ b/model/ndn_namebuilder.cc
@@ -19,28 +19,43 @@
  */
 
 #include "ndn_namebuilder.h"
+#include <ccn/ccn.h>
 
-namespace ns3 
+using namespace std;
+
+namespace ns3 {
+namespace NDNabstraction {
+
+NameBuilder::NameBuilder ()
 {
-namespace NDNabstraction
+  m_value = ccn_charbuf_create ();
+  ccn_name_init(m_value);
+}
+
+NameBuilder::NameBuilder (const string &s)
 {
-    NameBuilder::NameBuilder()
-    {
-        m_value = ccn_charbuf_create();
-        ccn_name_init(m_value);
-    }
-    
-    ccn_charbuf*
-    NameBuilder::GetName()
-    {
-        return m_value;
-    }
-    
-    void
-    NameBuilder::AddComponent(string s)
-    {
-        
-        ccn_name_append_str(m_value,s.c_str());
-    }
+  m_value = ccn_charbuf_create ();
+  ccn_name_init(m_value);
+  (*this) (s);
+}
+
+NameBuilder::~NameBuilder ()
+{
+  ccn_charbuf_destroy(&m_value);
+}
+
+const ccn_charbuf*
+NameBuilder::GetName () const
+{
+  return m_value;
+}
+
+NameBuilder&
+NameBuilder::operator () (const string &s)
+{
+  ccn_name_append_str (m_value,s.c_str());
+  return *this;
+}
+
 }
 }
diff --git a/model/ndn_namebuilder.h b/model/ndn_namebuilder.h
index b883414..1b54bfe 100644
--- a/model/ndn_namebuilder.h
+++ b/model/ndn_namebuilder.h
@@ -18,24 +18,30 @@
  * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
  */
 
-#include "ccn_ccn.h"
+#ifndef _NDN_NAMEBUILDER_H_
+#define _NDN_NAMEBUILDER_H_
+
 #include <string>
 
-using namespace std;
+class ccn_charbuf;
 
-namespace ns3 
+namespace ns3 {
+namespace NDNabstraction {
+  
+class NameBuilder
 {
-namespace NDNabstraction
-{
-    class NameBuilder
-    {
-    public:
-        NameBuilder();
-        ccn_charbuf* GetName();
-        void AddComponent(string s);
-        //TODO add more overloads
-    private:
-        ccn_charbuf *m_value;
-    };
+public:
+  NameBuilder ();
+  NameBuilder (const std::string &s);
+  ~NameBuilder ();
+  
+  const ccn_charbuf* GetName () const;
+  NameBuilder& operator () (const std::string &s);
+private:
+  ccn_charbuf *m_value;
+};
+
 }
 }
+#endif // _NDN_NAMEBUILDER_H_
+
diff --git a/model/ndn_stupidinterestgenerator.cc b/model/ndn_stupidinterestgenerator.cc
index 629d48f..5bc1861 100644
--- a/model/ndn_stupidinterestgenerator.cc
+++ b/model/ndn_stupidinterestgenerator.cc
@@ -13,6 +13,8 @@
 #include "ndn_interestpacket.h"
 #include "ndn_namebuilder.h"
 
+#include "ccn/ccn_charbuf.h"
+
 NS_LOG_COMPONENT_DEFINE ("StupidInterestGenerator");
 
 namespace ns3
@@ -159,11 +161,9 @@
         NS_LOG_LOGIC ("sending packet at " << Simulator::Now ());
         NS_ASSERT (m_sendEvent.IsExpired ());
         
-        NameBuilder name;        
-        name.AddComponent("prefix1");
-        name.AddComponent("prefix2");
-        name.AddComponent("filename");
-        ccn_charbuf *output = name.GetName();
+        NameBuilder name;
+		name("prefix1")("prefix2")("filename");
+        const ccn_charbuf *output = name.GetName();
         Ptr<InterestPacket> packet = Create<InterestPacket>(output->buf,(uint32_t)output->length);
         packet->AddTimeout(4000);
         UniformVariable var;
@@ -174,4 +174,4 @@
     }
 
 //}
-}
\ No newline at end of file
+}
diff --git a/model/ndn_stupidinterestgenerator.h b/model/ndn_stupidinterestgenerator.h
index 6407d32..0a8f396 100644
--- a/model/ndn_stupidinterestgenerator.h
+++ b/model/ndn_stupidinterestgenerator.h
@@ -13,7 +13,7 @@
 #include "ns3/nstime.h"
 #include "ns3/event-id.h"
 #include "ns3/ptr.h"
-#include "ccn_ccn.h"
+#include <ccn/ccn.h>
 #include "ns3/udp-socket-factory.h"
 
 namespace ns3 
@@ -75,4 +75,4 @@
 
     };
 //}
-}
\ No newline at end of file
+}