build: migrate to C++17

Change-Id: Ic5c01274f62556764ea96fc232cf3d835c4ab659
This commit is contained in:
Davide Pesavento committed 2022-07-23 13:51:24 -04:00
1 parent 5a6292db4e
commit 8663ed1c21
17 files changed
+91 -147

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ if has CentOS-8 $NODE_LABELS; then
fi
CXX=${CXX:-g++}
STD=-std=c++14
STD=-std=c++17
CXXFLAGS="-O2 -Wall -Wno-unneeded-internal-declaration -Wno-unused-const-variable $(pkg-config --cflags libndn-cxx $PROJ)"
INCLUDEDIR="$(pkg-config --variable=includedir $PROJ)"/$PROJ
+1 -1
View File
@@ -136,7 +136,7 @@ class GccBasicFlags(CompilerFlags):
"""
def getGeneralFlags(self, conf):
flags = super(GccBasicFlags, self).getGeneralFlags(conf)
flags['CXXFLAGS'] += ['-std=c++14']
flags['CXXFLAGS'] += ['-std=c++17']
if Utils.unversioned_sys_platform() == 'linux':
flags['LINKFLAGS'] += ['-fuse-ld=gold']
elif Utils.unversioned_sys_platform() == 'freebsd':
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2021 University of California, Los Angeles
* Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -27,8 +27,7 @@
#include <ndn-cxx/encoding/buffer-stream.hpp>
namespace chronosync {
namespace bzip2 {
namespace chronosync::bzip2 {
namespace bio = boost::iostreams;
@@ -56,5 +55,4 @@ decompress(const char* buffer, size_t bufferSize)
return os.buf();
}
} // namespace bzip2
} // namespace chronosync
} // namespace chronosync::bzip2
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2021 University of California, Los Angeles
* Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -22,8 +22,7 @@
#include <ndn-cxx/encoding/buffer.hpp>
namespace chronosync {
namespace bzip2 {
namespace chronosync::bzip2 {
/**
* @brief Compress @p buffer of size @p bufferSize with bzip2
@@ -37,7 +36,6 @@ compress(const char* buffer, size_t bufferSize);
std::shared_ptr<ndn::Buffer>
decompress(const char* buffer, size_t bufferSize);
} // namespace bzip2
} // namespace chronosync
} // namespace chronosync::bzip2
#endif // CHRONOSYNC_DETAIL_BZIP2_HELPER_HPP
+3 -4
View File
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2021 University of California, Los Angeles
* Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -65,9 +65,7 @@ using boost::noncopyable;
using std::size_t;
using std::bind;
using std::function;
using std::make_shared;
using std::ref;
using std::shared_ptr;
using ndn::Block;
@@ -79,8 +77,9 @@ using ndn::security::Validator;
using ndn::security::ValidationError;
namespace name = ndn::name;
namespace time = ndn::time;
namespace security = ndn::security;
namespace time = ndn::time;
using namespace ndn::time_literals;
} // namespace chronosync
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2021 University of California, Los Angeles
* Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -22,8 +22,7 @@
#ifndef CHRONOSYNC_DETAIL_TLV_HPP
#define CHRONOSYNC_DETAIL_TLV_HPP
namespace chronosync {
namespace tlv {
namespace chronosync::tlv {
/**
* @brief Type value of sync reply related TLVs
@@ -35,7 +34,6 @@ enum {
SeqNo = 130, // 0x82
};
} // namespace tlv
} // namespace chronosync
} // namespace chronosync::tlv
#endif // CHRONOSYNC_DETAIL_TLV_HPP
+16 -36
View File
@@ -37,29 +37,15 @@ NDN_LOG_INIT(sync.Logic);
namespace chronosync {
const uint8_t EMPTY_DIGEST_VALUE[] = {
const std::vector<uint8_t> EMPTY_DIGEST{
0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14,
0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24,
0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c,
0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55
};
int Logic::s_instanceCounter = 0;
const ndn::Name Logic::DEFAULT_NAME;
const ndn::Name Logic::EMPTY_NAME;
const std::shared_ptr<Validator> Logic::DEFAULT_VALIDATOR;
const time::steady_clock::Duration Logic::DEFAULT_RESET_TIMER = time::seconds(0);
const time::steady_clock::Duration Logic::DEFAULT_CANCEL_RESET_TIMER = time::milliseconds(500);
const time::milliseconds Logic::DEFAULT_RESET_INTEREST_LIFETIME(1000);
const time::milliseconds Logic::DEFAULT_SYNC_INTEREST_LIFETIME(1000);
const time::milliseconds Logic::DEFAULT_SYNC_REPLY_FRESHNESS(1000);
const time::milliseconds Logic::DEFAULT_RECOVERY_INTEREST_LIFETIME(1000);
const ConstBufferPtr Logic::EMPTY_DIGEST(new ndn::Buffer(EMPTY_DIGEST_VALUE, 32));
const ndn::name::Component Logic::RESET_COMPONENT("reset");
const ndn::name::Component Logic::RECOVERY_COMPONENT("recovery");
const name::Component RESET_COMPONENT("reset");
const name::Component RECOVERY_COMPONENT("recovery");
const size_t NDNLP_EXPECTED_OVERHEAD = 20;
/**
@@ -84,7 +70,7 @@ getMaxPacketLimit()
if (getenv("CHRONOSYNC_MAX_PACKET_SIZE") != nullptr) {
try {
limit = ndn::clamp<size_t>(boost::lexical_cast<size_t>(getenv("CHRONOSYNC_MAX_PACKET_SIZE")),
limit = std::clamp<size_t>(boost::lexical_cast<size_t>(getenv("CHRONOSYNC_MAX_PACKET_SIZE")),
500, ndn::MAX_NDN_PACKET_SIZE);
}
catch (const boost::bad_lexical_cast&) {
@@ -104,8 +90,8 @@ Logic::Logic(ndn::Face& face,
const UpdateCallback& onUpdate,
const Name& defaultSigningId,
std::shared_ptr<Validator> validator,
const time::steady_clock::Duration& resetTimer,
const time::steady_clock::Duration& cancelResetTimer,
const time::steady_clock::duration& resetTimer,
const time::steady_clock::duration& cancelResetTimer,
const time::milliseconds& resetInterestLifetime,
const time::milliseconds& syncInterestLifetime,
const time::milliseconds& syncReplyFreshness,
@@ -129,7 +115,7 @@ Logic::Logic(ndn::Face& face,
, m_syncInterestLifetime(syncInterestLifetime)
, m_syncReplyFreshness(syncReplyFreshness)
, m_recoveryInterestLifetime(recoveryInterestLifetime)
, m_validator(validator)
, m_validator(std::move(validator))
, m_instanceId(s_instanceCounter++)
{
CHRONO_LOG_DBG(">> Logic::Logic");
@@ -275,19 +261,16 @@ Logic::updateSeqNo(const SeqNo& seqNo, const Name& updatePrefix)
ConstBufferPtr previousRoot = m_state.getRootDigest();
printDigest(previousRoot);
bool isInserted = false;
bool isUpdated = false;
SeqNo oldSeq;
std::tie(isInserted, isUpdated, oldSeq) = m_state.update(node.sessionName, node.seqNo);
auto [isInserted, isUpdated, oldSeq] = m_state.update(node.sessionName, node.seqNo);
CHRONO_LOG_DBG("Insert: " << std::boolalpha << isInserted);
CHRONO_LOG_DBG("Updated: " << std::boolalpha << isUpdated);
(void)oldSeq; // silence "unused variable" warning with gcc 7
if (isInserted || isUpdated) {
DiffStatePtr commit = make_shared<DiffState>();
commit->update(node.sessionName, node.seqNo);
commit->setRootDigest(m_state.getRootDigest());
insertToDiffLog(commit, previousRoot);
satisfyPendingSyncInterests(prefix, commit);
}
}
@@ -445,7 +428,7 @@ Logic::processSyncInterest(const Interest& interest, bool isTimedProcessing/*=fa
}
// If the digest of incoming interest is an "empty" digest
if (*digest == *EMPTY_DIGEST) {
if (*digest == EMPTY_DIGEST) {
CHRONO_LOG_DBG("Poor guy, he knows nothing");
sendSyncData(m_defaultUserPrefix, name, m_state);
return;
@@ -505,10 +488,7 @@ Logic::processSyncData(const Name&, ConstBufferPtr digest, const Block& syncRepl
const Name& info = leaf->getSessionName();
SeqNo seq = leaf->getSeq();
bool isInserted = false;
bool isUpdated = false;
SeqNo oldSeq;
std::tie(isInserted, isUpdated, oldSeq) = m_state.update(info, seq);
auto [isInserted, isUpdated, oldSeq] = m_state.update(info, seq);
if (isInserted || isUpdated) {
commit->update(info, seq);
oldSeq++;
@@ -610,7 +590,7 @@ Logic::sendSyncInterest()
Name interestName;
interestName.append(m_syncPrefix)
.append(ndn::name::Component(*m_state.getRootDigest()));
.append(name::Component(*m_state.getRootDigest()));
m_pendingSyncInterestName = interestName;
@@ -688,7 +668,7 @@ Logic::encodeSyncReply(const Name& nodePrefix, const Name& name, const State& st
trimState(partialState, state, nExcludedStates);
finalizeReply(partialState);
BOOST_ASSERT(state.getLeaves().size() != 0);
BOOST_ASSERT(!state.getLeaves().empty());
nExcludedStates *= 2;
}
@@ -746,7 +726,7 @@ Logic::sendRecoveryInterest(ConstBufferPtr digest)
Name interestName;
interestName.append(m_syncPrefix)
.append(RECOVERY_COMPONENT)
.append(ndn::name::Component(*digest));
.append(name::Component(*digest));
Interest interest(interestName);
interest.setMustBeFresh(true);
@@ -771,7 +751,7 @@ Logic::processRecoveryInterest(const Interest& interest)
ConstBufferPtr rootDigest = m_state.getRootDigest();
auto stateIter = m_log.find(digest);
if (stateIter != m_log.end() || *digest == *EMPTY_DIGEST || *rootDigest == *digest) {
if (stateIter != m_log.end() || *digest == EMPTY_DIGEST || *rootDigest == *digest) {
CHRONO_LOG_DBG("I can help you recover");
sendSyncData(m_defaultUserPrefix, name, m_state);
return;
+17 -23
View File
@@ -70,7 +70,7 @@ public:
* The parameter is a set of MissingDataInfo, of which each corresponds to
* a session that has changed its state.
*/
using UpdateCallback = function<void(const std::vector<MissingDataInfo>&)>;
using UpdateCallback = std::function<void(const std::vector<MissingDataInfo>&)>;
/**
* @brief Logic of ChronoSync
@@ -84,12 +84,15 @@ public:
using std::runtime_error::runtime_error;
};
static const time::steady_clock::Duration DEFAULT_RESET_TIMER;
static const time::steady_clock::Duration DEFAULT_CANCEL_RESET_TIMER;
static const time::milliseconds DEFAULT_RESET_INTEREST_LIFETIME;
static const time::milliseconds DEFAULT_SYNC_INTEREST_LIFETIME;
static const time::milliseconds DEFAULT_SYNC_REPLY_FRESHNESS;
static const time::milliseconds DEFAULT_RECOVERY_INTEREST_LIFETIME;
static inline const Name EMPTY_NAME;
static inline const Name DEFAULT_NAME;
static inline const std::shared_ptr<Validator> DEFAULT_VALIDATOR;
static constexpr time::steady_clock::duration DEFAULT_RESET_TIMER = 0_ms;
static constexpr time::steady_clock::duration DEFAULT_CANCEL_RESET_TIMER = 500_ms;
static constexpr time::milliseconds DEFAULT_RESET_INTEREST_LIFETIME = 1_s;
static constexpr time::milliseconds DEFAULT_SYNC_INTEREST_LIFETIME = 1_s;
static constexpr time::milliseconds DEFAULT_SYNC_REPLY_FRESHNESS = 1_s;
static constexpr time::milliseconds DEFAULT_RECOVERY_INTEREST_LIFETIME = 1_s;
/**
* @brief Constructor
@@ -114,8 +117,8 @@ public:
const UpdateCallback& onUpdate,
const Name& defaultSigningId = DEFAULT_NAME,
std::shared_ptr<Validator> validator = DEFAULT_VALIDATOR,
const time::steady_clock::Duration& resetTimer = DEFAULT_RESET_TIMER,
const time::steady_clock::Duration& cancelResetTimer = DEFAULT_CANCEL_RESET_TIMER,
const time::steady_clock::duration& resetTimer = DEFAULT_RESET_TIMER,
const time::steady_clock::duration& cancelResetTimer = DEFAULT_CANCEL_RESET_TIMER,
const time::milliseconds& resetInterestLifetime = DEFAULT_RESET_INTEREST_LIFETIME,
const time::milliseconds& syncInterestLifetime = DEFAULT_SYNC_INTEREST_LIFETIME,
const time::milliseconds& syncReplyFreshness = DEFAULT_SYNC_REPLY_FRESHNESS,
@@ -442,17 +445,8 @@ private:
void
onRecoveryTimeout(const Interest& interest);
public:
static const ndn::Name DEFAULT_NAME;
static const ndn::Name EMPTY_NAME;
static const std::shared_ptr<Validator> DEFAULT_VALIDATOR;
private:
using NodeList = std::unordered_map<ndn::Name, NodeInfo>;
static const ConstBufferPtr EMPTY_DIGEST;
static const ndn::name::Component RESET_COMPONENT;
static const ndn::name::Component RECOVERY_COMPONENT;
using NodeList = std::unordered_map<Name, NodeInfo>;
// Communication
ndn::Face& m_face;
@@ -487,9 +481,9 @@ private:
std::uniform_int_distribution<> m_rangeUniformRandom;
std::uniform_int_distribution<> m_reexpressionJitter;
/// @brief Timer to send next reset 0 for no reset
time::steady_clock::Duration m_resetTimer;
time::steady_clock::duration m_resetTimer;
/// @brief Timer to cancel reset state
time::steady_clock::Duration m_cancelResetTimer;
time::steady_clock::duration m_cancelResetTimer;
/// @brief Lifetime of reset interest
time::milliseconds m_resetInterestLifetime;
/// @brief Lifetime of sync interest
@@ -503,8 +497,8 @@ private:
ndn::KeyChain m_keyChain;
std::shared_ptr<Validator> m_validator;
int m_instanceId;
static int s_instanceCounter;
const int m_instanceId;
static inline int s_instanceCounter = 0;
};
#ifdef CHRONOSYNC_WITH_TESTS
+3 -5
View File
@@ -30,10 +30,6 @@ NDN_LOG_INIT(sync.Socket);
namespace chronosync {
const ndn::Name Socket::DEFAULT_NAME;
const ndn::Name Socket::DEFAULT_PREFIX;
const std::shared_ptr<Validator> Socket::DEFAULT_VALIDATOR;
Socket::Socket(const Name& syncPrefix,
const Name& userPrefix,
ndn::Face& face,
@@ -49,14 +45,16 @@ Socket::Socket(const Name& syncPrefix,
syncInterestLifetime, Logic::DEFAULT_SYNC_REPLY_FRESHNESS, Logic::DEFAULT_RECOVERY_INTEREST_LIFETIME,
session)
, m_signingId(signingId)
, m_validator(validator)
, m_validator(std::move(validator))
{
NDN_LOG_DEBUG(">> Socket::Socket");
if (m_userPrefix != DEFAULT_NAME)
m_registeredPrefixList[m_userPrefix] =
m_face.setInterestFilter(m_userPrefix,
[this] (auto&&... args) { onInterest(std::forward<decltype(args)>(args)...); },
[] (auto&&...) {});
NDN_LOG_DEBUG("<< Socket::Socket");
}
+8 -13
View File
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2019 University of California, Los Angeles
* Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -52,11 +52,7 @@ public:
class Error : public std::runtime_error
{
public:
explicit
Error(const std::string& what)
: std::runtime_error(what)
{
}
using std::runtime_error::runtime_error;
};
Socket(const Name& syncPrefix,
@@ -70,9 +66,8 @@ public:
~Socket();
using DataValidatedCallback = function<void(const Data&)>;
using DataValidationErrorCallback = function<void(const Data&, const ValidationError& error)> ;
using DataValidatedCallback = std::function<void(const Data&)>;
using DataValidationErrorCallback = std::function<void(const Data&, const ValidationError& error)> ;
/**
* @brief Add a sync node under same logic
@@ -232,12 +227,12 @@ private:
const ValidationError& error);
public:
static const ndn::Name DEFAULT_NAME;
static const ndn::Name DEFAULT_PREFIX;
static const std::shared_ptr<Validator> DEFAULT_VALIDATOR;
static inline const Name DEFAULT_NAME;
static inline const Name DEFAULT_PREFIX;
static inline const std::shared_ptr<Validator> DEFAULT_VALIDATOR;
private:
using RegisteredPrefixList = std::unordered_map<ndn::Name, ndn::RegisteredPrefixHandle>;
using RegisteredPrefixList = std::unordered_map<Name, ndn::RegisteredPrefixHandle>;
Name m_userPrefix;
ndn::Face& m_face;
+4 -4
View File
@@ -40,16 +40,16 @@ State::update(const Name& info, const SeqNo& seq)
auto leaf = m_leaves.find(info);
if (leaf == m_leaves.end()) {
m_leaves.insert(make_shared<Leaf>(info, seq));
return std::make_tuple(true, false, 0);
return {true, false, 0};
}
else {
if ((*leaf)->getSeq() == seq || seq < (*leaf)->getSeq()) {
return std::make_tuple(false, false, 0);
return {false, false, 0};
}
SeqNo old = (*leaf)->getSeq();
m_leaves.modify(leaf, [seq] (LeafPtr& leaf) { leaf->setSeq(seq); } );
return std::make_tuple(false, true, old);
return {false, true, old};
}
}
@@ -128,7 +128,7 @@ State::wireDecode(const Block& wire)
NDN_THROW(Error("The supplied block does not contain wire format"));
if (wire.type() != tlv::SyncReply)
NDN_THROW(Error("Unexpected TLV type when decoding SyncReply: " + ndn::to_string(wire.type())));
NDN_THROW(Error("Unexpected TLV type when decoding SyncReply: " + std::to_string(wire.type())));
wire.parse();
m_wire = wire;
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2017 University of California, Los Angeles
* Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -22,8 +22,7 @@
#include <ndn-cxx/util/io.hpp>
#include <boost/filesystem.hpp>
namespace ndn {
namespace tests {
namespace ndn::tests {
IdentityManagementFixture::IdentityManagementFixture()
: m_keyChain("pib-memory:", "tpm-memory:")
@@ -75,5 +74,4 @@ IdentityManagementFixture::saveIdentityCertificate(const Name& identity, const s
}
}
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
+6 -8
View File
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2021 University of California, Los Angeles
* Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -17,15 +17,14 @@
* ChronoSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
#define NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
#ifndef CHRONOSYNC_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
#define CHRONOSYNC_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
#include "detail/common.hpp"
#include "unit-test-time-fixture.hpp"
namespace ndn {
namespace tests {
namespace ndn::tests {
/** \brief a fixture that cleans up KeyChain identities and certificate files upon destruction
*/
@@ -69,7 +68,6 @@ class IdentityManagementTimeFixture : public UnitTestTimeFixture
{
};
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
#endif // NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
#endif // CHRONOSYNC_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
+6 -8
View File
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2017 University of California, Los Angeles
* Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -17,15 +17,14 @@
* ChronoSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NDN_TESTS_UNIT_TESTS_UNIT_TEST_TIME_FIXTURE_HPP
#define NDN_TESTS_UNIT_TESTS_UNIT_TEST_TIME_FIXTURE_HPP
#ifndef CHRONOSYNC_TESTS_UNIT_TEST_TIME_FIXTURE_HPP
#define CHRONOSYNC_TESTS_UNIT_TEST_TIME_FIXTURE_HPP
#include <ndn-cxx/util/time-unit-test-clock.hpp>
#include <boost/asio.hpp>
namespace ndn {
namespace tests {
namespace ndn::tests {
class UnitTestTimeFixture
{
@@ -61,7 +60,6 @@ public:
boost::asio::io_service io;
};
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
#endif // NDN_TESTS_UNIT_TESTS_UNIT_TEST_TIME_FIXTURE_HPP
#endif // CHRONOSYNC_TESTS_UNIT_TEST_TIME_FIXTURE_HPP
+3 -3
View File
@@ -432,12 +432,12 @@ public:
{
unsetenv("CHRONOSYNC_MAX_PACKET_SIZE");
if (oldSize) {
setenv("CHRONOSYNC_MAX_PACKET_SIZE", oldSize->c_str(), 1);
setenv("CHRONOSYNC_MAX_PACKET_SIZE", oldSize->data(), 1);
}
}
private:
ndn::optional<std::string> oldSize;
std::optional<std::string> oldSize;
};
BOOST_FIXTURE_TEST_CASE(MaxPacketCustomization, MaxPacketCustomizationFixture)
@@ -447,7 +447,7 @@ BOOST_FIXTURE_TEST_CASE(MaxPacketCustomization, MaxPacketCustomizationFixture)
setenv("CHRONOSYNC_MAX_PACKET_SIZE", "1500", 1);
BOOST_CHECK_EQUAL(getMaxPacketLimit(), 1500);
setenv("CHRONOSYNC_MAX_PACKET_SIZE", ndn::to_string(ndn::MAX_NDN_PACKET_SIZE * 100).c_str(), 1);
setenv("CHRONOSYNC_MAX_PACKET_SIZE", std::to_string(ndn::MAX_NDN_PACKET_SIZE * 100).data(), 1);
BOOST_CHECK_EQUAL(getMaxPacketLimit(), ndn::MAX_NDN_PACKET_SIZE);
setenv("CHRONOSYNC_MAX_PACKET_SIZE", "1", 1);
+5 -15
View File
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2019 University of California, Los Angeles
* Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -27,18 +27,8 @@ namespace test {
class Handler
{
public:
Handler(ndn::Face& face,
const Name& syncPrefix,
const Name& userPrefix)
: logic(face,
syncPrefix,
userPrefix,
bind(&Handler::onUpdate, this, _1))
{
}
void
onUpdate(const std::vector<MissingDataInfo>& v)
Handler(ndn::Face& face, const Name& syncPrefix, const Name& userPrefix)
: logic(face, syncPrefix, userPrefix, [] (auto&&...) {})
{
}
@@ -76,7 +66,7 @@ public:
userPrefix[1] = Name("/user1");
userPrefix[2] = Name("/user2");
face = make_shared<ndn::Face>(ref(io));
face = std::make_shared<ndn::Face>(io);
}
Name syncPrefix;
@@ -92,7 +82,7 @@ BOOST_FIXTURE_TEST_SUITE(MultiUserTests, MultiUserFixture)
BOOST_AUTO_TEST_CASE(ThreeUserNode)
{
handler = make_shared<Handler>(ref(*face), syncPrefix, userPrefix[0]);
handler = std::make_shared<Handler>(*face, syncPrefix, userPrefix[0]);
handler->addUserNode(userPrefix[1]);
handler->addUserNode(userPrefix[2]);
handler->removeUserNode(userPrefix[0]);
+6 -6
View File
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2019 University of California, Los Angeles
* Copyright (c) 2012-2022 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -48,7 +48,7 @@ public:
userPrefix,
face,
isNum ? bind(&SocketTestApp::fetchNumbers, this, _1) :
bind(&SocketTestApp::fetchAll, this, _1),
bind(&SocketTestApp::fetchAll, this, _1),
Logic::DEFAULT_NAME,
Logic::DEFAULT_VALIDATOR,
Logic::DEFAULT_SYNC_INTEREST_LIFETIME,
@@ -63,14 +63,14 @@ public:
Name dataName(dataPacket.getName());
string str2(reinterpret_cast<const char*>(dataPacket.getContent().value()),
dataPacket.getContent().value_size());
data.insert(make_pair(dataName, str2));
data.emplace(dataName, str2);
}
void
set(Name name, const char* buf, int len)
{
string str2(buf, len);
data.insert(make_pair(name, str2));
data.emplace(name, str2);
}
void
@@ -139,7 +139,7 @@ public:
}
public:
std::map<ndn::Name, string> data;
std::map<Name, string> data;
uint32_t sum;
Socket socket;
};
@@ -194,7 +194,7 @@ public:
void
createSocket(size_t idx, bool isNum)
{
app[idx] = make_shared<SocketTestApp>(syncPrefix, userPrefix[idx], ref(*faces[idx]), isNum);
app[idx] = make_shared<SocketTestApp>(syncPrefix, userPrefix[idx], std::ref(*faces[idx]), isNum);
sessionName[idx] = app[idx]->socket.getLogic().getSessionName();
}