read: auto-register prefixes for inserted data

Change-Id: Iebddca056a4c74f179f7af7203881adfe1cba777
refs: #4247
diff --git a/src/storage/repo-storage.cpp b/src/storage/repo-storage.cpp
index 1828eb9..d3834ba 100644
--- a/src/storage/repo-storage.cpp
+++ b/src/storage/repo-storage.cpp
@@ -51,7 +51,10 @@
    int64_t id = m_storage.insert(data);
    if (id == -1)
      return false;
-   return m_index.insert(data, id);
+   bool didInsert = m_index.insert(data, id);
+   if (didInsert)
+     afterDataInsertion(data.getName());
+   return didInsert;
 }
 
 ssize_t
@@ -65,10 +68,13 @@
   while (idName.first != 0) {
     bool resultDb = m_storage.erase(idName.first);
     bool resultIndex = m_index.erase(idName.second); //full name
-    if (resultDb && resultIndex)
+    if (resultDb && resultIndex) {
+      afterDataDeletion(idName.second);
       count++;
-    else
+    }
+    else {
       hasError = true;
+    }
     idName = m_index.find(name);
   }
   if (hasError)
@@ -88,10 +94,13 @@
   while (idName.first != 0) {
     bool resultDb = m_storage.erase(idName.first);
     bool resultIndex = m_index.erase(idName.second); //full name
-    if (resultDb && resultIndex)
+    if (resultDb && resultIndex) {
+      afterDataDeletion(idName.second);
       count++;
-    else
+    }
+    else {
       hasError = true;
+    }
     idName = m_index.find(interestDelete);
   }
   if (hasError)
diff --git a/src/storage/repo-storage.hpp b/src/storage/repo-storage.hpp
index bc2ecbe..bf3ade8 100644
--- a/src/storage/repo-storage.hpp
+++ b/src/storage/repo-storage.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017,  Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -17,8 +17,8 @@
  * repo-ng, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef REPO_STORAGE_REPO_STORE_HPP
-#define REPO_STORAGE_REPO_STORE_HPP
+#ifndef REPO_REPO_STORAGE_HPP
+#define REPO_REPO_STORAGE_HPP
 
 #include "../common.hpp"
 #include "storage.hpp"
@@ -26,6 +26,7 @@
 #include "../repo-command-parameter.hpp"
 
 #include <ndn-cxx/exclude.hpp>
+#include <ndn-cxx/util/signal.hpp>
 
 #include <queue>
 
@@ -89,6 +90,10 @@
   std::shared_ptr<Data>
   readData(const Interest& interest) const;
 
+public:
+  ndn::util::Signal<RepoStorage, ndn::Name> afterDataInsertion;
+  ndn::util::Signal<RepoStorage, ndn::Name> afterDataDeletion;
+
 private:
   Index m_index;
   Storage& m_storage;
@@ -96,4 +101,4 @@
 
 } // namespace repo
 
-#endif // REPO_REPO_STORE_HPP
+#endif // REPO_REPO_STORAGE_HPP