Major update to rename ContentObject to Data everywhere.
diff --git a/ndn-cpp/Closure.hpp b/ndn-cpp/Closure.hpp
index 9efbd03..c017a81 100644
--- a/ndn-cpp/Closure.hpp
+++ b/ndn-cpp/Closure.hpp
@@ -27,35 +27,35 @@
UPCALL_FINAL = 0, // handler is about to be deregistered
UPCALL_INTEREST = 1, // incoming interest
UPCALL_CONSUMED_INTEREST = 2, // incoming interest, someone has answered
- UPCALL_CONTENT = 3, // incoming verified content
+ UPCALL_DATA = 3, // incoming verified data packet
UPCALL_INTEREST_TIMED_OUT = 4, // interest timed out
- UPCALL_CONTENT_UNVERIFIED = 5, // content that has not been verified
- UPCALL_CONTENT_BAD = 6 // verification failed
+ UPCALL_DATA_UNVERIFIED = 5, // data packet that has not been verified
+ UPCALL_DATA_BAD = 6 // verification failed
};
class NDN;
class Interest;
-class ContentObject;
+class Data;
class UpcallInfo {
public:
- UpcallInfo(NDN *ndn, ptr_lib::shared_ptr<Interest> &interest, int matchedComps, ptr_lib::shared_ptr<ContentObject> &contentObject)
+ UpcallInfo(NDN *ndn, ptr_lib::shared_ptr<Interest> &interest, int matchedComps, ptr_lib::shared_ptr<Data> &data)
{
ndn_ = ndn;
interest_ = interest;
- contentObject_ = contentObject;
+ data_ = data;
}
NDN *getNDN() { return ndn_; }
ptr_lib::shared_ptr<Interest> &getInterest() { return interest_; }
- ptr_lib::shared_ptr<ContentObject> &getContentObject() { return contentObject_; }
+ ptr_lib::shared_ptr<Data> &getData() { return data_; }
private:
NDN *ndn_;
ptr_lib::shared_ptr<Interest> interest_;
- ptr_lib::shared_ptr<ContentObject> contentObject_;
+ ptr_lib::shared_ptr<Data> data_;
};
class Closure {
diff --git a/ndn-cpp/NDN.cpp b/ndn-cpp/NDN.cpp
index 1299e94..206af43 100644
--- a/ndn-cpp/NDN.cpp
+++ b/ndn-cpp/NDN.cpp
@@ -5,7 +5,7 @@
#include "encoding/BinaryXMLDecoder.hpp"
#include "c/encoding/BinaryXML.h"
-#include "ContentObject.hpp"
+#include "data.hpp"
#include "NDN.hpp"
using namespace std;
@@ -30,12 +30,12 @@
BinaryXmlDecoder decoder(element, elementLength);
if (decoder.peekDTag(ndn_BinaryXml_DTag_ContentObject)) {
- shared_ptr<ContentObject> contentObject(new ContentObject());
- contentObject->decode(element, elementLength);
+ shared_ptr<Data> data(new Data());
+ data->decode(element, elementLength);
shared_ptr<Interest> dummyInterest;
- UpcallInfo upcallInfo(this, dummyInterest, 0, contentObject);
- tempClosure_->upcall(UPCALL_CONTENT, upcallInfo);
+ UpcallInfo upcallInfo(this, dummyInterest, 0, data);
+ tempClosure_->upcall(UPCALL_DATA, upcallInfo);
}
}
diff --git a/ndn-cpp/NDN.hpp b/ndn-cpp/NDN.hpp
index 2abb8f2..106431a 100644
--- a/ndn-cpp/NDN.hpp
+++ b/ndn-cpp/NDN.hpp
@@ -35,8 +35,8 @@
/**
* Encode name as an Interest. If interestTemplate is not 0, use its interest selectors.
* Send the interest through the transport, read the entire response and call
- * closure->upcall(UPCALL_CONTENT (or UPCALL_CONTENT_UNVERIFIED),
- * UpcallInfo(this, interest, 0, contentObject)).
+ * closure->upcall(UPCALL_DATA (or UPCALL_DATA_UNVERIFIED),
+ * UpcallInfo(this, interest, 0, data)).
* @param name reference to a Name for the interest. This does not keep a pointer to the Name object.
* @param closure a shared_ptr for the Closure. This uses shared_ptr to take another reference to the object.
* @param interestTemplate if not 0, copy interest selectors from the template. This does not keep a pointer to the Interest object.
diff --git a/ndn-cpp/c/ContentObject.h b/ndn-cpp/c/data.h
similarity index 88%
rename from ndn-cpp/c/ContentObject.h
rename to ndn-cpp/c/data.h
index 36ede14..9338846 100644
--- a/ndn-cpp/c/ContentObject.h
+++ b/ndn-cpp/c/data.h
@@ -3,8 +3,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_CONTENTOBJECT_H
-#define NDN_CONTENTOBJECT_H
+#ifndef NDN_DATA_H
+#define NDN_DATA_H
#include "Name.h"
#include "PublisherPublicKeyDigest.h"
@@ -65,7 +65,7 @@
ndn_KeyLocator_init(&self->keyLocator);
}
-struct ndn_ContentObject {
+struct ndn_Data {
struct ndn_Signature signature;
struct ndn_Name name;
struct ndn_SignedInfo signedInfo;
@@ -74,13 +74,13 @@
};
/**
- * Initialize an ndn_ContentObject struct with the pre-allocated nameComponents,
+ * Initialize an ndn_Data struct with the pre-allocated nameComponents,
* and defaults for all the values.
- * @param self pointer to the ndn_ContentObject struct
+ * @param self pointer to the ndn_Data struct
* @param nameComponents the pre-allocated array of ndn_NameComponent
* @param maxNameComponents the number of elements in the allocated nameComponents array
*/
-static inline void ndn_ContentObject_init(struct ndn_ContentObject *self, struct ndn_NameComponent *nameComponents, unsigned int maxNameComponents)
+static inline void ndn_Data_init(struct ndn_Data *self, struct ndn_NameComponent *nameComponents, unsigned int maxNameComponents)
{
ndn_Signature_init(&self->signature);
ndn_Name_init(&self->name, nameComponents, maxNameComponents);
diff --git a/ndn-cpp/c/encoding/BinaryXMLContentObject.h b/ndn-cpp/c/encoding/BinaryXMLContentObject.h
deleted file mode 100644
index eb7cc5e..0000000
--- a/ndn-cpp/c/encoding/BinaryXMLContentObject.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * @author: Jeff Thompson
- * See COPYING for copyright and distribution information.
- */
-
-#ifndef NDN_BINARYXMLCONTENTOBJECT_H
-#define NDN_BINARYXMLCONTENTOBJECT_H
-
-#include "../errors.h"
-#include "../ContentObject.h"
-#include "BinaryXMLEncoder.h"
-#include "BinaryXMLDecoder.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-ndn_Error ndn_encodeBinaryXmlContentObject(struct ndn_ContentObject *contentObject, struct ndn_BinaryXmlEncoder *encoder);
-
-ndn_Error ndn_decodeBinaryXmlContentObject(struct ndn_ContentObject *contentObject, struct ndn_BinaryXmlDecoder *decoder);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/ndn-cpp/c/encoding/BinaryXMLContentObject.c b/ndn-cpp/c/encoding/binary-xml-data.c
similarity index 85%
rename from ndn-cpp/c/encoding/BinaryXMLContentObject.c
rename to ndn-cpp/c/encoding/binary-xml-data.c
index d95889c..8da14b2 100644
--- a/ndn-cpp/c/encoding/BinaryXMLContentObject.c
+++ b/ndn-cpp/c/encoding/binary-xml-data.c
@@ -8,7 +8,7 @@
#include "BinaryXMLDecoder.h"
#include "BinaryXMLName.h"
#include "BinaryXMLPublisherPublicKeyDigest.h"
-#include "BinaryXMLContentObject.h"
+#include "binary-xml-data.h"
static ndn_Error encodeSignature(struct ndn_Signature *signature, struct ndn_BinaryXmlEncoder *encoder)
{
@@ -129,23 +129,23 @@
return 0;
}
-ndn_Error ndn_encodeBinaryXmlContentObject(struct ndn_ContentObject *contentObject, struct ndn_BinaryXmlEncoder *encoder)
+ndn_Error ndn_encodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlEncoder *encoder)
{
ndn_Error error;
if (error = ndn_BinaryXmlEncoder_writeElementStartDTag(encoder, ndn_BinaryXml_DTag_ContentObject))
return error;
- if (error = encodeSignature(&contentObject->signature, encoder))
+ if (error = encodeSignature(&data->signature, encoder))
return 0;
- if (error = ndn_encodeBinaryXmlName(&contentObject->name, encoder))
+ if (error = ndn_encodeBinaryXmlName(&data->name, encoder))
return error;
- if (error = encodeSignedInfo(&contentObject->signedInfo, encoder))
+ if (error = encodeSignedInfo(&data->signedInfo, encoder))
return 0;
if (error = ndn_BinaryXmlEncoder_writeBlobDTagElement
- (encoder, ndn_BinaryXml_DTag_Content, contentObject->content, contentObject->contentLength))
+ (encoder, ndn_BinaryXml_DTag_Content, data->content, data->contentLength))
return error;
if (error = ndn_BinaryXmlEncoder_writeElementClose(encoder))
@@ -154,7 +154,7 @@
return 0;
}
-ndn_Error ndn_decodeBinaryXmlContentObject(struct ndn_ContentObject *contentObject, struct ndn_BinaryXmlDecoder *decoder)
+ndn_Error ndn_decodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlDecoder *decoder)
{
ndn_Error error;
if (error = ndn_BinaryXmlDecoder_readElementStartDTag(decoder, ndn_BinaryXml_DTag_ContentObject))
@@ -164,27 +164,27 @@
if (error = ndn_BinaryXmlDecoder_peekDTag(decoder, ndn_BinaryXml_DTag_Signature, &gotExpectedTag))
return error;
if (gotExpectedTag) {
- if (error = decodeSignature(&contentObject->signature, decoder))
+ if (error = decodeSignature(&data->signature, decoder))
return error;
}
else
- ndn_Signature_init(&contentObject->signature);
+ ndn_Signature_init(&data->signature);
- if (error = ndn_decodeBinaryXmlName(&contentObject->name, decoder))
+ if (error = ndn_decodeBinaryXmlName(&data->name, decoder))
return error;
if (error = ndn_BinaryXmlDecoder_peekDTag(decoder, ndn_BinaryXml_DTag_SignedInfo, &gotExpectedTag))
return error;
if (gotExpectedTag) {
- if (error = decodeSignedInfo(&contentObject->signedInfo, decoder))
+ if (error = decodeSignedInfo(&data->signedInfo, decoder))
return error;
}
else
- ndn_SignedInfo_init(&contentObject->signedInfo);
+ ndn_SignedInfo_init(&data->signedInfo);
// Require a Content element, but set allowNull to allow a missing BLOB.
if (error = ndn_BinaryXmlDecoder_readBinaryDTagElement
- (decoder, ndn_BinaryXml_DTag_Content, 1, &contentObject->content, &contentObject->contentLength))
+ (decoder, ndn_BinaryXml_DTag_Content, 1, &data->content, &data->contentLength))
return error;
if (error = ndn_BinaryXmlDecoder_readElementClose(decoder))
diff --git a/ndn-cpp/c/encoding/binary-xml-data.h b/ndn-cpp/c/encoding/binary-xml-data.h
new file mode 100644
index 0000000..f3b14e9
--- /dev/null
+++ b/ndn-cpp/c/encoding/binary-xml-data.h
@@ -0,0 +1,26 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_BINARY_XML_DATA_H
+#define NDN_BINARY_XML_DATA_H
+
+#include "../errors.h"
+#include "../data.h"
+#include "BinaryXMLEncoder.h"
+#include "BinaryXMLDecoder.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ndn_Error ndn_encodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlEncoder *encoder);
+
+ndn_Error ndn_decodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlDecoder *decoder);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/ndn-cpp/ContentObject.cpp b/ndn-cpp/data.cpp
similarity index 75%
rename from ndn-cpp/ContentObject.cpp
rename to ndn-cpp/data.cpp
index 637c066..322faff 100644
--- a/ndn-cpp/ContentObject.cpp
+++ b/ndn-cpp/data.cpp
@@ -4,7 +4,7 @@
*/
#include "common.hpp"
-#include "ContentObject.hpp"
+#include "data.hpp"
using namespace std;
@@ -64,25 +64,25 @@
keyLocator_.set(signedInfoStruct.keyLocator);
}
-void ContentObject::get(struct ndn_ContentObject &contentObjectStruct) const
+void Data::get(struct ndn_Data &dataStruct) const
{
- signature_.get(contentObjectStruct.signature);
- name_.get(contentObjectStruct.name);
- signedInfo_.get(contentObjectStruct.signedInfo);
+ signature_.get(dataStruct.signature);
+ name_.get(dataStruct.name);
+ signedInfo_.get(dataStruct.signedInfo);
- contentObjectStruct.contentLength = content_.size();
+ dataStruct.contentLength = content_.size();
if (content_.size() > 0)
- contentObjectStruct.content = (unsigned char *)&content_[0];
+ dataStruct.content = (unsigned char *)&content_[0];
else
- contentObjectStruct.content = 0;
+ dataStruct.content = 0;
}
-void ContentObject::set(const struct ndn_ContentObject &contentObjectStruct)
+void Data::set(const struct ndn_Data &dataStruct)
{
- signature_.set(contentObjectStruct.signature);
- name_.set(contentObjectStruct.name);
- signedInfo_.set(contentObjectStruct.signedInfo);
- setVector(content_, contentObjectStruct.content, contentObjectStruct.contentLength);
+ signature_.set(dataStruct.signature);
+ name_.set(dataStruct.name);
+ signedInfo_.set(dataStruct.signedInfo);
+ setVector(content_, dataStruct.content, dataStruct.contentLength);
}
}
diff --git a/ndn-cpp/ContentObject.hpp b/ndn-cpp/data.hpp
similarity index 82%
rename from ndn-cpp/ContentObject.hpp
rename to ndn-cpp/data.hpp
index 18c69ea..883331f 100644
--- a/ndn-cpp/ContentObject.hpp
+++ b/ndn-cpp/data.hpp
@@ -3,13 +3,13 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_CONTENTOBJECT_HPP
-#define NDN_CONTENTOBJECT_HPP
+#ifndef NDN_DATA_HPP
+#define NDN_DATA_HPP
#include "Name.hpp"
#include "PublisherPublicKeyDigest.hpp"
#include "Key.hpp"
-#include "c/ContentObject.h"
+#include "c/data.h"
namespace ndn {
@@ -82,11 +82,11 @@
KeyLocator keyLocator_;
};
-class ContentObject {
+class Data {
public:
ptr_lib::shared_ptr<std::vector<unsigned char> > encode(WireFormat &wireFormat) const
{
- return wireFormat.encodeContentObject(*this);
+ return wireFormat.encodeData(*this);
}
ptr_lib::shared_ptr<std::vector<unsigned char> > encode() const
{
@@ -94,7 +94,7 @@
}
void decode(const unsigned char *input, unsigned int inputLength, WireFormat &wireFormat)
{
- wireFormat.decodeContentObject(*this, input, inputLength);
+ wireFormat.decodeData(*this, input, inputLength);
}
void decode(const unsigned char *input, unsigned int inputLength)
{
@@ -110,17 +110,17 @@
}
/**
- * Set the contentObjectStruct to point to the values in this interest, without copying any memory.
- * WARNING: The resulting pointers in contentObjectStruct are invalid after a further use of this object which could reallocate memory.
- * @param contentObjectStruct a C ndn_ContentObject struct where the name components array is already allocated.
+ * Set the dataStruct to point to the values in this interest, without copying any memory.
+ * WARNING: The resulting pointers in dataStruct are invalid after a further use of this object which could reallocate memory.
+ * @param dataStruct a C ndn_Data struct where the name components array is already allocated.
*/
- void get(struct ndn_ContentObject &contentObjectStruct) const;
+ void get(struct ndn_Data &dataStruct) const;
/**
- * Clear this content object, and set the values by copying from the ndn_ContentObject struct.
- * @param contentObjectStruct a C ndn_ContentObject struct
+ * Clear this data object, and set the values by copying from the ndn_Data struct.
+ * @param dataStruct a C ndn_Data struct
*/
- void set(const struct ndn_ContentObject &contentObjectStruct);
+ void set(const struct ndn_Data &dataStruct);
const Signature &getSignature() const { return signature_; }
diff --git a/ndn-cpp/encoding/BinaryXMLWireFormat.cpp b/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
index e0b2b1c..1c6b7b1 100644
--- a/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
+++ b/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
@@ -5,9 +5,9 @@
#include <stdexcept>
#include "../c/encoding/BinaryXMLInterest.h"
-#include "../c/encoding/BinaryXMLContentObject.h"
+#include "../c/encoding/binary-xml-data.h"
#include "../Interest.hpp"
-#include "../ContentObject.hpp"
+#include "../data.hpp"
#include "BinaryXMLEncoder.hpp"
#include "BinaryXMLDecoder.hpp"
#include "BinaryXMLWireFormat.hpp"
@@ -51,33 +51,33 @@
interest.set(interestStruct);
}
-ptr_lib::shared_ptr<vector<unsigned char> > BinaryXmlWireFormat::encodeContentObject(const ContentObject &contentObject)
+ptr_lib::shared_ptr<vector<unsigned char> > BinaryXmlWireFormat::encodeData(const Data &data)
{
struct ndn_NameComponent nameComponents[100];
- struct ndn_ContentObject contentObjectStruct;
- ndn_ContentObject_init
- (&contentObjectStruct, nameComponents, sizeof(nameComponents) / sizeof(nameComponents[0]));
- contentObject.get(contentObjectStruct);
+ struct ndn_Data dataStruct;
+ ndn_Data_init
+ (&dataStruct, nameComponents, sizeof(nameComponents) / sizeof(nameComponents[0]));
+ data.get(dataStruct);
BinaryXmlEncoder encoder;
- ndn_encodeBinaryXmlContentObject(&contentObjectStruct, &encoder);
+ ndn_encodeBinaryXmlData(&dataStruct, &encoder);
return encoder.getOutput();
}
-void BinaryXmlWireFormat::decodeContentObject(ContentObject &contentObject, const unsigned char *input, unsigned int inputLength)
+void BinaryXmlWireFormat::decodeData(Data &data, const unsigned char *input, unsigned int inputLength)
{
struct ndn_NameComponent nameComponents[100];
- struct ndn_ContentObject contentObjectStruct;
- ndn_ContentObject_init
- (&contentObjectStruct, nameComponents, sizeof(nameComponents) / sizeof(nameComponents[0]));
+ struct ndn_Data dataStruct;
+ ndn_Data_init
+ (&dataStruct, nameComponents, sizeof(nameComponents) / sizeof(nameComponents[0]));
BinaryXmlDecoder decoder(input, inputLength);
ndn_Error error;
- if (error = ndn_decodeBinaryXmlContentObject(&contentObjectStruct, &decoder))
+ if (error = ndn_decodeBinaryXmlData(&dataStruct, &decoder))
throw std::runtime_error(ndn_getErrorString(error));
- contentObject.set(contentObjectStruct);
+ data.set(dataStruct);
}
}
diff --git a/ndn-cpp/encoding/BinaryXMLWireFormat.hpp b/ndn-cpp/encoding/BinaryXMLWireFormat.hpp
index ff73218..ffc19b0 100644
--- a/ndn-cpp/encoding/BinaryXMLWireFormat.hpp
+++ b/ndn-cpp/encoding/BinaryXMLWireFormat.hpp
@@ -15,8 +15,8 @@
virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeInterest(const Interest &interest);
virtual void decodeInterest(Interest &interest, const unsigned char *input, unsigned int inputLength);
- virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeContentObject(const ContentObject &contentObject);
- virtual void decodeContentObject(ContentObject &contentObject, const unsigned char *input, unsigned int inputLength);
+ virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeData(const Data &data);
+ virtual void decodeData(Data &data, const unsigned char *input, unsigned int inputLength);
static BinaryXmlWireFormat &getInstance() { return instance_; }
diff --git a/ndn-cpp/encoding/WireFormat.cpp b/ndn-cpp/encoding/WireFormat.cpp
index 238ce9c..39d2e11 100644
--- a/ndn-cpp/encoding/WireFormat.cpp
+++ b/ndn-cpp/encoding/WireFormat.cpp
@@ -18,11 +18,11 @@
throw logic_error("unimplemented");
}
-ptr_lib::shared_ptr<vector<unsigned char> > WireFormat::encodeContentObject(const ContentObject &contentObject)
+ptr_lib::shared_ptr<vector<unsigned char> > WireFormat::encodeData(const Data &data)
{
throw logic_error("unimplemented");
}
-void WireFormat::decodeContentObject(ContentObject &contentObject, const unsigned char *input, unsigned int inputLength)
+void WireFormat::decodeData(Data &data, const unsigned char *input, unsigned int inputLength)
{
throw logic_error("unimplemented");
}
diff --git a/ndn-cpp/encoding/WireFormat.hpp b/ndn-cpp/encoding/WireFormat.hpp
index 1afe25f..a7d62bc 100644
--- a/ndn-cpp/encoding/WireFormat.hpp
+++ b/ndn-cpp/encoding/WireFormat.hpp
@@ -12,15 +12,15 @@
namespace ndn {
class Interest;
-class ContentObject;
+class Data;
class WireFormat {
public:
virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeInterest(const Interest &interest);
virtual void decodeInterest(Interest &interest, const unsigned char *input, unsigned int inputLength);
- virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeContentObject(const ContentObject &contentObject);
- virtual void decodeContentObject(ContentObject &contentObject, const unsigned char *input, unsigned int inputLength);
+ virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeData(const Data &data);
+ virtual void decodeData(Data &data, const unsigned char *input, unsigned int inputLength);
};
}