Adding support of more fields in ContentObject

All big fields (digest, signature, etc.) are represented with 32-bit
integers. Should be enough for simulation purposes.

Also. This commit contains a number of code reorganizations, so the code
may not work...
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc
deleted file mode 100644
index 94732f7..0000000
--- a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ccnb-parser-content-object-visitor.h"
-#include "ccnb-parser-name-components-visitor.h"
-#include "ccnb-parser-non-negative-integer-visitor.h"
-#include "ccnb-parser-timestamp-visitor.h"
-
-#include "../syntax-tree/ccnb-parser-block.h"
-#include "../syntax-tree/ccnb-parser-dtag.h"
-
-#include "ns3/ccnx-name-components.h"
-#include "ns3/assert.h"
-#include "ns3/log.h"
-
-#include "ns3/ccnx-content-object-header.h"
-
-#include <boost/foreach.hpp>
-
-NS_LOG_COMPONENT_DEFINE ("CcnbParserContentObjectVisitor");
-
-namespace ns3 {
-namespace CcnbParser {
-
-// We don't really care about any other fields
-void
-ContentObjectVisitor::visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader* */)
-{
-  // uint32_t n.m_dtag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  static NameComponentsVisitor nameComponentsVisitor;
-  static NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
-  static TimestampVisitor          timestampVisitor;
-  
-  CcnxContentObjectHeader &contentObject = *(boost::any_cast<CcnxContentObjectHeader*> (param));
-  
-  switch (n.m_dtag)
-    {
-    case CCN_DTAG_ContentObject:
-      // process nested blocks
-      BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
-        {
-          block->accept (*this, param);
-        }
-      break;
-    case CCN_DTAG_Name:
-      {
-        // process name components
-        Ptr<CcnxNameComponents> name = Create<CcnxNameComponents> ();
-        
-        BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
-          {
-            block->accept (nameComponentsVisitor, &(*name));
-          }
-        contentObject.SetName (name);
-        break;
-      }
-
-    case CCN_DTAG_Signature: // ignoring
-      break;
-
-    case CCN_DTAG_SignedInfo:
-      // process nested blocks
-      BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
-        {
-          block->accept (*this, param);
-        }      
-      break;
-      
-    case CCN_DTAG_Timestamp:
-      NS_LOG_DEBUG ("Timestamp");
-      if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnbDecodingException ();
-
-      contentObject.SetTimestamp (
-               boost::any_cast<Time> (
-                                      (*n.m_nestedTags.begin())->accept(
-                                                                        timestampVisitor
-                                                                        )));
-      break;
-
-    case CCN_DTAG_FreshnessSeconds:
-      NS_LOG_DEBUG ("FreshnessSeconds");
-      
-      if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnbDecodingException ();
-      contentObject.SetFreshness (
-          Seconds (
-               boost::any_cast<uint32_t> (
-                                          (*n.m_nestedTags.begin())->accept(
-                                                                           nonNegativeIntegerVisitor
-                                                                           ))));
-      
-      break;
-      
-    case CCN_DTAG_Content: // !!! HACK
-      // This hack was necessary for memory optimizations (i.e., content is virtual payload)
-      NS_ASSERT_MSG (n.m_nestedTags.size() == 0, "Parser should have stopped just after processing <Content> tag");
-      break;
-      
-    default: // ignore all other stuff
-      break;
-    }
-}
-
-} // namespace CcnbParser
-} // namespace ns3
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h
deleted file mode 100644
index ae6fe9b..0000000
--- a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
-#define _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
-
-#include "ccnb-parser-void-depth-first-visitor.h"
-
-namespace ns3 {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Visitor that fills fields in CcnxContentObjectHeader
- *
- * Usage example:
- * \code
- *   Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
- *   Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
- *   ContentObjectVisitor visitor;
- *   root->accept (visitor, *header); 
- * \endcode
- */
-class ContentObjectVisitor : public VoidDepthFirstVisitor
-{
-public:
-  virtual void visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader* */);
-};
-
-}
-}
-
-#endif // _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.cc
similarity index 79%
copy from helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc
copy to helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.cc
index 0102b0a..34608b1 100644
--- a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc
+++ b/helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.cc
@@ -18,24 +18,29 @@
  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#include "ccnb-parser-nonce-visitor.h"
+#include "ccnb-parser-content-type-visitor.h"
 #include "../syntax-tree/ccnb-parser-blob.h"
 
 namespace ns3 {
 namespace CcnbParser {
 
 boost::any
-NonceVisitor::visit (Blob &n) 
+ContentTypeVisitor::visit (Blob &n) 
 {
   // Buffer n.m_blob;
-  if (n.m_blobSize < 4)
+  if (n.m_blobSize != 3)
     throw CcnbDecodingException ();
-     
-  return boost::any (*(reinterpret_cast<uint32_t*> (n.m_blob)));
+
+  uint32_t type =
+    (n.m_blob [0] << 16) |
+    (n.m_blob [1] << 8 ) |
+    (n.m_blob [2]      );
+    
+  return boost::any (type);
 }
 
 boost::any
-NonceVisitor::visit (Udata &n)
+ContentTypeVisitor::visit (Udata &n)
 {
   // std::string n.m_udata;
   throw CcnbDecodingException ();
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.h
similarity index 87%
rename from helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h
rename to helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.h
index c4912aa..0c3cc6c 100644
--- a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h
+++ b/helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.h
@@ -18,8 +18,8 @@
  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#ifndef _CCNB_PARSER_NONCE_VISITOR_H_
-#define _CCNB_PARSER_NONCE_VISITOR_H_
+#ifndef _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
+#define _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
 
 #include "ccnb-parser-no-argu-depth-first-visitor.h"
 
@@ -35,7 +35,7 @@
  *
  * Will return empty boost::any() if called on anything except BLOB block
  */
-class NonceVisitor : public NoArguDepthFirstVisitor
+class ContentTypeVisitor : public NoArguDepthFirstVisitor
 {
 public:
   virtual boost::any visit (Blob &n); 
@@ -45,4 +45,4 @@
 }
 }
 
-#endif // _CCNB_PARSER_NONCE_VISITOR_H_
+#endif // _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc
index b7ccaba..ff219f0 100644
--- a/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc
+++ b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc
@@ -32,7 +32,7 @@
 #include "ccnb-parser-name-components-visitor.h"
 #include "ccnb-parser-non-negative-integer-visitor.h"
 #include "ccnb-parser-timestamp-visitor.h"
-#include "ccnb-parser-nonce-visitor.h"
+#include "ccnb-parser-uint32t-blob-visitor.h"
 
 #include <boost/foreach.hpp>
 
@@ -53,7 +53,7 @@
   static NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
   static NameComponentsVisitor     nameComponentsVisitor;
   static TimestampVisitor          timestampVisitor;
-  static NonceVisitor              nonceVisitor;
+  static Uint32tBlobVisitor        nonceVisitor;
   
   CcnxInterestHeader &interest = *(boost::any_cast<CcnxInterestHeader*> (param));
 
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.cc
similarity index 90%
rename from helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc
rename to helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.cc
index 0102b0a..fbeee6e 100644
--- a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.cc
+++ b/helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.cc
@@ -18,14 +18,14 @@
  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#include "ccnb-parser-nonce-visitor.h"
+#include "ccnb-parser-uint32t-blob-visitor.h"
 #include "../syntax-tree/ccnb-parser-blob.h"
 
 namespace ns3 {
 namespace CcnbParser {
 
 boost::any
-NonceVisitor::visit (Blob &n) 
+Uint32tBlobVisitor::visit (Blob &n) 
 {
   // Buffer n.m_blob;
   if (n.m_blobSize < 4)
@@ -35,7 +35,7 @@
 }
 
 boost::any
-NonceVisitor::visit (Udata &n)
+Uint32tBlobVisitor::visit (Udata &n)
 {
   // std::string n.m_udata;
   throw CcnbDecodingException ();
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.h
similarity index 87%
copy from helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h
copy to helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.h
index c4912aa..e06273f 100644
--- a/helper/ccnb-parser/visitors/ccnb-parser-nonce-visitor.h
+++ b/helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.h
@@ -18,8 +18,8 @@
  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#ifndef _CCNB_PARSER_NONCE_VISITOR_H_
-#define _CCNB_PARSER_NONCE_VISITOR_H_
+#ifndef _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
+#define _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
 
 #include "ccnb-parser-no-argu-depth-first-visitor.h"
 
@@ -35,7 +35,7 @@
  *
  * Will return empty boost::any() if called on anything except BLOB block
  */
-class NonceVisitor : public NoArguDepthFirstVisitor
+class Uint32tBlobVisitor : public NoArguDepthFirstVisitor
 {
 public:
   virtual boost::any visit (Blob &n); 
@@ -45,4 +45,4 @@
 }
 }
 
-#endif // _CCNB_PARSER_NONCE_VISITOR_H_
+#endif // _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_