Auto-register prefixes for inserted data
Now it is actually working
Change-Id: Ifcc46a765fa399b10d05f6a98c23c753f57d9f0a
Refs: #4247
diff --git a/src/handles/read-handle.cpp b/src/handles/read-handle.cpp
index 897fab1..b880bdd 100644
--- a/src/handles/read-handle.cpp
+++ b/src/handles/read-handle.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2018, 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.
@@ -27,6 +27,7 @@
: BaseHandle(face, storageHandle, keyChain, scheduler)
, m_prefixSubsetLength(prefixSubsetLength)
{
+ connectAutoListen();
}
void
diff --git a/src/handles/read-handle.hpp b/src/handles/read-handle.hpp
index a2bbd86..8ec67a2 100644
--- a/src/handles/read-handle.hpp
+++ b/src/handles/read-handle.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2018, 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.
@@ -43,9 +43,6 @@
void
listen(const Name& prefix) override;
- void
- connectAutoListen();
-
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
const std::map<ndn::Name, RegisteredDataPrefix>&
getRegisteredPrefixes()
@@ -65,6 +62,9 @@
void
onDataInserted(const Name& name);
+ void
+ connectAutoListen();
+
private:
/**
* @brief Read data from backend storage
diff --git a/src/storage/repo-storage.cpp b/src/storage/repo-storage.cpp
index d3834ba..148116b 100644
--- a/src/storage/repo-storage.cpp
+++ b/src/storage/repo-storage.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California.
+ * Copyright (c) 2014-2018, 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.
@@ -22,13 +22,11 @@
#include <istream>
+#include <ndn-cxx/util/logger.hpp>
+
namespace repo {
-static void
-insertItemToIndex(Index* index, const Storage::ItemMeta& item)
-{
- index->insert(item.fullName, item.id, item.keyLocatorHash);
-}
+NDN_LOG_INIT(repo.RepoStorage);
RepoStorage::RepoStorage(const int64_t& nMaxPackets, Storage& store)
: m_index(nMaxPackets)
@@ -39,7 +37,16 @@
void
RepoStorage::initialize()
{
- m_storage.fullEnumerate(bind(&insertItemToIndex, &m_index, _1));
+ NDN_LOG_DEBUG("Initialize");
+ m_storage.fullEnumerate(bind(&RepoStorage::insertItemToIndex, this, _1));
+}
+
+void
+RepoStorage::insertItemToIndex(const Storage::ItemMeta& item)
+{
+ NDN_LOG_DEBUG("Insert data to index " << item.fullName);
+ m_index.insert(item.fullName, item.id, item.keyLocatorHash);
+ afterDataInsertion(item.fullName);
}
bool
diff --git a/src/storage/repo-storage.hpp b/src/storage/repo-storage.hpp
index bf3ade8..ec5faa7 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-2017, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2018, 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.
@@ -90,6 +90,10 @@
std::shared_ptr<Data>
readData(const Interest& interest) const;
+private:
+ void
+ insertItemToIndex(const Storage::ItemMeta& item);
+
public:
ndn::util::Signal<RepoStorage, ndn::Name> afterDataInsertion;
ndn::util::Signal<RepoStorage, ndn::Name> afterDataDeletion;