read-echo: functions to read data from repo

Change-Id: I61a0b8bf254cd84c49def0f7ddda5ab026c689f4
diff --git a/ndn-handle/read-handle.cpp b/ndn-handle/read-handle.cpp
new file mode 100644
index 0000000..9ab7822
--- /dev/null
+++ b/ndn-handle/read-handle.cpp
@@ -0,0 +1,34 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Regents of the University of California.
+ * See COPYING for copyright and distribution information.
+ */
+#include "read-handle.hpp"
+
+namespace repo {
+
+void
+ReadHandle::onInterest(const Name& prefix, const Interest& interest)
+{
+  Data data;
+  if (getStorageHandle()->readData(interest, data)) {
+    getFace()->put(data);
+  }
+}
+
+void
+ReadHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
+{
+  std::cerr << "ERROR: Failed to register prefix in local hub's daemon" << std::endl;
+  getFace()->shutdown();
+}
+
+void
+ReadHandle::listen(const Name& prefix)
+{
+  getFace()->setInterestFilter(prefix,
+                            bind(&ReadHandle::onInterest, this, _1, _2),
+                            bind(&ReadHandle::onRegisterFailed, this, _1, _2));
+}
+
+} //namespace repo