src: Update source code to use new API and fix compilation errors due to missing headers

Change-Id: I295fbcdcd6ab114a565d9b7531387728a6596884
Refs: 1629
diff --git a/src/handles/delete-handle.cpp b/src/handles/delete-handle.cpp
index 49e4d98..d88d523 100644
--- a/src/handles/delete-handle.cpp
+++ b/src/handles/delete-handle.cpp
@@ -36,6 +36,11 @@
                        bind(&DeleteHandle::onValidationFailed, this, _1, prefix));
 }
 
+void
+DeleteHandle::onRegisterSuccess(const Name& prefix)
+{
+  std::cerr << "Successfully registered prefix " << prefix << std::endl;
+}
 
 void
 DeleteHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
@@ -103,6 +108,7 @@
 {
   getFace().setInterestFilter(Name(prefix).append("delete"),
                               bind(&DeleteHandle::onInterest, this, _1, _2),
+                              bind(&DeleteHandle::onRegisterSuccess, this, _1),
                               bind(&DeleteHandle::onRegisterFailed, this, _1, _2));
 }
 
diff --git a/src/handles/delete-handle.hpp b/src/handles/delete-handle.hpp
index 680e8dc..8ca1c56 100644
--- a/src/handles/delete-handle.hpp
+++ b/src/handles/delete-handle.hpp
@@ -52,6 +52,9 @@
   onInterest(const Name& prefix, const Interest& interest);
 
   void
+  onRegisterSuccess(const Name& prefix);
+
+  void
   onRegisterFailed(const Name& prefix, const std::string& reason);
 
   void
diff --git a/src/handles/read-handle.cpp b/src/handles/read-handle.cpp
index d0e80b3..e13a85c 100644
--- a/src/handles/read-handle.cpp
+++ b/src/handles/read-handle.cpp
@@ -31,6 +31,12 @@
 }
 
 void
+ReadHandle::onRegisterSuccess(const Name& prefix)
+{
+  std::cerr << "Successfully registered prefix " << prefix << std::endl;
+}
+
+void
 ReadHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
 {
   std::cerr << "ERROR: Failed to register prefix in local hub's daemon" << std::endl;
@@ -42,6 +48,7 @@
 {
   getFace().setInterestFilter(prefix,
                               bind(&ReadHandle::onInterest, this, _1, _2),
+                              bind(&ReadHandle::onRegisterSuccess, this, _1),
                               bind(&ReadHandle::onRegisterFailed, this, _1, _2));
 }
 
diff --git a/src/handles/read-handle.hpp b/src/handles/read-handle.hpp
index 93468c0..7bf0484 100644
--- a/src/handles/read-handle.hpp
+++ b/src/handles/read-handle.hpp
@@ -44,6 +44,9 @@
   onInterest(const Name& prefix, const Interest& interest);
 
   void
+  onRegisterSuccess(const Name& prefix);
+
+  void
   onRegisterFailed(const Name& prefix, const std::string& reason);
 };
 
diff --git a/src/handles/write-handle.cpp b/src/handles/write-handle.cpp
index 0ea17ae..77c674b 100644
--- a/src/handles/write-handle.cpp
+++ b/src/handles/write-handle.cpp
@@ -51,6 +51,12 @@
                           bind(&WriteHandle::onValidationFailed, this, _1));
 }
 
+void
+WriteHandle::onRegisterSuccess(const Name& prefix)
+{
+  std::cerr << "Successfully registered prefix " << prefix << std::endl;
+}
+
 // onRegisterFailed.
 void
 WriteHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
@@ -180,11 +186,13 @@
   insertPrefix.append(prefix).append("insert");
   getFace().setInterestFilter(insertPrefix,
                               bind(&WriteHandle::onInterest, this, _1, _2),
+                              bind(&WriteHandle::onRegisterSuccess, this, _1),
                               bind(&WriteHandle::onRegisterFailed, this, _1, _2));
   Name insertCheckPrefix;
   insertCheckPrefix.append(prefix).append("insert check");
   getFace().setInterestFilter(insertCheckPrefix,
                               bind(&WriteHandle::onCheckInterest, this, _1, _2),
+                              bind(&WriteHandle::onRegisterSuccess, this, _1),
                               bind(&WriteHandle::onRegisterFailed, this, _1, _2));
 }
 
diff --git a/src/handles/write-handle.hpp b/src/handles/write-handle.hpp
index 075e78c..59fefb6 100644
--- a/src/handles/write-handle.hpp
+++ b/src/handles/write-handle.hpp
@@ -112,6 +112,9 @@
   void
   onValidationFailed(const shared_ptr<const Interest>& interest);
 
+  void
+  onRegisterSuccess(const Name& prefix);
+
   /**
    * @brief insert command prefix register failed
    */
diff --git a/src/repo-command-response.hpp b/src/repo-command-response.hpp
index 0eb4f1d..92b390b 100644
--- a/src/repo-command-response.hpp
+++ b/src/repo-command-response.hpp
@@ -21,6 +21,7 @@
 #define REPO_REPO_COMMAND_RESPONSE_HPP
 
 #include <ndn-cxx/encoding/block.hpp>
+#include <ndn-cxx/encoding/block-helpers.hpp>
 #include <ndn-cxx/encoding/encoding-buffer.hpp>
 #include <ndn-cxx/encoding/tlv-nfd.hpp>
 #include "repo-tlv.hpp"
diff --git a/src/repo.cpp b/src/repo.cpp
index 3502763..2c6f3b0 100644
--- a/src/repo.cpp
+++ b/src/repo.cpp
@@ -107,16 +107,10 @@
   return repoConfig;
 }
 
-inline static void
-NullDeleter(boost::asio::io_service* variable)
-{
-  // do nothing
-}
-
 Repo::Repo(boost::asio::io_service& ioService, const RepoConfig& config)
   : m_config(config)
   , m_scheduler(ioService)
-  , m_face(shared_ptr<boost::asio::io_service>(&ioService, &NullDeleter))
+  , m_face(ioService)
   , m_storageHandle(openStorage(config))
   , m_readHandle(m_face, *m_storageHandle, m_keyChain, m_scheduler)
   , m_writeHandle(m_face, *m_storageHandle, m_keyChain, m_scheduler, m_validator)
diff --git a/tests/dataset-fixtures.hpp b/tests/dataset-fixtures.hpp
index b404ab2..3adf0b4 100644
--- a/tests/dataset-fixtures.hpp
+++ b/tests/dataset-fixtures.hpp
@@ -21,6 +21,8 @@
 #define REPO_TESTS_DATASET_FIXTURES_HPP
 
 #include <ndn-cxx/security/key-chain.hpp>
+#include <vector>
+#include <boost/mpl/vector.hpp>
 
 namespace repo {
 namespace tests {
diff --git a/tests/integrated/test-basic-command-insert-delete.cpp b/tests/integrated/test-basic-command-insert-delete.cpp
index 3f2992f..189ee27 100644
--- a/tests/integrated/test-basic-command-insert-delete.cpp
+++ b/tests/integrated/test-basic-command-insert-delete.cpp
@@ -253,6 +253,7 @@
     //The delayEvent will be canceled in onInsertInterest
     insertFace.setInterestFilter(insertParameter.getName(),
                                  bind(&Fixture<T>::onInsertInterest, this, _2),
+                                 ndn::RegisterPrefixSuccessCallback(),
                                  bind(&Fixture<T>::onRegisterFailed, this, _2));
     timeCount++;
   }
diff --git a/tools/ndngetfile.cpp b/tools/ndngetfile.cpp
index 2a26962..fd9dc6a 100644
--- a/tools/ndngetfile.cpp
+++ b/tools/ndngetfile.cpp
@@ -19,6 +19,7 @@
 
 #include "ndngetfile.hpp"
 #include <boost/lexical_cast.hpp>
+#include <fstream>
 
 namespace repo {
 
diff --git a/tools/ndnputfile.cpp b/tools/ndnputfile.cpp
index 1c56934..2103eb1 100644
--- a/tools/ndnputfile.cpp
+++ b/tools/ndnputfile.cpp
@@ -22,12 +22,15 @@
 
 #include <ndn-cxx/face.hpp>
 #include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
 #include <ndn-cxx/util/command-interest-generator.hpp>
 #include <fstream>
 #include <string>
 #include <stdlib.h>
+#include <stdint.h>
 #include <boost/filesystem.hpp>
-
+#include <boost/lexical_cast.hpp>
+#include <boost/asio.hpp>
 #include <boost/iostreams/operations.hpp>
 #include <boost/iostreams/read.hpp>
 
@@ -97,6 +100,9 @@
   onSingleInterest(const ndn::Name& prefix, const ndn::Interest& interest);
 
   void
+  onRegisterSuccess(const ndn::Name& prefix);
+
+  void
   onRegisterFailed(const ndn::Name& prefix, const std::string& reason);
 
   void
@@ -212,13 +218,9 @@
                              ndn::bind(&NdnPutFile::onSingleInterest, this, _1, _2)
                              :
                              ndn::bind(&NdnPutFile::onInterest, this, _1, _2),
+                           ndn::bind(&NdnPutFile::onRegisterSuccess, this, _1),
                            ndn::bind(&NdnPutFile::onRegisterFailed, this, _1, _2));
 
-  // @todo Move startCommand
-  // setInterestFilter doesn't currently have "onSuccess" callback,
-  // so insertCommand needs to be started right away
-  startInsertCommand();
-
   if (hasTimeout)
     m_scheduler.scheduleEvent(timeout, ndn::bind(&NdnPutFile::stopProcess, this));
 
@@ -226,6 +228,12 @@
 }
 
 void
+NdnPutFile::onRegisterSuccess(const Name& prefix)
+{
+  startInsertCommand();
+}
+
+void
 NdnPutFile::startInsertCommand()
 {
   RepoCommandParameter parameters;