model: Adding one more way to set Name of Interests and ContentObjects using reference to the Name object
diff --git a/model/ndn-content-object.cc b/model/ndn-content-object.cc
index 91d890d..544d48c 100644
--- a/model/ndn-content-object.cc
+++ b/model/ndn-content-object.cc
@@ -49,11 +49,17 @@
}
void
-ContentObject::SetName (const Ptr<Name> &name)
+ContentObject::SetName (Ptr<Name> name)
{
m_name = name;
}
+void
+ContentObject::SetName (const Name &name)
+{
+ m_name = Create<Name> (name);
+}
+
const Name&
ContentObject::GetName () const
{
diff --git a/model/ndn-content-object.h b/model/ndn-content-object.h
index c26d5c1..78b6e69 100644
--- a/model/ndn-content-object.h
+++ b/model/ndn-content-object.h
@@ -42,8 +42,7 @@
*
* Only few important fields are actually implemented in the simulation
*
- * ContentObject serializes/deserializes header up-to and including <Content> tags
- * Necessary closing tags should be added using ContentObjectTail
+ * @see http://ndnsim.net/new-packet-formats.html
*
* Optimized and simplified formatting of Interest packets
*
@@ -51,9 +50,27 @@
* Name
* Content
*
- * This hacks are necessary to optimize memory use (i.e., virtual payload)
- *
- * "<ContentObject><Signature>..</Signature><Name>...</Name><SignedInfo>...</SignedInfo><Content>"
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Length | |
+ * |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
+ * ~ ~
+ * ~ Signature ~
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Length | |
+ * |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+ * ~ ~
+ * ~ Name ~
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Length | |
+ * |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+ * ~ ~
+ * ~ Content ~
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
class ContentObject : public SimpleRefCount<ContentObject,Header>
@@ -69,12 +86,20 @@
/**
* \brief Set content object name
*
- * Sets name of the content object. For example, SetName( Name("prefix")("postfix") );
+ * Sets name of the content object
**/
void
- SetName (const Ptr<Name> &name);
+ SetName (Ptr<Name> name);
/**
+ * @brief Another, less efficient, variant of setting content object name
+ *
+ * Sets name of the content object
+ */
+ void
+ SetName (const Name &name);
+
+ /**
* @brief Get name of the content object
*/
const Name&
diff --git a/model/ndn-interest.cc b/model/ndn-interest.cc
index fb7e449..fc5b24f 100644
--- a/model/ndn-interest.cc
+++ b/model/ndn-interest.cc
@@ -76,6 +76,12 @@
m_name = name;
}
+void
+Interest::SetName (const Name &name)
+{
+ m_name = Create<Name> (name);
+}
+
const Name&
Interest::GetName () const
{
diff --git a/model/ndn-interest.h b/model/ndn-interest.h
index 7138058..c5808f7 100644
--- a/model/ndn-interest.h
+++ b/model/ndn-interest.h
@@ -101,13 +101,22 @@
/**
* \brief Set interest name
*
- * Sets name of the interest. For example, SetName( ndnName("prefix")("postfix") );
- * @param[in] name const pointer to ndnName object that contains an interest name
+ * @param name smart pointer to Name
+ *
**/
void
SetName (Ptr<Name> name);
/**
+ * \brief Another variant to set interest name
+ *
+ * @param name const reference to Name object
+ *
+ **/
+ void
+ SetName (const Name &name);
+
+ /**
* \brief Get interest name
*
* Gets name of the interest.