Auto-register prefixes for inserted data
Now it is actually working
Change-Id: Ifcc46a765fa399b10d05f6a98c23c753f57d9f0a
Refs: #4247
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index f1d23d6..bba2b1e 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -17,15 +17,15 @@
if ccver < (4, 8, 2):
errmsg = ('The version of gcc you are using is too old.\n'
'The minimum supported gcc version is 4.8.2.')
- flags = GccFlags()
+ conf.flags = GccFlags()
elif cxx == 'clang':
if ccver < (3, 4, 0):
errmsg = ('The version of clang you are using is too old.\n'
'The minimum supported clang version is 3.4.0.')
- flags = ClangFlags()
+ conf.flags = ClangFlags()
else:
warnmsg = 'Note: %s compiler is unsupported' % cxx
- flags = CompilerFlags()
+ conf.flags = CompilerFlags()
if errmsg:
conf.end_msg('.'.join(conf.env['CC_VERSION']), color='RED')
@@ -36,29 +36,31 @@
else:
conf.end_msg('.'.join(conf.env['CC_VERSION']))
- areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
+ conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
# General flags are always applied (e.g., selecting C++11 mode)
- generalFlags = flags.getGeneralFlags(conf)
+ generalFlags = conf.flags.getGeneralFlags(conf)
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
conf.env.DEFINES += generalFlags['DEFINES']
+@Configure.conf
+def check_compiler_flags(conf):
# Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
# corresponding environment variables are not set.
# DEFINES are always applied.
if conf.options.debug:
- extraFlags = flags.getDebugFlags(conf)
- if areCustomCxxflagsPresent:
+ extraFlags = conf.flags.getDebugFlags(conf)
+ if conf.areCustomCxxflagsPresent:
missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS]
if len(missingFlags) > 0:
Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
% " ".join(conf.env.CXXFLAGS))
Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
else:
- extraFlags = flags.getOptimizedFlags(conf)
+ extraFlags = conf.flags.getOptimizedFlags(conf)
- if not areCustomCxxflagsPresent:
+ if not conf.areCustomCxxflagsPresent:
conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
@@ -75,9 +77,10 @@
self.start_msg('Checking supported CXXFLAGS')
supportedFlags = []
- for flag in cxxflags:
- if self.check_cxx(cxxflags=['-Werror', flag], mandatory=False):
- supportedFlags += [flag]
+ for flags in cxxflags:
+ flags = Utils.to_list(flags)
+ if self.check_cxx(cxxflags=['-Werror'] + flags, mandatory=False):
+ supportedFlags += flags
self.end_msg(' '.join(supportedFlags))
self.env.prepend_value('CXXFLAGS', supportedFlags)
@@ -93,9 +96,10 @@
self.start_msg('Checking supported LINKFLAGS')
supportedFlags = []
- for flag in linkflags:
- if self.check_cxx(linkflags=['-Werror', flag], mandatory=False):
- supportedFlags += [flag]
+ for flags in linkflags:
+ flags = Utils.to_list(flags)
+ if self.check_cxx(linkflags=['-Werror'] + flags, mandatory=False):
+ supportedFlags += flags
self.end_msg(' '.join(supportedFlags))
self.env.prepend_value('LINKFLAGS', supportedFlags)
@@ -173,25 +177,36 @@
class ClangFlags(GccBasicFlags):
def getGeneralFlags(self, conf):
flags = super(ClangFlags, self).getGeneralFlags(conf)
- if Utils.unversioned_sys_platform() == 'darwin':
- flags['CXXFLAGS'] += ['-stdlib=libc++']
- flags['LINKFLAGS'] += ['-stdlib=libc++']
+ version = tuple(int(i) for i in conf.env['CC_VERSION'])
+ if Utils.unversioned_sys_platform() == 'darwin' and version >= (9, 0, 0): # Bug #4296
+ flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
+ ['-isystem', '/opt/local/include']] # for MacPorts
return flags
def getDebugFlags(self, conf):
flags = super(ClangFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
+ '-Wextra-semi',
+ '-Wundefined-func-template',
'-Wno-error=deprecated-register',
'-Wno-error=infinite-recursion', # Bug #3358
'-Wno-error=keyword-macro', # Bug #3235
'-Wno-error=unneeded-internal-declaration', # Bug #1588
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
+ version = tuple(int(i) for i in conf.env['CC_VERSION'])
+ if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
+ flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
return flags
def getOptimizedFlags(self, conf):
flags = super(ClangFlags, self).getOptimizedFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
+ '-Wextra-semi',
+ '-Wundefined-func-template',
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
+ version = tuple(int(i) for i in conf.env['CC_VERSION'])
+ if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
+ flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
return flags
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;
diff --git a/wscript b/wscript
index fc3de3b..ed3e3c4 100644
--- a/wscript
+++ b/wscript
@@ -34,12 +34,11 @@
conf.env['WITH_TESTS'] = conf.options.with_tests
conf.env['WITH_TOOLS'] = conf.options.with_tools
- USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem']
+ USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem', 'thread', 'log', 'log_setup']
if conf.env['WITH_TESTS']:
conf.define('HAVE_TESTS', 1)
USED_BOOST_LIBS += ['unit_test_framework']
-
- conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True)
+ conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True, mt=True)
try:
conf.load("doxygen")