build: use C++11
Change-Id: I0e58ac4e9cb42d07a9b58125d761875f91c7744c
Refs: #1930
diff --git a/.jenkins b/.jenkins
new file mode 100755
index 0000000..afc4699
--- /dev/null
+++ b/.jenkins
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+set -e
+
+DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+
+for i in $( find "$DIR/.jenkins.d" -type f -perm +111 | sort ); do
+ echo "Run: $i"
+ "$i"
+done
diff --git a/.jenkins.d/10-ndn-cxx.sh b/.jenkins.d/10-ndn-cxx.sh
new file mode 100755
index 0000000..823b816
--- /dev/null
+++ b/.jenkins.d/10-ndn-cxx.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+cd /tmp
+BUILD="no"
+if [ ! -d ndn-cxx ]; then
+ git clone --depth 1 git://github.com/named-data/ndn-cxx
+ cd ndn-cxx
+ BUILD="yes"
+else
+ cd ndn-cxx
+ INSTALLED_VERSION=`git rev-parse HEAD || echo NONE`
+ sudo rm -Rf latest-version
+ git clone --depth 1 git://github.com/named-data/ndn-cxx latest-version
+ cd latest-version
+ LATEST_VERSION=`git rev-parse HEAD || echo UNKNOWN`
+ cd ..
+ rm -Rf latest-version
+ if [ "$INSTALLED_VERSION" != "$LATEST_VERSION" ]; then
+ cd ..
+ sudo rm -Rf ndn-cxx
+ git clone --depth 1 git://github.com/named-data/ndn-cxx
+ cd ndn-cxx
+ BUILD="yes"
+ fi
+fi
+
+sudo rm -Rf /usr/local/include/ndn-cxx
+sudo rm -f /usr/local/lib/libndn-cxx*
+sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx*
+
+if [ "$BUILD" = "yes" ]; then
+ ./waf distclean --color=yes
+fi
+
+./waf configure --color=yes --without-osx-keychain
+./waf -j1 --color=yes
+sudo ./waf install --color=yes
diff --git a/.jenkins.d/20-build.sh b/.jenkins.d/20-build.sh
new file mode 100755
index 0000000..985216e
--- /dev/null
+++ b/.jenkins.d/20-build.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+git submodule init
+git submodule sync
+git submodule update
+
+COVERAGE=$( python -c "print '--with-coverage' if 'code-coverage' in '$JOB_NAME' else ''" )
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+# Configure/build in debug mode
+./waf -j1 --color=yes configure --with-tests --debug
+./waf -j1 --color=yes build
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+# Configure/build in optimized mode without tests with precompiled headers
+./waf -j1 --color=yes configure
+./waf -j1 --color=yes build
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+# Configure/build in optimized mode
+./waf -j1 --color=yes configure --with-tests $COVERAGE
+./waf -j1 --color=yes build
+
+# (tests will be run against optimized version)
+
+# Install
+sudo ./waf -j1 --color=yes install
diff --git a/.jenkins.d/30-nfd.sh b/.jenkins.d/30-nfd.sh
new file mode 100755
index 0000000..2f139cd
--- /dev/null
+++ b/.jenkins.d/30-nfd.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+cd /tmp
+BUILD="no"
+if [ ! -d NFD ]; then
+ git clone --recursive --depth 1 git://github.com/named-data/NFD
+ cd NFD
+ BUILD="yes"
+else
+ cd NFD
+ INSTALLED_VERSION=`git rev-parse HEAD || echo NONE`
+ sudo rm -Rf latest-version
+ git clone --recursive --depth 1 git://github.com/named-data/NFD latest-version
+ cd latest-version
+ LATEST_VERSION=`git rev-parse HEAD || echo UNKNOWN`
+ cd ..
+ rm -Rf latest-version
+ if [ "$INSTALLED_VERSION" != "$LATEST_VERSION" ]; then
+ cd ..
+ sudo rm -Rf NFD
+ git clone --recursive --depth 1 git://github.com/named-data/NFD
+ cd NFD
+ BUILD="yes"
+ fi
+fi
+
+if [ "$BUILD" = "yes" ]; then
+ sudo ./waf -j1 --color=yes distclean
+fi
+
+git submodule update --init
+
+./waf configure -j1 --color=yes
+./waf -j1 --color=yes
+sudo ./waf install -j1 --color=yes
diff --git a/.jenkins.d/40-tests.sh b/.jenkins.d/40-tests.sh
new file mode 100755
index 0000000..aa90b64
--- /dev/null
+++ b/.jenkins.d/40-tests.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+# Run tests
+sudo rm -Rf ~/.ndn
+mkdir ~/.ndn
+
+sudo cp /usr/local/etc/ndn/nfd.conf.sample /usr/local/etc/ndn/nfd.conf
+
+IS_OSX=$( python -c "print 'yes' if 'OSX' in '$NODE_LABELS'.strip().split(' ') else 'no'" )
+IS_LINUX=$( python -c "print 'yes' if 'Linux' in '$NODE_LABELS'.strip().split(' ') else 'no'" )
+
+if [ $IS_OSX = "yes" ]; then
+ security unlock-keychain -p "named-data"
+fi
+
+sudo killall nrd || true
+sudo killall nfd || true
+
+/usr/local/bin/nfd-start
+
+./build/unit-tests -l test_suite
+
+sudo killall nrd || true
+sudo killall nfd || true
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 59b32a9..ce19594 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -1,27 +1,17 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2014, Regents of the University of California
-#
-# GPL 3.0 license, see the COPYING.md file for more information
from waflib import Logs, Configure
def options(opt):
- opt.add_option('--with-c++11', action='store_true', default=False, dest='use_cxx11',
- help='''Enable C++11 mode (experimental, may not work)''')
opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
- help='''Compile in debugging mode without all optimizations (-O0)''')
+ help='''Compile in debugging mode without optimizations (-O0 or -Og)''')
def configure(conf):
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
- defaultFlags = []
-
- if conf.options.use_cxx11:
- defaultFlags += ['-std=c++0x', '-std=c++11']
- else:
- defaultFlags += ['-std=c++03', '-Wno-variadic-macros', '-Wno-c99-extensions']
-
- defaultFlags += ['-pedantic', '-Wall', '-Wno-long-long']
+ defaultFlags = ['-std=c++0x', '-std=c++11',
+ '-stdlib=libc++', # clang on OSX < 10.9 by default uses gcc's
+ # libstdc++, which is not C++11 compatible
+ '-pedantic', '-Wall']
if conf.options.debug:
conf.define('_DEBUG', 1)
@@ -30,7 +20,8 @@
'-g3',
'-fcolor-diagnostics', # clang
'-fdiagnostics-color', # gcc >= 4.9
- '-Werror'
+ '-Werror',
+ '-Wno-error=deprecated-register',
]
if areCustomCxxflagsPresent:
missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
@@ -45,17 +36,35 @@
if not areCustomCxxflagsPresent:
conf.add_supported_cxxflags(defaultFlags)
+ # clang on OSX < 10.9 by default uses gcc's libstdc++, which is not C++11 compatible
+ conf.add_supported_linkflags(['-stdlib=libc++'])
+
@Configure.conf
def add_supported_cxxflags(self, cxxflags):
"""
Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
"""
- self.start_msg('Checking allowed flags for c++ compiler')
+ self.start_msg('Checking supported CXXFLAGS')
supportedFlags = []
for flag in cxxflags:
- if self.check_cxx(cxxflags=[flag], mandatory=False):
+ if self.check_cxx(cxxflags=['-Werror', flag], mandatory=False):
supportedFlags += [flag]
self.end_msg(' '.join(supportedFlags))
self.env.CXXFLAGS = supportedFlags + self.env.CXXFLAGS
+
+@Configure.conf
+def add_supported_linkflags(self, linkflags):
+ """
+ Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
+ """
+ self.start_msg('Checking supported LINKFLAGS')
+
+ supportedFlags = []
+ for flag in linkflags:
+ if self.check_cxx(linkflags=['-Werror', flag], mandatory=False):
+ supportedFlags += [flag]
+
+ self.end_msg(' '.join(supportedFlags))
+ self.env.LINKFLAGS = supportedFlags + self.env.LINKFLAGS
diff --git a/src/common.hpp b/src/common.hpp
index 317789c..ee122d3 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -43,6 +43,8 @@
#include <list>
#include <algorithm>
#include <iostream>
+#include <functional>
+#include <memory>
namespace repo {
@@ -58,13 +60,11 @@
using ndn::Scheduler;
using ndn::ValidatorConfig;
-using ndn::bind;
-using ndn::shared_ptr;
-using ndn::make_shared;
-using ndn::enable_shared_from_this;
-
-using std::vector;
-using std::string;
+using std::shared_ptr;
+using std::make_shared;
+using std::bind;
+using std::placeholders::_1;
+using std::placeholders::_2;
using boost::noncopyable;
diff --git a/src/handles/base-handle.hpp b/src/handles/base-handle.hpp
index 44ac4a8..95b8caa 100644
--- a/src/handles/base-handle.hpp
+++ b/src/handles/base-handle.hpp
@@ -110,7 +110,7 @@
inline void
BaseHandle::reply(const Interest& commandInterest, const RepoCommandResponse& response)
{
- shared_ptr<Data> rdata = make_shared<Data>(commandInterest.getName());
+ std::shared_ptr<Data> rdata = std::make_shared<Data>(commandInterest.getName());
rdata->setContent(response.wireEncode());
m_keyChain.sign(*rdata);
m_face.put(*rdata);
diff --git a/src/handles/delete-handle.cpp b/src/handles/delete-handle.cpp
index c6ad7c5..5cd0506 100644
--- a/src/handles/delete-handle.cpp
+++ b/src/handles/delete-handle.cpp
@@ -92,7 +92,8 @@
}
void
-DeleteHandle::onValidationFailed(const shared_ptr<const Interest>& interest, const string& reason)
+DeleteHandle::onValidationFailed(const shared_ptr<const Interest>& interest,
+ const std::string& reason)
{
std::cerr << reason << std::endl;
negativeReply(*interest, 401);
diff --git a/src/handles/delete-handle.hpp b/src/handles/delete-handle.hpp
index 91ff244..5493d2e 100644
--- a/src/handles/delete-handle.hpp
+++ b/src/handles/delete-handle.hpp
@@ -25,8 +25,6 @@
namespace repo {
-using std::vector;
-
class DeleteHandle : public BaseHandle
{
@@ -56,10 +54,10 @@
onRegisterFailed(const Name& prefix, const std::string& reason);
void
- onValidated(const shared_ptr<const Interest>& interest, const Name& prefix);
+ onValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix);
void
- onValidationFailed(const shared_ptr<const Interest>& interest, const string& reason);
+ onValidationFailed(const std::shared_ptr<const Interest>& interest, const std::string& reason);
/**
* @todo delete check has not been realized due to the while loop of segmented data deletion.
diff --git a/src/handles/tcp-bulk-insert-handle.hpp b/src/handles/tcp-bulk-insert-handle.hpp
index ef1cbdd..62ced11 100644
--- a/src/handles/tcp-bulk-insert-handle.hpp
+++ b/src/handles/tcp-bulk-insert-handle.hpp
@@ -59,7 +59,7 @@
private:
void
handleAccept(const boost::system::error_code& error,
- const shared_ptr<boost::asio::ip::tcp::socket>& socket);
+ const std::shared_ptr<boost::asio::ip::tcp::socket>& socket);
private:
boost::asio::ip::tcp::acceptor m_acceptor;
diff --git a/src/handles/watch-handle.cpp b/src/handles/watch-handle.cpp
index 15a82fa..9e80212 100644
--- a/src/handles/watch-handle.cpp
+++ b/src/handles/watch-handle.cpp
@@ -98,7 +98,8 @@
}
void
-WatchHandle::onValidationFailed(const shared_ptr<const Interest>& interest, const string& reason)
+WatchHandle::onValidationFailed(const shared_ptr<const Interest>& interest,
+ const std::string& reason)
{
std::cerr << reason << std::endl;
negativeReply(*interest, 401);
diff --git a/src/handles/watch-handle.hpp b/src/handles/watch-handle.hpp
index 10cddda..2fde3cf 100644
--- a/src/handles/watch-handle.hpp
+++ b/src/handles/watch-handle.hpp
@@ -71,10 +71,10 @@
onInterest(const Name& prefix, const Interest& interest);
void
- onValidated(const shared_ptr<const Interest>& interest, const Name& prefix);
+ onValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix);
void
- onValidationFailed(const shared_ptr<const Interest>& interest, const string& reason);
+ onValidationFailed(const std::shared_ptr<const Interest>& interest, const std::string& reason);
void
onRegistered(const Name& prefix);
@@ -96,14 +96,14 @@
onTimeout(const Interest& interest, const Name& name);
void
- onDataValidated(const Interest& interest, const shared_ptr<const Data>& data,
+ onDataValidated(const Interest& interest, const std::shared_ptr<const Data>& data,
const Name& name);
/**
* @brief failure of validation
*/
void
- onDataValidationFailed(const Interest& interest, const shared_ptr<const Data>& data,
+ onDataValidationFailed(const Interest& interest, const std::shared_ptr<const Data>& data,
const std::string& reason, const Name& name);
@@ -121,10 +121,11 @@
onCheckInterest(const Name& prefix, const Interest& interest);
void
- onCheckValidated(const shared_ptr<const Interest>& interest, const Name& prefix);
+ onCheckValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix);
void
- onCheckValidationFailed(const shared_ptr<const Interest>& interest, const std::string& reason);
+ onCheckValidationFailed(const std::shared_ptr<const Interest>& interest,
+ const std::string& reason);
private: // watch stop command
/**
@@ -134,10 +135,11 @@
onStopInterest(const Name& prefix, const Interest& interest);
void
- onStopValidated(const shared_ptr<const Interest>& interest, const Name& prefix);
+ onStopValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix);
void
- onStopValidationFailed(const shared_ptr<const Interest>& interest, const std::string& reason);
+ onStopValidationFailed(const std::shared_ptr<const Interest>& interest,
+ const std::string& reason);
private:
void
diff --git a/src/handles/write-handle.cpp b/src/handles/write-handle.cpp
index 0bc4e12..08e951b 100644
--- a/src/handles/write-handle.cpp
+++ b/src/handles/write-handle.cpp
@@ -20,7 +20,6 @@
#include "write-handle.hpp"
namespace repo {
-using namespace ndn::time;
static const int RETRY_TIMEOUT = 3;
static const int DEFAULT_CREDIT = 12;
@@ -72,7 +71,7 @@
}
void
-WriteHandle::onValidated(const shared_ptr<const Interest>& interest, const Name& prefix)
+WriteHandle::onValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix)
{
//m_validResult = 1;
RepoCommandParameter parameter;
@@ -99,14 +98,15 @@
}
void
-WriteHandle::onValidationFailed(const shared_ptr<const Interest>& interest, const string& reason)
+WriteHandle::onValidationFailed(const std::shared_ptr<const Interest>& interest,
+ const std::string& reason)
{
std::cerr << reason << std::endl;
negativeReply(*interest, 401);
}
void
-WriteHandle::onData(const Interest& interest, ndn::Data& data, ProcessId processId)
+WriteHandle::onData(const Interest& interest, Data& data, ProcessId processId)
{
m_validator.validate(data,
bind(&WriteHandle::onDataValidated, this, interest, _1, processId),
@@ -114,7 +114,8 @@
}
void
-WriteHandle::onDataValidated(const Interest& interest, const shared_ptr<const Data>& data,
+WriteHandle::onDataValidated(const Interest& interest,
+ const std::shared_ptr<const Data>& data,
ProcessId processId)
{
if (m_processes.count(processId) == 0) {
@@ -135,7 +136,8 @@
}
void
-WriteHandle::onDataValidationFailed(const shared_ptr<const Data>& data, const std::string& reason)
+WriteHandle::onDataValidationFailed(const std::shared_ptr<const Data>& data,
+ const std::string& reason)
{
std::cerr << reason << std::endl;
}
@@ -150,7 +152,7 @@
void
WriteHandle::onSegmentDataValidated(const Interest& interest,
- const shared_ptr<const Data>& data,
+ const std::shared_ptr<const Data>& data,
ProcessId processId)
{
if (m_processes.count(processId) == 0) {
@@ -182,7 +184,7 @@
}
void
-WriteHandle::onTimeout(const ndn::Interest& interest, ProcessId processId)
+WriteHandle::onTimeout(const Interest& interest, ProcessId processId)
{
std::cerr << "Timeout" << std::endl;
m_processes.erase(processId);
diff --git a/src/handles/write-handle.hpp b/src/handles/write-handle.hpp
index bbbfe28..1c64437 100644
--- a/src/handles/write-handle.hpp
+++ b/src/handles/write-handle.hpp
@@ -109,10 +109,10 @@
onInterest(const Name& prefix, const Interest& interest);
void
- onValidated(const shared_ptr<const Interest>& interest, const Name& prefix);
+ onValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix);
void
- onValidationFailed(const shared_ptr<const Interest>& interest, const string& reason);
+ onValidationFailed(const std::shared_ptr<const Interest>& interest, const std::string& reason);
/**
* @brief insert command prefix register failed
@@ -128,7 +128,7 @@
onData(const Interest& interest, Data& data, ProcessId processId);
void
- onDataValidated(const Interest& interest, const shared_ptr<const Data>& data,
+ onDataValidated(const Interest& interest, const std::shared_ptr<const Data>& data,
ProcessId processId);
/**
@@ -148,7 +148,7 @@
onSegmentData(const Interest& interest, Data& data, ProcessId processId);
void
- onSegmentDataValidated(const Interest& interest, const shared_ptr<const Data>& data,
+ onSegmentDataValidated(const Interest& interest, const std::shared_ptr<const Data>& data,
ProcessId processId);
/**
@@ -183,7 +183,7 @@
* @brief failure of validation for both one or segmented data
*/
void
- onDataValidationFailed(const shared_ptr<const Data>& data, const std::string& reason);
+ onDataValidationFailed(const std::shared_ptr<const Data>& data, const std::string& reason);
/**
* @brief extends noEndTime of process if not noEndTimeout, set StatusCode 405
@@ -208,10 +208,11 @@
onCheckRegisterFailed(const Name& prefix, const std::string& reason);
void
- onCheckValidated(const shared_ptr<const Interest>& interest, const Name& prefix);
+ onCheckValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix);
void
- onCheckValidationFailed(const shared_ptr<const Interest>& interest, const std::string& reason);
+ onCheckValidationFailed(const std::shared_ptr<const Interest>& interest,
+ const std::string& reason);
private:
void
diff --git a/src/main.cpp b/src/main.cpp
index 3a1be07..9713943 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -20,9 +20,7 @@
#include "config.hpp"
#include "repo.hpp"
-using namespace repo;
-
-static const string ndnRepoUsageMessage =
+static const std::string ndnRepoUsageMessage =
/* argv[0] */ " - Next generation of NDN repository\n"
"-h: show help message\n"
"-c: set config file path\n"
@@ -46,15 +44,16 @@
else
{
/// \todo May be try to reload config file
- signalSet.async_wait(bind(&terminate, boost::ref(ioService), _1, _2,
- boost::ref(signalSet)));
+ signalSet.async_wait(std::bind(&terminate, std::ref(ioService),
+ std::placeholders::_1, std::placeholders::_2,
+ std::ref(signalSet)));
}
}
int
main(int argc, char** argv)
{
- string configPath = DEFAULT_CONFIG_FILE;
+ std::string configPath = DEFAULT_CONFIG_FILE;
int opt;
while ((opt = getopt(argc, argv, "hc:")) != -1) {
switch (opt) {
@@ -62,7 +61,7 @@
std::cout << argv[0] << ndnRepoUsageMessage << std::endl;
return 1;
case 'c':
- configPath = string(optarg);
+ configPath = std::string(optarg);
break;
default:
break;
@@ -71,7 +70,7 @@
try {
boost::asio::io_service ioService;
- Repo repoInstance(ioService, parseConfig(configPath));
+ repo::Repo repoInstance(ioService, repo::parseConfig(configPath));
boost::asio::signal_set signalSet(ioService);
signalSet.add(SIGINT);
@@ -79,8 +78,9 @@
signalSet.add(SIGHUP);
signalSet.add(SIGUSR1);
signalSet.add(SIGUSR2);
- signalSet.async_wait(bind(&terminate, boost::ref(ioService), _1, _2,
- boost::ref(signalSet)));
+ signalSet.async_wait(std::bind(&terminate, std::ref(ioService),
+ std::placeholders::_1, std::placeholders::_2,
+ std::ref(signalSet)));
repoInstance.initializeStorage();
diff --git a/src/repo.cpp b/src/repo.cpp
index 02c80da..64287e2 100644
--- a/src/repo.cpp
+++ b/src/repo.cpp
@@ -19,6 +19,7 @@
#include "repo.hpp"
#include "storage/sqlite-storage.hpp"
+
namespace repo {
RepoConfig
@@ -114,7 +115,7 @@
: m_config(config)
, m_scheduler(ioService)
, m_face(ioService)
- , m_store(make_shared<SqliteStorage>(config.dbPath))
+ , m_store(std::make_shared<SqliteStorage>(config.dbPath))
, m_storageHandle(config.nMaxPackets, *m_store)
, m_validator(m_face)
, m_readHandle(m_face, m_storageHandle, m_keyChain, m_scheduler)
@@ -142,7 +143,7 @@
Repo::enableListening()
{
// Enable "listening" on Data prefixes
- for (vector<ndn::Name>::iterator it = m_config.dataPrefixes.begin();
+ for (auto it = m_config.dataPrefixes.begin();
it != m_config.dataPrefixes.end();
++it)
{
@@ -150,7 +151,7 @@
}
// Enable "listening" on control prefixes
- for (vector<ndn::Name>::iterator it = m_config.repoPrefixes.begin();
+ for (auto it = m_config.repoPrefixes.begin();
it != m_config.repoPrefixes.end();
++it)
{
@@ -160,7 +161,7 @@
}
// Enable listening on TCP bulk insert addresses
- for (vector<pair<string, string> >::iterator it = m_config.tcpBulkInsertEndpoints.begin();
+ for (auto it = m_config.tcpBulkInsertEndpoints.begin();
it != m_config.tcpBulkInsertEndpoints.end();
++it)
{
diff --git a/src/repo.hpp b/src/repo.hpp
index e1feea6..3e7e89d 100644
--- a/src/repo.hpp
+++ b/src/repo.hpp
@@ -37,18 +37,14 @@
namespace repo {
-using std::string;
-using std::vector;
-using std::pair;
-
struct RepoConfig
{
- string repoConfigPath;
+ std::string repoConfigPath;
//StorageMethod storageMethod; This will be implemtented if there is other method.
std::string dbPath;
- vector<ndn::Name> dataPrefixes;
- vector<ndn::Name> repoPrefixes;
- vector<pair<string, string> > tcpBulkInsertEndpoints;
+ std::vector<ndn::Name> dataPrefixes;
+ std::vector<ndn::Name> repoPrefixes;
+ std::vector<std::pair<std::string, std::string> > tcpBulkInsertEndpoints;
int64_t nMaxPackets;
boost::property_tree::ptree validatorNode;
};
@@ -86,7 +82,7 @@
RepoConfig m_config;
ndn::Scheduler m_scheduler;
ndn::Face m_face;
- shared_ptr<Storage> m_store;
+ std::shared_ptr<Storage> m_store;
RepoStorage m_storageHandle;
KeyChain m_keyChain;
ValidatorConfig m_validator;
diff --git a/src/storage/repo-storage.hpp b/src/storage/repo-storage.hpp
index ed0ce9d..bc2ecbe 100644
--- a/src/storage/repo-storage.hpp
+++ b/src/storage/repo-storage.hpp
@@ -84,15 +84,14 @@
/**
* @brief read data from repo
* @param interest used to request data
- * @return std::pair<bool,shared_ptr<Data> >
+ * @return std::shared_ptr<Data>
*/
- shared_ptr<Data>
+ std::shared_ptr<Data>
readData(const Interest& interest) const;
private:
Index m_index;
Storage& m_storage;
-
};
} // namespace repo
diff --git a/src/storage/skiplist.hpp b/src/storage/skiplist.hpp
index 34c7c57..e6dd6a0 100644
--- a/src/storage/skiplist.hpp
+++ b/src/storage/skiplist.hpp
@@ -397,7 +397,7 @@
m_head->prevs.resize(newLevel + 1, m_head);
insertPositions.resize(newLevel + 1, m_head);
}
- for (int i = 0; i <= newLevel; i++) {
+ for (size_t i = 0; i <= newLevel; i++) {
newNode->nexts[i] = insertPositions[i]->nexts[i];
newNode->prevs[i] = insertPositions[i];
insertPositions[i]->nexts[i] = newNode;
diff --git a/src/storage/sqlite-storage.cpp b/src/storage/sqlite-storage.cpp
index 78b1792..7edcda7 100644
--- a/src/storage/sqlite-storage.cpp
+++ b/src/storage/sqlite-storage.cpp
@@ -25,6 +25,8 @@
namespace repo {
+using std::string;
+
SqliteStorage::SqliteStorage(const string& dbPath)
: m_size(0)
{
diff --git a/src/storage/sqlite-storage.hpp b/src/storage/sqlite-storage.hpp
index 73579c7..168cc41 100755
--- a/src/storage/sqlite-storage.hpp
+++ b/src/storage/sqlite-storage.hpp
@@ -48,7 +48,7 @@
};
explicit
- SqliteStorage(const string& dbPath);
+ SqliteStorage(const std::string& dbPath);
virtual
~SqliteStorage();
@@ -72,7 +72,7 @@
* @brief get the data from database
* @para id id number of each entry in the database, used to find the data
*/
- virtual shared_ptr<Data>
+ virtual std::shared_ptr<Data>
read(const int64_t id);
/**
@@ -86,7 +86,7 @@
* insertItemToIndex to reubuild index from database
*/
void
- fullEnumerate(const ndn::function<void(const Storage::ItemMeta)>& f);
+ fullEnumerate(const std::function<void(const Storage::ItemMeta)>& f);
private:
void
@@ -94,7 +94,7 @@
private:
sqlite3* m_db;
- string m_dbPath;
+ std::string m_dbPath;
int64_t m_size;
};
diff --git a/src/storage/storage.hpp b/src/storage/storage.hpp
index 04f366f..bf75306 100755
--- a/src/storage/storage.hpp
+++ b/src/storage/storage.hpp
@@ -76,7 +76,7 @@
* @brief get the data from database
* @param id id number of each entry in the database, used to find the data
*/
- virtual shared_ptr<Data>
+ virtual std::shared_ptr<Data>
read(const int64_t id) = 0;
/**
@@ -90,7 +90,7 @@
* insertItemToIndex to reubuild index from database
*/
virtual void
- fullEnumerate(const ndn::function<void(const Storage::ItemMeta)>& f) = 0;
+ fullEnumerate(const std::function<void(const Storage::ItemMeta)>& f) = 0;
};
diff --git a/tools/ndngetfile.cpp b/tools/ndngetfile.cpp
index 50f8ab3..db1b22b 100644
--- a/tools/ndngetfile.cpp
+++ b/tools/ndngetfile.cpp
@@ -23,7 +23,14 @@
namespace repo {
-using namespace ndn;
+using ndn::Name;
+using ndn::Interest;
+using ndn::Data;
+using ndn::Block;
+
+using std::bind;
+using std::placeholders::_1;
+using std::placeholders::_2;
static const int MAX_RETRY = 3;
@@ -45,9 +52,9 @@
m_face.expressInterest(interest,
m_hasVersion ?
- bind(&Consumer::onVersionedData, this, _1, _2)
- :
- bind(&Consumer::onUnversionedData, this, _1, _2),
+ bind(&Consumer::onVersionedData, this, _1, _2)
+ :
+ bind(&Consumer::onUnversionedData, this, _1, _2),
bind(&Consumer::onTimeout, this, _1));
}
@@ -161,7 +168,7 @@
{
uint64_t segment = name[-1].toSegment();
BOOST_ASSERT(segment == (m_nextSegment - 1));
- const name::Component& finalBlockId = data.getMetaInfo().getFinalBlockId();
+ const ndn::name::Component& finalBlockId = data.getMetaInfo().getFinalBlockId();
if (finalBlockId == name[-1]) {
m_isFinished = true;
}
diff --git a/tools/ndnputfile.cpp b/tools/ndnputfile.cpp
index ffe5519..9d20a63 100644
--- a/tools/ndnputfile.cpp
+++ b/tools/ndnputfile.cpp
@@ -38,6 +38,12 @@
using namespace ndn::time;
+using std::shared_ptr;
+using std::make_shared;
+using std::bind;
+using std::placeholders::_1;
+using std::placeholders::_2;
+
static const uint64_t DEFAULT_BLOCK_SIZE = 1000;
static const uint64_t DEFAULT_INTEREST_LIFETIME = 4000;
static const uint64_t DEFAULT_FRESHNESS_PERIOD = 10000;
@@ -151,7 +157,7 @@
bool m_isFinished;
ndn::Name m_dataPrefix;
- typedef std::map<uint64_t, ndn::shared_ptr<ndn::Data> > DataContainer;
+ typedef std::map<uint64_t, shared_ptr<ndn::Data> > DataContainer;
DataContainer m_data;
};
@@ -185,8 +191,8 @@
throw Error("Error reading from the input stream");
}
- ndn::shared_ptr<ndn::Data> data =
- ndn::make_shared<ndn::Data>(Name(m_dataPrefix)
+ shared_ptr<ndn::Data> data =
+ make_shared<ndn::Data>(Name(m_dataPrefix)
.appendSegment(m_currentSegmentNo));
if (insertStream->peek() == std::istream::traits_type::eof()) {
@@ -215,15 +221,15 @@
std::cerr << "setInterestFilter for " << m_dataPrefix << std::endl;
m_face.setInterestFilter(m_dataPrefix,
isSingle ?
- 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));
+ bind(&NdnPutFile::onSingleInterest, this, _1, _2)
+ :
+ bind(&NdnPutFile::onInterest, this, _1, _2),
+ bind(&NdnPutFile::onRegisterSuccess, this, _1),
+ bind(&NdnPutFile::onRegisterFailed, this, _1, _2));
if (hasTimeout)
- m_scheduler.scheduleEvent(timeout, ndn::bind(&NdnPutFile::stopProcess, this));
+ m_scheduler.scheduleEvent(timeout, bind(&NdnPutFile::stopProcess, this));
m_face.processEvents();
}
@@ -245,8 +251,8 @@
ndn::Interest commandInterest = generateCommandInterest(repoPrefix, "insert", parameters);
m_face.expressInterest(commandInterest,
- ndn::bind(&NdnPutFile::onInsertCommandResponse, this, _1, _2),
- ndn::bind(&NdnPutFile::onInsertCommandTimeout, this, _1));
+ bind(&NdnPutFile::onInsertCommandResponse, this, _1, _2),
+ bind(&NdnPutFile::onInsertCommandTimeout, this, _1));
}
void
@@ -261,7 +267,7 @@
m_processId = response.getProcessId();
m_scheduler.scheduleEvent(m_checkPeriod,
- ndn::bind(&NdnPutFile::startCheckCommand, this));
+ bind(&NdnPutFile::startCheckCommand, this));
}
void
@@ -336,7 +342,7 @@
throw Error("Input data does not fit into one Data packet");
}
- ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>(m_dataPrefix);
+ shared_ptr<ndn::Data> data = make_shared<ndn::Data>(m_dataPrefix);
data->setContent(buffer, readSize);
data->setFreshnessPeriod(freshnessPeriod);
signData(*data);
@@ -381,8 +387,8 @@
RepoCommandParameter()
.setProcessId(m_processId));
m_face.expressInterest(checkInterest,
- ndn::bind(&NdnPutFile::onCheckCommandResponse, this, _1, _2),
- ndn::bind(&NdnPutFile::onCheckCommandTimeout, this, _1));
+ bind(&NdnPutFile::onCheckCommandResponse, this, _1, _2),
+ bind(&NdnPutFile::onCheckCommandTimeout, this, _1));
}
void
@@ -414,7 +420,7 @@
}
m_scheduler.scheduleEvent(m_checkPeriod,
- ndn::bind(&NdnPutFile::startCheckCommand, this));
+ bind(&NdnPutFile::startCheckCommand, this));
}
void
diff --git a/tools/ndnrepowatch.cpp b/tools/ndnrepowatch.cpp
index a9b6d8b..c5128f3 100644
--- a/tools/ndnrepowatch.cpp
+++ b/tools/ndnrepowatch.cpp
@@ -34,6 +34,11 @@
using namespace ndn::time;
+using std::shared_ptr;
+using std::bind;
+using std::placeholders::_1;
+using std::placeholders::_2;
+
static const uint64_t DEFAULT_INTEREST_LIFETIME = 4000;
static const uint64_t DEFAULT_FRESHNESS_PERIOD = 10000;
static const uint64_t DEFAULT_CHECK_PERIOD = 1000;
@@ -130,7 +135,7 @@
ndn::Name m_dataPrefix;
ndn::KeyChain m_keyChain;
- typedef std::map<uint64_t, ndn::shared_ptr<ndn::Data> > DataContainer;
+ typedef std::map<uint64_t, shared_ptr<ndn::Data> > DataContainer;
};
void
@@ -140,7 +145,7 @@
startWatchCommand();
if (hasTimeout)
- m_scheduler.scheduleEvent(watchTimeout, ndn::bind(&NdnRepoWatch::stopProcess, this));
+ m_scheduler.scheduleEvent(watchTimeout, bind(&NdnRepoWatch::stopProcess, this));
m_face.processEvents();
}
@@ -161,20 +166,23 @@
}
ndn::Interest commandInterest = generateCommandInterest(repoPrefix, "start", parameters);
m_face.expressInterest(commandInterest,
- ndn::bind(&NdnRepoWatch::onWatchCommandResponse, this, _1, _2),
- ndn::bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
+ bind(&NdnRepoWatch::onWatchCommandResponse, this,
+ _1, _2),
+ bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
}
else if (status == STOP){
ndn::Interest commandInterest = generateCommandInterest(repoPrefix, "stop", parameters);
m_face.expressInterest(commandInterest,
- ndn::bind(&NdnRepoWatch::onWatchCommandResponse, this, _1, _2),
- ndn::bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
+ bind(&NdnRepoWatch::onWatchCommandResponse, this,
+ _1, _2),
+ bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
}
else if (status == CHECK){
ndn::Interest commandInterest = generateCommandInterest(repoPrefix, "check", parameters);
m_face.expressInterest(commandInterest,
- ndn::bind(&NdnRepoWatch::onWatchCommandResponse, this, _1, _2),
- ndn::bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
+ bind(&NdnRepoWatch::onWatchCommandResponse, this,
+ _1, _2),
+ bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
}
}
@@ -196,13 +204,13 @@
else if (statusCode == 300) {
std::cerr << "Watching prefix is running!" <<std::endl;
m_scheduler.scheduleEvent(m_checkPeriod,
- ndn::bind(&NdnRepoWatch::startCheckCommand, this));
+ bind(&NdnRepoWatch::startCheckCommand, this));
return;
}
else if (statusCode == 100) {
std::cerr << "Watching prefix starts!" <<std::endl;
m_scheduler.scheduleEvent(m_checkPeriod,
- ndn::bind(&NdnRepoWatch::startCheckCommand, this));
+ bind(&NdnRepoWatch::startCheckCommand, this));
return;
}
else {
@@ -231,8 +239,8 @@
RepoCommandParameter()
.setName(m_dataPrefix));
m_face.expressInterest(checkInterest,
- ndn::bind(&NdnRepoWatch::onWatchCommandResponse, this, _1, _2),
- ndn::bind(&NdnRepoWatch::onCheckCommandTimeout, this, _1));
+ bind(&NdnRepoWatch::onWatchCommandResponse, this, _1, _2),
+ bind(&NdnRepoWatch::onCheckCommandTimeout, this, _1));
}
void
diff --git a/tools/repo-ng-ls.cpp b/tools/repo-ng-ls.cpp
index be51b34..862f133 100644
--- a/tools/repo-ng-ls.cpp
+++ b/tools/repo-ng-ls.cpp
@@ -26,7 +26,7 @@
namespace repo {
-using namespace ndn::time;
+using std::string;
void
printUsage(const char* programName)
diff --git a/waf b/waf
index 78a44f3..ef9df38 100755
--- a/waf
+++ b/waf
Binary files differ