Major update to rename NDN class to Face
diff --git a/Makefile.am b/Makefile.am
index 53004e9..3dcb005 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,7 +44,7 @@
ndn-cpp/data.cpp ndn-cpp/c/data.h ndn-cpp/data.hpp \
ndn-cpp/Interest.cpp ndn-cpp/c/Interest.h ndn-cpp/Interest.hpp \
ndn-cpp/Key.cpp ndn-cpp/c/Key.h ndn-cpp/Key.hpp \
- ndn-cpp/NDN.cpp ndn-cpp/NDN.hpp \
+ ndn-cpp/face.cpp ndn-cpp/face.hpp \
ndn-cpp/Name.cpp ndn-cpp/c/Name.h ndn-cpp/Name.hpp \
ndn-cpp/PublisherPublicKeyDigest.hpp \
ndn-cpp/c/encoding/BinaryXML.h \
diff --git a/Makefile.in b/Makefile.in
index 457f6d4..954463e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -155,7 +155,7 @@
libndn_cpp_a_LIBADD =
am_libndn_cpp_a_OBJECTS = ndn-cpp/data.$(OBJEXT) \
ndn-cpp/Interest.$(OBJEXT) ndn-cpp/Key.$(OBJEXT) \
- ndn-cpp/NDN.$(OBJEXT) ndn-cpp/Name.$(OBJEXT) \
+ ndn-cpp/face.$(OBJEXT) ndn-cpp/Name.$(OBJEXT) \
ndn-cpp/encoding/BinaryXMLElementReader.$(OBJEXT) \
ndn-cpp/encoding/BinaryXMLWireFormat.$(OBJEXT) \
ndn-cpp/encoding/WireFormat.$(OBJEXT) \
@@ -445,7 +445,7 @@
ndn-cpp/data.cpp ndn-cpp/c/data.h ndn-cpp/data.hpp \
ndn-cpp/Interest.cpp ndn-cpp/c/Interest.h ndn-cpp/Interest.hpp \
ndn-cpp/Key.cpp ndn-cpp/c/Key.h ndn-cpp/Key.hpp \
- ndn-cpp/NDN.cpp ndn-cpp/NDN.hpp \
+ ndn-cpp/face.cpp ndn-cpp/face.hpp \
ndn-cpp/Name.cpp ndn-cpp/c/Name.h ndn-cpp/Name.hpp \
ndn-cpp/PublisherPublicKeyDigest.hpp \
ndn-cpp/c/encoding/BinaryXML.h \
@@ -632,7 +632,7 @@
ndn-cpp/$(DEPDIR)/$(am__dirstamp)
ndn-cpp/Key.$(OBJEXT): ndn-cpp/$(am__dirstamp) \
ndn-cpp/$(DEPDIR)/$(am__dirstamp)
-ndn-cpp/NDN.$(OBJEXT): ndn-cpp/$(am__dirstamp) \
+ndn-cpp/face.$(OBJEXT): ndn-cpp/$(am__dirstamp) \
ndn-cpp/$(DEPDIR)/$(am__dirstamp)
ndn-cpp/Name.$(OBJEXT): ndn-cpp/$(am__dirstamp) \
ndn-cpp/$(DEPDIR)/$(am__dirstamp)
@@ -757,9 +757,9 @@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/$(DEPDIR)/Interest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/$(DEPDIR)/Key.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/$(DEPDIR)/NDN.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/$(DEPDIR)/Name.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/$(DEPDIR)/data.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/$(DEPDIR)/face.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/c/$(DEPDIR)/errors.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/c/encoding/$(DEPDIR)/BinaryXMLDecoder.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/c/encoding/$(DEPDIR)/BinaryXMLElementReader.Po@am__quote@
diff --git a/ndn-cpp/Closure.hpp b/ndn-cpp/Closure.hpp
index c017a81..77d212a 100644
--- a/ndn-cpp/Closure.hpp
+++ b/ndn-cpp/Closure.hpp
@@ -33,27 +33,27 @@
UPCALL_DATA_BAD = 6 // verification failed
};
-class NDN;
+class Face;
class Interest;
class Data;
class UpcallInfo {
public:
- UpcallInfo(NDN *ndn, ptr_lib::shared_ptr<Interest> &interest, int matchedComps, ptr_lib::shared_ptr<Data> &data)
+ UpcallInfo(Face *ndn, ptr_lib::shared_ptr<Interest> &interest, int matchedComps, ptr_lib::shared_ptr<Data> &data)
{
ndn_ = ndn;
interest_ = interest;
data_ = data;
}
- NDN *getNDN() { return ndn_; }
+ Face *getNDN() { return ndn_; }
ptr_lib::shared_ptr<Interest> &getInterest() { return interest_; }
ptr_lib::shared_ptr<Data> &getData() { return data_; }
private:
- NDN *ndn_;
+ Face *ndn_;
ptr_lib::shared_ptr<Interest> interest_;
ptr_lib::shared_ptr<Data> data_;
};
diff --git a/ndn-cpp/NDN.cpp b/ndn-cpp/face.cpp
similarity index 79%
rename from ndn-cpp/NDN.cpp
rename to ndn-cpp/face.cpp
index 206af43..f2212ea 100644
--- a/ndn-cpp/NDN.cpp
+++ b/ndn-cpp/face.cpp
@@ -6,14 +6,14 @@
#include "encoding/BinaryXMLDecoder.hpp"
#include "c/encoding/BinaryXML.h"
#include "data.hpp"
-#include "NDN.hpp"
+#include "face.hpp"
using namespace std;
using namespace ndn::ptr_lib;
namespace ndn {
-void NDN::expressInterest(const Name &name, const shared_ptr<Closure> &closure, const Interest *interestTemplate)
+void Face::expressInterest(const Name &name, const shared_ptr<Closure> &closure, const Interest *interestTemplate)
{
Interest interest(name);
shared_ptr<vector<unsigned char> > encoding = interest.encode();
@@ -25,7 +25,7 @@
transport_->send(*encoding);
}
-void NDN::onReceivedElement(unsigned char *element, unsigned int elementLength)
+void Face::onReceivedElement(unsigned char *element, unsigned int elementLength)
{
BinaryXmlDecoder decoder(element, elementLength);
diff --git a/ndn-cpp/NDN.hpp b/ndn-cpp/face.hpp
similarity index 88%
rename from ndn-cpp/NDN.hpp
rename to ndn-cpp/face.hpp
index 106431a..ed30050 100644
--- a/ndn-cpp/NDN.hpp
+++ b/ndn-cpp/face.hpp
@@ -3,8 +3,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_NDN_HPP
-#define NDN_NDN_HPP
+#ifndef NDN_FACE_HPP
+#define NDN_FACE_HPP
#include "Closure.hpp"
#include "Interest.hpp"
@@ -15,19 +15,19 @@
namespace ndn {
-class NDN : public ElementListener {
+class Face : public ElementListener {
public:
- NDN(const char *host, unsigned short port, const ptr_lib::shared_ptr<Transport> &transport)
+ Face(const char *host, unsigned short port, const ptr_lib::shared_ptr<Transport> &transport)
: host_(host), port_(port), transport_(transport)
{
}
- NDN(const char *host, unsigned short port)
+ Face(const char *host, unsigned short port)
: host_(host), port_(port), transport_(new UdpTransport())
{
}
- NDN(const char *host)
+ Face(const char *host)
: host_(host), port_(9695), transport_(new UdpTransport())
{
}
diff --git a/ndn-cpp/transport/TcpTransport.cpp b/ndn-cpp/transport/TcpTransport.cpp
index 1f217f0..a6a6663 100644
--- a/ndn-cpp/transport/TcpTransport.cpp
+++ b/ndn-cpp/transport/TcpTransport.cpp
@@ -4,7 +4,7 @@
*/
#include <stdexcept>
-#include "../NDN.hpp"
+#include "../face.hpp"
#include "../c/util/ndn_realloc.h"
#include "TcpTransport.hpp"
@@ -12,20 +12,20 @@
namespace ndn {
-void TcpTransport::connect(NDN &ndn)
+void TcpTransport::connect(Face &face)
{
ndn_Error error;
- if (error = ndn_TcpTransport_connect(&transport_, (char *)ndn.getHost(), ndn.getPort()))
+ if (error = ndn_TcpTransport_connect(&transport_, (char *)face.getHost(), face.getPort()))
throw std::runtime_error(ndn_getErrorString(error));
// TODO: This belongs in the socket listener.
const unsigned int initialLength = 1000;
// Automatically cast ndn_ to (struct ndn_ElementListener *)
ndn_BinaryXmlElementReader_init
- (&elementReader_, &ndn, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
+ (&elementReader_, &face, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
// TODO: Properly indicate connected status.
- ndn_ = &ndn;
+ face_ = &face;
}
void TcpTransport::send(const unsigned char *data, unsigned int dataLength)
diff --git a/ndn-cpp/transport/TcpTransport.hpp b/ndn-cpp/transport/TcpTransport.hpp
index b3b8d30..88e61fb 100644
--- a/ndn-cpp/transport/TcpTransport.hpp
+++ b/ndn-cpp/transport/TcpTransport.hpp
@@ -17,14 +17,14 @@
TcpTransport()
{
ndn_TcpTransport_init(&transport_);
- ndn_ = 0;
+ face_ = 0;
}
/**
*
- * @param ndn Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
+ * @param face Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
*/
- virtual void connect(NDN &ndn);
+ virtual void connect(Face &face);
virtual void send(const unsigned char *data, unsigned int dataLength);
@@ -32,7 +32,7 @@
private:
struct ndn_TcpTransport transport_;
- NDN *ndn_;
+ Face *face_;
// TODO: This belongs in the socket listener.
ndn_BinaryXmlElementReader elementReader_;
};
diff --git a/ndn-cpp/transport/Transport.cpp b/ndn-cpp/transport/Transport.cpp
index 0fa97bc..e0aab03 100644
--- a/ndn-cpp/transport/Transport.cpp
+++ b/ndn-cpp/transport/Transport.cpp
@@ -10,7 +10,7 @@
namespace ndn {
-void Transport::connect(NDN &ndn)
+void Transport::connect(Face &face)
{
throw logic_error("unimplemented");
}
diff --git a/ndn-cpp/transport/Transport.hpp b/ndn-cpp/transport/Transport.hpp
index 4a55573..af1a2c0 100644
--- a/ndn-cpp/transport/Transport.hpp
+++ b/ndn-cpp/transport/Transport.hpp
@@ -10,14 +10,14 @@
namespace ndn {
-class NDN;
+class Face;
class Transport {
public:
/**
*
- * @param ndn Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
+ * @param face Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
*/
- virtual void connect(NDN &ndn);
+ virtual void connect(Face &face);
virtual void send(const unsigned char *data, unsigned int dataLength);
diff --git a/ndn-cpp/transport/UdpTransport.cpp b/ndn-cpp/transport/UdpTransport.cpp
index 6fd47e4..52b62a5 100644
--- a/ndn-cpp/transport/UdpTransport.cpp
+++ b/ndn-cpp/transport/UdpTransport.cpp
@@ -4,7 +4,7 @@
*/
#include <stdexcept>
-#include "../NDN.hpp"
+#include "../face.hpp"
#include "../c/util/ndn_realloc.h"
#include "UdpTransport.hpp"
@@ -12,20 +12,20 @@
namespace ndn {
-void UdpTransport::connect(NDN &ndn)
+void UdpTransport::connect(Face &face)
{
ndn_Error error;
- if (error = ndn_UdpTransport_connect(&transport_, (char *)ndn.getHost(), ndn.getPort()))
+ if (error = ndn_UdpTransport_connect(&transport_, (char *)face.getHost(), face.getPort()))
throw std::runtime_error(ndn_getErrorString(error));
// TODO: This belongs in the socket listener.
const unsigned int initialLength = 1000;
// Automatically cast ndn_ to (struct ndn_ElementListener *)
ndn_BinaryXmlElementReader_init
- (&elementReader_, &ndn, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
+ (&elementReader_, &face, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
// TODO: Properly indicate connected status.
- ndn_ = &ndn;
+ face_ = &face;
}
void UdpTransport::send(const unsigned char *data, unsigned int dataLength)
diff --git a/ndn-cpp/transport/UdpTransport.hpp b/ndn-cpp/transport/UdpTransport.hpp
index 460eedd..781effd 100644
--- a/ndn-cpp/transport/UdpTransport.hpp
+++ b/ndn-cpp/transport/UdpTransport.hpp
@@ -17,14 +17,14 @@
UdpTransport()
{
ndn_UdpTransport_init(&transport_);
- ndn_ = 0;
+ face_ = 0;
}
/**
*
- * @param ndn Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
+ * @param face Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
*/
- virtual void connect(NDN &ndn);
+ virtual void connect(Face &face);
virtual void send(const unsigned char *data, unsigned int dataLength);
@@ -32,7 +32,7 @@
private:
struct ndn_UdpTransport transport_;
- NDN *ndn_;
+ Face *face_;
// TODO: This belongs in the socket listener.
ndn_BinaryXmlElementReader elementReader_;
};
diff --git a/tests/test-get-async.cpp b/tests/test-get-async.cpp
index fc3a2ca..eac1ac6 100644
--- a/tests/test-get-async.cpp
+++ b/tests/test-get-async.cpp
@@ -9,7 +9,7 @@
#include <ndn-cpp/Interest.hpp>
#include <ndn-cpp/data.hpp>
#include <ndn-cpp/transport/UdpTransport.hpp>
-#include <ndn-cpp/NDN.hpp>
+#include <ndn-cpp/face.hpp>
using namespace std;
using namespace ndn;
@@ -45,8 +45,8 @@
try {
shared_ptr<UdpTransport> transport(new UdpTransport());
shared_ptr<MyClosure> closure(new MyClosure());
- NDN ndn("E.hub.ndn.ucla.edu", 9695, transport);
- ndn.expressInterest(Name("/ndn/ucla.edu/apps/ndn-js-test/hello.txt/level2/%FD%05%0B%16%7D%95%0E"), closure);
+ Face face("E.hub.ndn.ucla.edu", 9695, transport);
+ face.expressInterest(Name("/ndn/ucla.edu/apps/ndn-js-test/hello.txt/level2/%FD%05%0B%16%7D%95%0E"), closure);
// Pump the receive process. This should really be done by a socket listener.
while (!closure->gotContent_)