model: Major API changes

Interest and ContentObject are no longer derived from Header class.
Instead, they are encapsulating payload and, optionally, wire-formatted
Packet object.

Refs #1005 (http://redmine.named-data.net/)
diff --git a/model/ndn-content-object.cc b/model/ndn-content-object.cc
index 052cd4a..d287ca7 100644
--- a/model/ndn-content-object.cc
+++ b/model/ndn-content-object.cc
@@ -33,22 +33,21 @@
 NS_OBJECT_ENSURE_REGISTERED (ContentObject);
 NS_OBJECT_ENSURE_REGISTERED (ContentObjectTail);
 
-TypeId
-ContentObject::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::ndn::ContentObject")
-    .SetGroupName ("Ndn")
-    .SetParent<Header> ()
-    .AddConstructor<ContentObject> ()
-    ;
-  return tid;
-}
-
 ContentObject::ContentObject ()
   : m_signature (0)
 {
 }
 
+ContentObject::ContentObject (const ContentObject &other)
+  : m_name (Create<Name> (other.GetName ()))
+  , m_freshness (other->GetFreshness ())
+  , m_timestamp (other->GetTimestamp ())
+  , m_signature (other->GetSignature ())
+  , m_payload (other->GetPayload ()->Copy ())
+  , m_wire (0)
+{
+}
+
 void
 ContentObject::SetName (Ptr<Name> name)
 {
@@ -111,114 +110,6 @@
   return m_signature;
 }
 
-uint32_t
-ContentObject::GetSerializedSize () const
-{
-  uint32_t size = 1 + 1 + 2 +
-    ((2 + 2) + (m_name->GetSerializedSize ()) + (2 + 2 + 4 + 2 + 2 + (2 + 0)));
-  if (m_signature != 0)
-    size += 4;
-  
-  NS_LOG_INFO ("Serialize size = " << size);
-  return size;
-}
-
-void
-ContentObject::Serialize (Buffer::Iterator start) const
-{
-  start.WriteU8 (0x80); // version
-  start.WriteU8 (0x01); // packet type
-  start.WriteU16 (GetSerializedSize () - 4); // length
-  
-  if (m_signature != 0)
-    {
-      start.WriteU16 (6); // signature length
-      start.WriteU16 (0xFF00); // "fake" simulator signature
-      start.WriteU32 (m_signature);
-    }
-  else
-    {
-      start.WriteU16 (2); // signature length
-      start.WriteU16 (0); // empty signature
-    }
-
-  // name
-  uint32_t offset = m_name->Serialize (start);
-  NS_LOG_DEBUG ("Offset: " << offset);
-  start.Next (offset);
-
-  // content
-  // for now assume that contentdata length is zero
-  start.WriteU16 (2 + 4 + 2 + 2 + (2 + 0));
-  start.WriteU16 (4 + 2 + 2 + (2 + 0));
-  start.WriteU32 (static_cast<uint32_t> (m_timestamp.ToInteger (Time::S)));
-  start.WriteU16 (static_cast<uint16_t> (m_freshness.ToInteger (Time::S)));
-  start.WriteU16 (0); // reserved 
-  start.WriteU16 (0); // Length (ContentInfoOptions)
-
-  // that's it folks
-}
-
-
-uint32_t
-ContentObject::Deserialize (Buffer::Iterator start)
-{
-  Buffer::Iterator i = start;
-
-  if (i.ReadU8 () != 0x80)
-    throw new ContentObjectException ();
-
-  if (i.ReadU8 () != 0x01)
-    throw new ContentObjectException ();
-
-  i.ReadU16 (); // length
-
-  uint32_t signatureLength = i.ReadU16 ();
-  if (signatureLength == 6)
-    {
-      if (i.ReadU16 () != 0xFF00) // signature type
-        throw new ContentObjectException ();
-      m_signature = i.ReadU32 ();
-    }
-  else if (signatureLength == 2)
-    {
-      if (i.ReadU16 () != 0) // signature type
-        throw new ContentObjectException ();
-      m_signature = 0;
-    }
-  else
-    throw new ContentObjectException ();
-
-  m_name = Create<Name> ();
-  uint32_t offset = m_name->Deserialize (i);
-  i.Next (offset);
-
-  if (i.ReadU16 () != (2 + 4 + 2 + 2 + (2 + 0))) // content length
-    throw new ContentObjectException ();
-
-  if (i.ReadU16 () != (4 + 2 + 2 + (2 + 0))) // Length (content Info)
-    throw new ContentObjectException ();
-
-  m_timestamp = Seconds (i.ReadU32 ());
-  m_freshness = Seconds (i.ReadU16 ());
-
-  if (i.ReadU16 () != 0) // Reserved
-    throw new ContentObjectException ();
-  if (i.ReadU16 () != 0) // Length (ContentInfoOptions)
-    throw new ContentObjectException ();
-
-  NS_ASSERT_MSG (i.GetDistanceFrom (start) == GetSerializedSize (),
-                 "Something wrong with ContentObject::Deserialize");
-  
-  return i.GetDistanceFrom (start);
-}
-  
-TypeId
-ContentObject::GetInstanceTypeId (void) const
-{
-  return GetTypeId ();
-}
-  
 void
 ContentObject::Print (std::ostream &os) const
 {
@@ -226,50 +117,5 @@
   // os << "<ContentObject><Name>" << GetName () << "</Name><Content>";
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-ContentObjectTail::ContentObjectTail ()
-{
-}
-
-TypeId
-ContentObjectTail::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::ndn::ContentObjectTail")
-    .SetParent<Trailer> ()
-    .AddConstructor<ContentObjectTail> ()
-    ;
-  return tid;
-}
-
-TypeId
-ContentObjectTail::GetInstanceTypeId (void) const
-{
-  return GetTypeId ();
-}
-
-void
-ContentObjectTail::Print (std::ostream &os) const
-{
-  // os << "</Content></ContentObject>";
-}
-
-uint32_t
-ContentObjectTail::GetSerializedSize (void) const
-{
-  return 0;
-}
-
-void
-ContentObjectTail::Serialize (Buffer::Iterator start) const
-{
-}
-
-uint32_t
-ContentObjectTail::Deserialize (Buffer::Iterator start)
-{
-  return 0;
-}
-
 } // namespace ndn
 } // namespace ns3