Remove use of deprecated code
Change-Id: I721e9d0f9b41e7a53d75b1fde4a718c349273eeb
Refs: #3988
diff --git a/tools/ndngetfile.cpp b/tools/ndngetfile.cpp
index 99f54ca..1f59a36 100644
--- a/tools/ndngetfile.cpp
+++ b/tools/ndngetfile.cpp
@@ -1,6 +1,6 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/* -*- 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.
@@ -55,6 +55,7 @@
bind(&Consumer::onVersionedData, this, _1, _2)
:
bind(&Consumer::onUnversionedData, this, _1, _2),
+ bind(&Consumer::onTimeout, this, _1), // Nack
bind(&Consumer::onTimeout, this, _1));
}
@@ -72,7 +73,7 @@
}
void
-Consumer::onVersionedData(const Interest& interest, Data& data)
+Consumer::onVersionedData(const Interest& interest, const Data& data)
{
const Name& name = data.getName();
@@ -110,7 +111,7 @@
}
void
-Consumer::onUnversionedData(const Interest& interest, Data& data)
+Consumer::onUnversionedData(const Interest& interest, const Data& data)
{
const Name& name = data.getName();
//std::cout<<"recevied data name = "<<name<<std::endl;
@@ -248,7 +249,7 @@
{
interestLifetime = boost::lexical_cast<int>(optarg);
}
- catch (boost::bad_lexical_cast&)
+ catch (const boost::bad_lexical_cast&)
{
std::cerr << "ERROR: -l option should be an integer." << std::endl;
return 1;
@@ -260,7 +261,7 @@
{
timeout = boost::lexical_cast<int>(optarg);
}
- catch (boost::bad_lexical_cast&)
+ catch (const boost::bad_lexical_cast&)
{
std::cerr << "ERROR: -w option should be an integer." << std::endl;
return 1;
diff --git a/tools/ndngetfile.hpp b/tools/ndngetfile.hpp
index 8e84440..e7e851b 100644
--- a/tools/ndngetfile.hpp
+++ b/tools/ndngetfile.hpp
@@ -1,6 +1,6 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/* -*- 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.
@@ -55,14 +55,14 @@
fetchData(const ndn::Name& name);
void
- onVersionedData(const ndn::Interest& interest, ndn::Data& data);
+ onVersionedData(const ndn::Interest& interest, const ndn::Data& data);
void
- onUnversionedData(const ndn::Interest& interest, ndn::Data& data);
+ onUnversionedData(const ndn::Interest& interest, const ndn::Data& data);
void
onTimeout(const ndn::Interest& interest);
-
+
void
readData(const ndn::Data& data);
diff --git a/tools/ndnputfile.cpp b/tools/ndnputfile.cpp
index 7dd92e5..f08a7a3 100644
--- a/tools/ndnputfile.cpp
+++ b/tools/ndnputfile.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, 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.
@@ -14,7 +14,7 @@
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
- * repo-ng, e.g., in COPYING.md file. if (not, see <http://www.gnu.org/licenses/>.
+ * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../src/repo-command-parameter.hpp"
@@ -50,7 +50,7 @@
static const uint64_t DEFAULT_CHECK_PERIOD = 1000;
static const size_t PRE_SIGN_DATA_COUNT = 11;
-class NdnPutFile : ndn::noncopyable
+class NdnPutFile : boost::noncopyable
{
public:
class Error : public std::runtime_error
@@ -93,7 +93,7 @@
startInsertCommand();
void
- onInsertCommandResponse(const ndn::Interest& interest, ndn::Data& data);
+ onInsertCommandResponse(const ndn::Interest& interest, const ndn::Data& data);
void
onInsertCommandTimeout(const ndn::Interest& interest);
@@ -120,7 +120,7 @@
startCheckCommand();
void
- onCheckCommandResponse(const ndn::Interest& interest, ndn::Data& data);
+ onCheckCommandResponse(const ndn::Interest& interest, const ndn::Data& data);
void
onCheckCommandTimeout(const ndn::Interest& interest);
@@ -186,7 +186,7 @@
boost::iostreams::read(*insertStream, reinterpret_cast<char*>(buffer), DEFAULT_BLOCK_SIZE);
if (readSize <= 0) {
- throw Error("Error reading from the input stream");
+ BOOST_THROW_EXCEPTION(Error("Error reading from the input stream"));
}
shared_ptr<ndn::Data> data =
@@ -250,17 +250,18 @@
ndn::Interest commandInterest = generateCommandInterest(repoPrefix, "insert", parameters);
m_face.expressInterest(commandInterest,
bind(&NdnPutFile::onInsertCommandResponse, this, _1, _2),
+ bind(&NdnPutFile::onInsertCommandTimeout, this, _1), // Nack
bind(&NdnPutFile::onInsertCommandTimeout, this, _1));
}
void
-NdnPutFile::onInsertCommandResponse(const ndn::Interest& interest, ndn::Data& data)
+NdnPutFile::onInsertCommandResponse(const ndn::Interest& interest, const ndn::Data& data)
{
RepoCommandResponse response(data.getContent().blockFromValue());
int statusCode = response.getStatusCode();
if (statusCode >= 400) {
- throw Error("insert command failed with code " +
- boost::lexical_cast<std::string>(statusCode));
+ BOOST_THROW_EXCEPTION(Error("insert command failed with code " +
+ boost::lexical_cast<std::string>(statusCode)));
}
m_processId = response.getProcessId();
@@ -271,7 +272,7 @@
void
NdnPutFile::onInsertCommandTimeout(const ndn::Interest& interest)
{
- throw Error("command response timeout");
+ BOOST_THROW_EXCEPTION(Error("command response timeout"));
}
void
@@ -290,7 +291,7 @@
ndn::Name::Component segmentComponent = interest.getName().get(prefix.size());
segmentNo = segmentComponent.toSegment();
}
- catch (tlv::Error& e) {
+ catch (const tlv::Error& e) {
if (isVerbose) {
std::cerr << "Error processing incoming interest " << interest << ": "
<< e.what() << std::endl;
@@ -333,11 +334,11 @@
boost::iostreams::read(*insertStream, reinterpret_cast<char*>(buffer), DEFAULT_BLOCK_SIZE);
if (readSize <= 0) {
- throw Error("Error reading from the input stream");
+ BOOST_THROW_EXCEPTION(Error("Error reading from the input stream"));
}
if (insertStream->peek() != std::istream::traits_type::eof()) {
- throw Error("Input data does not fit into one Data packet");
+ BOOST_THROW_EXCEPTION(Error("Input data does not fit into one Data packet"));
}
shared_ptr<ndn::Data> data = make_shared<ndn::Data>(m_dataPrefix);
@@ -352,7 +353,7 @@
void
NdnPutFile::onRegisterFailed(const ndn::Name& prefix, const std::string& reason)
{
- throw Error("onRegisterFailed: " + reason);
+ BOOST_THROW_EXCEPTION(Error("onRegisterFailed: " + reason));
}
void
@@ -386,17 +387,18 @@
.setProcessId(m_processId));
m_face.expressInterest(checkInterest,
bind(&NdnPutFile::onCheckCommandResponse, this, _1, _2),
+ bind(&NdnPutFile::onCheckCommandTimeout, this, _1), // Nack
bind(&NdnPutFile::onCheckCommandTimeout, this, _1));
}
void
-NdnPutFile::onCheckCommandResponse(const ndn::Interest& interest, ndn::Data& data)
+NdnPutFile::onCheckCommandResponse(const ndn::Interest& interest, const ndn::Data& data)
{
RepoCommandResponse response(data.getContent().blockFromValue());
int statusCode = response.getStatusCode();
if (statusCode >= 400) {
- throw Error("Insert check command failed with code: " +
- boost::lexical_cast<std::string>(statusCode));
+ BOOST_THROW_EXCEPTION(Error("Insert check command failed with code: " +
+ boost::lexical_cast<std::string>(statusCode)));
}
if (m_isFinished) {
@@ -424,7 +426,7 @@
void
NdnPutFile::onCheckCommandTimeout(const ndn::Interest& interest)
{
- throw Error("check response timeout");
+ BOOST_THROW_EXCEPTION(Error("check response timeout"));
}
ndn::Interest
@@ -495,7 +497,7 @@
try {
ndnPutFile.freshnessPeriod = milliseconds(boost::lexical_cast<uint64_t>(optarg));
}
- catch (boost::bad_lexical_cast&) {
+ catch (const boost::bad_lexical_cast&) {
std::cerr << "-x option should be an integer.";
return 1;
}
@@ -504,7 +506,7 @@
try {
ndnPutFile.interestLifetime = milliseconds(boost::lexical_cast<uint64_t>(optarg));
}
- catch (boost::bad_lexical_cast&) {
+ catch (const boost::bad_lexical_cast&) {
std::cerr << "-l option should be an integer.";
return 1;
}
@@ -514,7 +516,7 @@
try {
ndnPutFile.timeout = milliseconds(boost::lexical_cast<uint64_t>(optarg));
}
- catch (boost::bad_lexical_cast&) {
+ catch (const boost::bad_lexical_cast&) {
std::cerr << "-w option should be an integer.";
return 1;
}
@@ -567,7 +569,7 @@
try {
return repo::main(argc, argv);
}
- catch (std::exception& e) {
+ catch (const std::exception& e) {
std::cerr << "ERROR: " << e.what() << std::endl;
return 2;
}
diff --git a/tools/ndnrepowatch.cpp b/tools/ndnrepowatch.cpp
index c5128f3..4172d79 100644
--- a/tools/ndnrepowatch.cpp
+++ b/tools/ndnrepowatch.cpp
@@ -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.
@@ -14,7 +14,7 @@
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
- * repo-ng, e.g., in COPYING.md file. if (not, see <http://www.gnu.org/licenses/>.
+ * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../src/repo-command-parameter.hpp"
@@ -50,7 +50,7 @@
STOP
};
-class NdnRepoWatch : ndn::noncopyable
+class NdnRepoWatch : boost::noncopyable
{
public:
class Error : public std::runtime_error
@@ -87,7 +87,7 @@
startWatchCommand();
void
- onWatchCommandResponse(const ndn::Interest& interest, ndn::Data& data);
+ onWatchCommandResponse(const ndn::Interest& interest, const ndn::Data& data);
void
onWatchCommandTimeout(const ndn::Interest& interest);
@@ -168,6 +168,7 @@
m_face.expressInterest(commandInterest,
bind(&NdnRepoWatch::onWatchCommandResponse, this,
_1, _2),
+ bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1), // Nack
bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
}
else if (status == STOP){
@@ -175,6 +176,7 @@
m_face.expressInterest(commandInterest,
bind(&NdnRepoWatch::onWatchCommandResponse, this,
_1, _2),
+ bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1), // Nack
bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
}
else if (status == CHECK){
@@ -182,19 +184,20 @@
m_face.expressInterest(commandInterest,
bind(&NdnRepoWatch::onWatchCommandResponse, this,
_1, _2),
+ bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1), // Nack
bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
}
}
void
-NdnRepoWatch::onWatchCommandResponse(const ndn::Interest& interest, ndn::Data& data)
+NdnRepoWatch::onWatchCommandResponse(const ndn::Interest& interest, const ndn::Data& data)
{
RepoCommandResponse response(data.getContent().blockFromValue());
int statusCode = response.getStatusCode();
if (statusCode >= 400) {
- throw Error("Watch command failed with code " +
- boost::lexical_cast<std::string>(statusCode));
+ BOOST_THROW_EXCEPTION(Error("Watch command failed with code " +
+ boost::lexical_cast<std::string>(statusCode)));
}
else if (statusCode == 101) {
std::cerr << "Watching prefix is stopped!" <<std::endl;
@@ -214,15 +217,15 @@
return;
}
else {
- throw Error("Unrecognized Status Code " +
- boost::lexical_cast<std::string>(statusCode));
+ BOOST_THROW_EXCEPTION(Error("Unrecognized Status Code " +
+ boost::lexical_cast<std::string>(statusCode)));
}
}
void
NdnRepoWatch::onWatchCommandTimeout(const ndn::Interest& interest)
{
- throw Error("command response timeout");
+ BOOST_THROW_EXCEPTION(Error("command response timeout"));
}
void
@@ -240,13 +243,14 @@
.setName(m_dataPrefix));
m_face.expressInterest(checkInterest,
bind(&NdnRepoWatch::onWatchCommandResponse, this, _1, _2),
+ bind(&NdnRepoWatch::onCheckCommandTimeout, this, _1), // Nack
bind(&NdnRepoWatch::onCheckCommandTimeout, this, _1));
}
void
NdnRepoWatch::onCheckCommandTimeout(const ndn::Interest& interest)
{
- throw Error("check response timeout");
+ BOOST_THROW_EXCEPTION(Error("check response timeout"));
}
void
@@ -255,8 +259,8 @@
RepoCommandResponse response(data.getContent().blockFromValue());
int statusCode = response.getStatusCode();
if (statusCode != 101) {
- throw Error("Watch stop command failed with code: " +
- boost::lexical_cast<std::string>(statusCode));
+ BOOST_THROW_EXCEPTION(Error("Watch stop command failed with code: " +
+ boost::lexical_cast<std::string>(statusCode)));
}
else {
std::cerr << "Status code is 101. Watching prefix is stopped successfully!" << std::endl;
@@ -268,7 +272,7 @@
void
NdnRepoWatch::onStopCommandTimeout(const ndn::Interest& interest)
{
- throw Error("stop response timeout");
+ BOOST_THROW_EXCEPTION(Error("stop response timeout"));
}
ndn::Interest
@@ -322,7 +326,7 @@
try {
app.freshnessPeriod = milliseconds(boost::lexical_cast<uint64_t>(optarg));
}
- catch (boost::bad_lexical_cast&) {
+ catch (const boost::bad_lexical_cast&) {
std::cerr << "-x option should be an integer.";
return 1;
}
@@ -331,7 +335,7 @@
try {
app.interestLifetime = milliseconds(boost::lexical_cast<uint64_t>(optarg));
}
- catch (boost::bad_lexical_cast&) {
+ catch (const boost::bad_lexical_cast&) {
std::cerr << "-l option should be an integer.";
return 1;
}
@@ -341,7 +345,7 @@
try {
app.watchTimeout = milliseconds(boost::lexical_cast<int64_t>(optarg));
}
- catch (boost::bad_lexical_cast&) {
+ catch (const boost::bad_lexical_cast&) {
std::cerr << "-w option should be an integer.";
return 1;
}
@@ -351,7 +355,7 @@
try {
app.maxInterestNum = boost::lexical_cast<int64_t>(optarg);
}
- catch (boost::bad_lexical_cast&) {
+ catch (const boost::bad_lexical_cast&) {
std::cerr << "-n option should be an integer.";
return 1;
}
@@ -398,7 +402,7 @@
try {
return repo::main(argc, argv);
}
- catch (std::exception& e) {
+ catch (const std::exception& e) {
std::cerr << "ERROR: " << e.what() << std::endl;
return 2;
}
diff --git a/tools/repo-ng-ls.cpp b/tools/repo-ng-ls.cpp
index 862f133..3a916a3 100644
--- a/tools/repo-ng-ls.cpp
+++ b/tools/repo-ng-ls.cpp
@@ -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.
@@ -14,7 +14,7 @@
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
- * repo-ng, e.g., in COPYING.md file. if (not, see <http://www.gnu.org/licenses/>.
+ * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../src/common.hpp"
@@ -88,7 +88,7 @@
#endif
);
if (rc != SQLITE_OK) {
- throw Error("Database file open failure");
+ BOOST_THROW_EXCEPTION(Error("Database file open failure"));
}
sqlite3_exec(m_db, "PRAGMA synchronous = OFF", 0, 0, &errMsg);
sqlite3_exec(m_db, "PRAGMA journal_mode = WAL", 0, 0, &errMsg);
@@ -98,20 +98,20 @@
RepoEnumerator::readConfig(const std::string& configFile)
{
if (configFile.empty()) {
- throw Error("Invalid configuration file name");
+ BOOST_THROW_EXCEPTION(Error("Invalid configuration file name"));
}
std::ifstream fin(configFile.c_str());
if (!fin.is_open())
- throw Error("failed to open configuration file '" + configFile + "'");
+ BOOST_THROW_EXCEPTION(Error("failed to open configuration file '" + configFile + "'"));
using namespace boost::property_tree;
ptree propertyTree;
try {
read_info(fin, propertyTree);
}
- catch (ptree_error& e) {
- throw Error("failed to read configuration file '" + configFile + "'");
+ catch (const ptree_error& e) {
+ BOOST_THROW_EXCEPTION(Error("failed to read configuration file '" + configFile + "'"));
}
ptree repoConf = propertyTree.get_child("repo");
m_dbPath = repoConf.get<std::string>("storage.path");
@@ -126,7 +126,7 @@
string sql = string("SELECT id, name, keylocatorHash FROM NDN_REPO;");
rc = sqlite3_prepare_v2(m_db, sql.c_str(), -1, &m_stmt, 0);
if (rc != SQLITE_OK)
- throw Error("Initiation Read Entries from Database Prepare error");
+ BOOST_THROW_EXCEPTION(Error("Initiation Read Entries from Database Prepare error"));
uint64_t entryNumber = 0;
while (true) {
rc = sqlite3_step(m_stmt);
@@ -154,7 +154,7 @@
}
else {
sqlite3_finalize(m_stmt);
- throw Error("Initiation Read Entries error");
+ BOOST_THROW_EXCEPTION(Error("Initiation Read Entries error"));
}
}
return entryNumber;
@@ -197,7 +197,7 @@
try {
return repo::main(argc, argv);
}
- catch (std::exception& e) {
+ catch (const std::exception& e) {
std::cerr << "ERROR: " << e.what() << std::endl;
return 2;
}