Added Node class, and move most functionality from Face to Node. Make connect take a Node, not a Face.
diff --git a/ndn-cpp/transport/tcp-transport.cpp b/ndn-cpp/transport/tcp-transport.cpp
index aa438bc..a0a53de 100644
--- a/ndn-cpp/transport/tcp-transport.cpp
+++ b/ndn-cpp/transport/tcp-transport.cpp
@@ -4,7 +4,7 @@
*/
#include <stdexcept>
-#include "../face.hpp"
+#include "../node.hpp"
#include "../c/util/ndn_realloc.h"
#include "tcp-transport.hpp"
@@ -12,20 +12,20 @@
namespace ndn {
-void TcpTransport::connect(Face &face)
+void TcpTransport::connect(Node &node)
{
ndn_Error error;
- if ((error = ndn_TcpTransport_connect(&transport_, (char *)face.getHost(), face.getPort())))
+ if ((error = ndn_TcpTransport_connect(&transport_, (char *)node.getHost(), node.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_, &face, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
+ (&elementReader_, &node, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
// TODO: Properly indicate connected status.
- face_ = &face;
+ node_ = &node;
}
void TcpTransport::send(const unsigned char *data, unsigned int dataLength)
diff --git a/ndn-cpp/transport/tcp-transport.hpp b/ndn-cpp/transport/tcp-transport.hpp
index f3c5e91..1028def 100644
--- a/ndn-cpp/transport/tcp-transport.hpp
+++ b/ndn-cpp/transport/tcp-transport.hpp
@@ -15,17 +15,17 @@
class TcpTransport : public Transport {
public:
TcpTransport()
+ : node_(0)
{
ndn_TcpTransport_init(&transport_);
- face_ = 0;
elementReader_.partialData.array = 0;
}
/**
- * Connect to the host specified in face.
- * @param face Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
+ * Connect to the host specified in node.
+ * @param node Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
*/
- virtual void connect(Face &face);
+ virtual void connect(Node &node);
/**
* Set data to the host
@@ -35,7 +35,7 @@
virtual void send(const unsigned char *data, unsigned int dataLength);
/**
- * Process any data to receive. For each element received, call face.onReceivedElement.
+ * Process any data to receive. For each element received, call node.onReceivedElement.
* This is non-blocking and will return immediately if there is no data to receive.
* You should normally not call this directly since it is called by Face.processEvents.
* @throw This may throw an exception for reading data or in the callback for processing the data. If you
@@ -52,7 +52,7 @@
private:
struct ndn_TcpTransport transport_;
- Face *face_;
+ Node *node_;
// 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 e16a879..cbcb659 100644
--- a/ndn-cpp/transport/transport.cpp
+++ b/ndn-cpp/transport/transport.cpp
@@ -10,7 +10,7 @@
namespace ndn {
-void Transport::connect(Face &face)
+void Transport::connect(Node &node)
{
throw logic_error("unimplemented");
}
diff --git a/ndn-cpp/transport/transport.hpp b/ndn-cpp/transport/transport.hpp
index 3246340..9159b99 100644
--- a/ndn-cpp/transport/transport.hpp
+++ b/ndn-cpp/transport/transport.hpp
@@ -10,14 +10,14 @@
namespace ndn {
-class Face;
+class Node;
class Transport {
public:
/**
- * Connect to the host specified in face.
- * @param face Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
+ * Connect to the host specified in node.
+ * @param node Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
*/
- virtual void connect(Face &face);
+ virtual void connect(Node &node);
/**
* Set data to the host
@@ -32,7 +32,7 @@
}
/**
- * Process any data to receive. For each element received, call face.onReceivedElement.
+ * Process any data to receive. For each element received, call node.onReceivedElement.
* This is non-blocking and will silently time out after a brief period if there is no data to receive.
* You should repeatedly call this from an event loop.
* @throw This may throw an exception for reading data or in the callback for processing the data. If you
diff --git a/ndn-cpp/transport/udp-transport.cpp b/ndn-cpp/transport/udp-transport.cpp
index 4ae9e37..b1d90e8 100644
--- a/ndn-cpp/transport/udp-transport.cpp
+++ b/ndn-cpp/transport/udp-transport.cpp
@@ -12,20 +12,20 @@
namespace ndn {
-void UdpTransport::connect(Face &face)
+void UdpTransport::connect(Node &node)
{
ndn_Error error;
- if ((error = ndn_UdpTransport_connect(&transport_, (char *)face.getHost(), face.getPort())))
+ if ((error = ndn_UdpTransport_connect(&transport_, (char *)node.getHost(), node.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_, &face, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
+ (&elementReader_, &node, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
// TODO: Properly indicate connected status.
- face_ = &face;
+ node_ = &node;
}
void UdpTransport::send(const unsigned char *data, unsigned int dataLength)
diff --git a/ndn-cpp/transport/udp-transport.hpp b/ndn-cpp/transport/udp-transport.hpp
index 4ea6324..ceeda72 100644
--- a/ndn-cpp/transport/udp-transport.hpp
+++ b/ndn-cpp/transport/udp-transport.hpp
@@ -15,17 +15,17 @@
class UdpTransport : public Transport {
public:
UdpTransport()
+ : node_(0)
{
ndn_UdpTransport_init(&transport_);
- face_ = 0;
elementReader_.partialData.array = 0;
}
/**
- * Connect to the host specified in face.
- * @param face Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
+ * Connect to the host specified in node.
+ * @param node Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
*/
- virtual void connect(Face &face);
+ virtual void connect(Node &node);
/**
* Set data to the host
@@ -35,7 +35,7 @@
virtual void send(const unsigned char *data, unsigned int dataLength);
/**
- * Process any data to receive. For each element received, call face.onReceivedElement.
+ * Process any data to receive. For each element received, call node.onReceivedElement.
* This is non-blocking and will return immediately if there is no data to receive.
* You should normally not call this directly since it is called by Face.processEvents.
* @throw This may throw an exception for reading data or in the callback for processing the data. If you
@@ -52,7 +52,7 @@
private:
struct ndn_UdpTransport transport_;
- Face *face_;
+ Node *node_;
// TODO: This belongs in the socket listener.
ndn_BinaryXmlElementReader elementReader_;
};