Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1190406

Browse files
committed
Migrate to C++17 and misc code cleanups
Change-Id: I6b63385c92361a7ef5803d2bfd00f39c77e88d34
1 parent9c0bd8d commit1190406

File tree

38 files changed

+303
-549
lines changed

38 files changed

+303
-549
lines changed

‎.waf-tools/default-compiler-flags.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class GccBasicFlags(CompilerFlags):
136136
"""
137137
defgetGeneralFlags(self,conf):
138138
flags=super(GccBasicFlags,self).getGeneralFlags(conf)
139-
flags['CXXFLAGS']+= ['-std=c++14']
139+
flags['CXXFLAGS']+= ['-std=c++17']
140140
ifUtils.unversioned_sys_platform()=='linux':
141141
flags['LINKFLAGS']+= ['-fuse-ld=gold']
142142
elifUtils.unversioned_sys_platform()=='freebsd':

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#repo-ng: Next generation NDN repository
22

33
[![CI](https://github.com/named-data/repo-ng/actions/workflows/ci.yml/badge.svg)](https://github.com/named-data/repo-ng/actions/workflows/ci.yml)
4-
![Language](https://img.shields.io/badge/C%2B%2B-14-blue)
4+
![Language](https://img.shields.io/badge/C%2B%2B-17-blue)
55

66
**repo-ng** is an implementation of a Named Data Networking (NDN) data repository,
77
and follows the[Repo protocol](https://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification).
88

99
repo-ng uses[ndn-cxx](https://github.com/named-data/ndn-cxx) as the NDN development
10-
library, and[sqlite](https://www.sqlite.org/) as the underlying storage engine.
10+
library and[sqlite](https://www.sqlite.org/) as the underlying storage engine.
1111

1212
##Installation
1313

‎src/common.hpp‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-*/
22
/*
3-
* Copyright (c) 2014-2020, Regents of the University of California.
3+
* Copyright (c) 2014-2022, Regents of the University of California.
44
*
55
* This file is part of NDN repo-ng (Next generation of NDN repository).
66
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -25,22 +25,19 @@
2525
#include<ndn-cxx/data.hpp>
2626
#include<ndn-cxx/face.hpp>
2727
#include<ndn-cxx/interest.hpp>
28-
#include<ndn-cxx/key-locator.hpp>
2928
#include<ndn-cxx/name.hpp>
30-
#include<ndn-cxx/security/key-chain.hpp>
31-
#include<ndn-cxx/security/validator.hpp>
32-
#include<ndn-cxx/security/validator-config.hpp>
33-
#include<ndn-cxx/util/time.hpp>
3429
#include<ndn-cxx/util/scheduler.hpp>
30+
#include<ndn-cxx/util/time.hpp>
3531

36-
#include<boost/utility.hpp>
32+
#include<boost/core/noncopyable.hpp>
3733

3834
#include<algorithm>
3935
#include<functional>
40-
#include<iostream>
36+
#include<iosfwd>
4137
#include<list>
4238
#include<map>
4339
#include<memory>
40+
#include<stdexcept>
4441
#include<string>
4542
#include<vector>
4643

@@ -52,24 +49,21 @@
5249

5350
namespacerepo {
5451

52+
using boost::noncopyable;
53+
5554
using ndn::Face;
5655
using ndn::Block;
57-
using ndn::operator""_block;
5856
using ndn::Name;
59-
namespacename= ndn::name;
6057
using ndn::Interest;
6158
using ndn::Data;
62-
using ndn::KeyLocator;
6359
using ndn::Scheduler;
64-
using ndn::security::KeyChain;
65-
using ndn::security::Validator;
66-
using ndn::security::ValidationError;
67-
using ndn::security::ValidatorConfig;
6860

69-
using boost::noncopyable;
61+
using ndn::operator""_block;
62+
namespacetime= ndn::time;
63+
usingnamespacendn::time_literals;
7064

71-
typedefuint64_tProcessId;
72-
typedefuint64_tSegmentNo;
65+
usingProcessId =uint64_t;
66+
usingSegmentNo =uint64_t;
7367

7468
}// namespace repo
7569

‎src/handles/command-base-handle.cpp‎

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-*/
22
/*
3-
* Copyright (c) 2014-2020, Regents of the University of California.
3+
* Copyright (c) 2014-2022, Regents of the University of California.
44
*
55
* This file is part of NDN repo-ng (Next generation of NDN repository).
66
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -19,7 +19,7 @@
1919

2020
#include"command-base-handle.hpp"
2121

22-
#include<ndn-cxx/util/random.hpp>
22+
#include<optional>
2323

2424
namespacerepo {
2525

@@ -29,43 +29,40 @@ using SignerTag = ndn::SimpleTag<ndn::Name, 20>;
2929

3030
/** \brief obtain signer from SignerTag attached to Interest, if available
3131
*/
32-
staticndn::optional<std::string>
32+
staticstd::optional<std::string>
3333
getSignerFromTag(const ndn::Interest& interest)
3434
{
35-
std::shared_ptr<SignerTag> signerTag = interest.getTag<SignerTag>();
35+
auto signerTag = interest.getTag<SignerTag>();
3636
if (signerTag ==nullptr) {
37-
returnndn::nullopt;
37+
returnstd::nullopt;
3838
}
3939
else {
4040
return signerTag->get().toUri();
4141
}
4242
}
4343

44-
CommandBaseHandle::CommandBaseHandle(Face& face, RepoStorage&storageHandle,
45-
Scheduler&scheduler,Validator& validator)
44+
CommandBaseHandle::CommandBaseHandle(Face& face, RepoStorage&storage,
45+
Scheduler&sched, ndn::security::Validator& validator)
4646
: face(face)
47-
, storageHandle(storageHandle)
48-
, scheduler(scheduler)
47+
, storageHandle(storage)
48+
, scheduler(sched)
4949
, m_validator(validator)
5050
{
5151
}
5252

5353
ndn::mgmt::Authorization
5454
CommandBaseHandle::makeAuthorization()
5555
{
56-
return [=] (const ndn::Name& prefix,constndn::Interest& interest,
57-
const ndn::mgmt::ControlParameters* params,
58-
const ndn::mgmt::AcceptContinuation& accept,
59-
const ndn::mgmt::RejectContinuation& reject) {
56+
return [=] (const ndn::Name&,constauto& interest,
57+
const ndn::mgmt::ControlParameters*,
58+
const ndn::mgmt::AcceptContinuation& accept,
59+
const ndn::mgmt::RejectContinuation& reject) {
6060
m_validator.validate(interest,
61-
[accept] (const ndn::Interest& request) {
62-
63-
auto signer1 =getSignerFromTag(request);
64-
std::string signer = signer1.value_or("*");
61+
[accept] (constauto& request) {
62+
auto signer =getSignerFromTag(request).value_or("*");
6563
accept(signer);
6664
},
67-
[reject] (const ndn::Interest& request,
68-
const ndn::security::ValidationError& error) {
65+
[reject] (auto&&...) {
6966
reject(ndn::mgmt::RejectReply::STATUS403);
7067
});
7168
};

‎src/handles/command-base-handle.hpp‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-*/
22
/*
3-
* Copyright (c) 2014-2018, Regents of the University of California.
3+
* Copyright (c) 2014-2022, Regents of the University of California.
44
*
55
* This file is part of NDN repo-ng (Next generation of NDN repository).
66
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -28,6 +28,7 @@
2828
#include"repo-command.hpp"
2929

3030
#include<ndn-cxx/mgmt/dispatcher.hpp>
31+
#include<ndn-cxx/security/validator.hpp>
3132

3233
namespacerepo {
3334

@@ -37,16 +38,12 @@ class CommandBaseHandle
3738
classError :publicstd::runtime_error
3839
{
3940
public:
40-
explicit
41-
Error(const std::string& what)
42-
: std::runtime_error(what)
43-
{
44-
}
41+
using std::runtime_error::runtime_error;
4542
};
4643

4744
public:
4845
CommandBaseHandle(Face& face, RepoStorage& storageHandle,
49-
Scheduler& scheduler, Validator& validator);
46+
Scheduler& scheduler,ndn::security::Validator& validator);
5047

5148
virtual
5249
~CommandBaseHandle() =default;
@@ -58,14 +55,14 @@ class CommandBaseHandle
5855
bool
5956
validateParameters(const ndn::mgmt::ControlParameters& parameters)
6057
{
61-
const RepoCommandParameter* castParams =
62-
dynamic_cast<const RepoCommandParameter*>(&parameters);
58+
constauto* castParams =dynamic_cast<const RepoCommandParameter*>(&parameters);
6359
BOOST_ASSERT(castParams !=nullptr);
60+
6461
T command;
6562
try {
6663
command.validateRequest(*castParams);
6764
}
68-
catch (const RepoCommand::ArgumentError& ae) {
65+
catch (const RepoCommand::ArgumentError&) {
6966
returnfalse;
7067
}
7168
returntrue;
@@ -77,8 +74,9 @@ class CommandBaseHandle
7774
Scheduler& scheduler;
7875

7976
private:
80-
Validator& m_validator;
77+
ndn::security::Validator& m_validator;
8178
};
79+
8280
}// namespace repo
8381

84-
#endif// REPO_HANDLES_COMMAND_BASE_HANDLE_HPP
82+
#endif// REPO_HANDLES_COMMAND_BASE_HANDLE_HPP

‎src/handles/delete-handle.cpp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-*/
22
/*
3-
* Copyright (c) 2014-2018, Regents of the University of California.
3+
* Copyright (c) 2014-2022, Regents of the University of California.
44
*
55
* This file is part of NDN repo-ng (Next generation of NDN repository).
66
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -27,7 +27,7 @@ NDN_LOG_INIT(repo.DeleteHandle);
2727

2828
DeleteHandle::DeleteHandle(Face& face, RepoStorage& storageHandle,
2929
ndn::mgmt::Dispatcher& dispatcher, Scheduler& scheduler,
30-
Validator& validator)
30+
ndn::security::Validator& validator)
3131
: CommandBaseHandle(face, storageHandle, scheduler, validator)
3232
{
3333
dispatcher.addControlCommand<RepoCommandParameter>(ndn::PartialName("delete"),
@@ -72,7 +72,8 @@ DeleteHandle::positiveReply(const Interest& interest, const RepoCommandParameter
7272
}
7373

7474
RepoCommandResponse
75-
DeleteHandle::negativeReply(const Interest& interest,uint64_t statusCode, std::string text)const
75+
DeleteHandle::negativeReply(const Interest& interest,uint64_t statusCode,
76+
const std::string& text)const
7677
{
7778
RepoCommandResponseresponse(statusCode, text);
7879
response.setBody(response.wireEncode());
@@ -108,9 +109,9 @@ DeleteHandle::processSegmentDeleteCommand(const Interest& interest, const RepoCo
108109
nDeletedData++;
109110
}
110111
}
112+
111113
//All the data deleted, return 200
112114
done(positiveReply(interest, parameter,200, nDeletedData));
113-
114115
}
115116

116117
}// namespace repo

‎src/handles/delete-handle.hpp‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-*/
22
/*
3-
* Copyright (c) 2014-2018, Regents of the University of California.
3+
* Copyright (c) 2014-2022, Regents of the University of California.
44
*
55
* This file is part of NDN repo-ng (Next generation of NDN repository).
66
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -22,27 +22,20 @@
2222

2323
#include"command-base-handle.hpp"
2424

25-
#include<ndn-cxx/mgmt/dispatcher.hpp>
26-
2725
namespacerepo {
2826

2927
classDeleteHandle :publicCommandBaseHandle
3028
{
31-
3229
public:
3330
classError :publicCommandBaseHandle::Error
3431
{
3532
public:
36-
explicit
37-
Error(const std::string& what)
38-
: CommandBaseHandle::Error(what)
39-
{
40-
}
33+
using CommandBaseHandle::Error::Error;
4134
};
4235

43-
public:
4436
DeleteHandle(Face& face, RepoStorage& storageHandle,
45-
ndn::mgmt::Dispatcher& dispatcher, Scheduler& scheduler, Validator& validator);
37+
ndn::mgmt::Dispatcher& dispatcher, Scheduler& scheduler,
38+
ndn::security::Validator& validator);
4639

4740
private:
4841
void
@@ -55,7 +48,7 @@ class DeleteHandle : public CommandBaseHandle
5548
uint64_t statusCode,uint64_t nDeletedData)const;
5649

5750
RepoCommandResponse
58-
negativeReply(const Interest& interest,uint64_t statusCode,const std::string text)const;
51+
negativeReply(const Interest& interest,uint64_t statusCode,const std::string& text)const;
5952

6053
void
6154
processSingleDeleteCommand(const Interest& interest,const RepoCommandParameter& parameter,

‎src/handles/tcp-bulk-insert-handle.hpp‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-*/
22
/*
3-
* Copyright (c) 2014-2019, Regents of the University of California.
3+
* Copyright (c) 2014-2022, Regents of the University of California.
44
*
55
* This file is part of NDN repo-ng (Next generation of NDN repository).
66
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -33,11 +33,7 @@ class TcpBulkInsertHandle : noncopyable
3333
classError :publicstd::runtime_error
3434
{
3535
public:
36-
explicit
37-
Error(const std::string& what)
38-
: std::runtime_error(what)
39-
{
40-
}
36+
using std::runtime_error::runtime_error;
4137
};
4238

4339
public:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp