peek: drop Selectors support
refs #4571
Change-Id: Iac6d07864746b0decfed6cb9dc3518b4999f83e3
diff --git a/tools/peek/ndnpeek/main.cpp b/tools/peek/ndnpeek/main.cpp
index 774d759..f04cec4 100644
--- a/tools/peek/ndnpeek/main.cpp
+++ b/tools/peek/ndnpeek/main.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-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -50,14 +50,6 @@
main(int argc, char* argv[])
{
PeekOptions options;
- options.isVerbose = false;
- options.mustBeFresh = false;
- options.wantRightmostChild = false;
- options.wantPayloadOnly = false;
- options.minSuffixComponents = -1;
- options.maxSuffixComponents = -1;
- options.interestLifetime = time::milliseconds(-1);
- options.timeout = time::milliseconds(-1);
po::options_description genericOptDesc("Generic options");
genericOptDesc.add_options()
@@ -73,18 +65,14 @@
po::options_description interestOptDesc("Interest construction");
interestOptDesc.add_options()
+ ("prefix,P", po::bool_switch(&options.canBePrefix),
+ "set CanBePrefix")
("fresh,f", po::bool_switch(&options.mustBeFresh),
"set MustBeFresh")
- ("rightmost,r", po::bool_switch(&options.wantRightmostChild),
- "set ChildSelector to rightmost")
- ("minsuffix,m", po::value<int>(&options.minSuffixComponents),
- "set MinSuffixComponents")
- ("maxsuffix,M", po::value<int>(&options.maxSuffixComponents),
- "set MaxSuffixComponents")
+ ("link-file", po::value<std::string>(),
+ "set ForwardingHint from a file")
("lifetime,l", po::value<int>(),
"set InterestLifetime (in milliseconds)")
- ("link-file", po::value<std::string>(),
- "set Link from a file")
;
po::options_description visibleOptDesc;
@@ -92,13 +80,13 @@
po::options_description hiddenOptDesc;
hiddenOptDesc.add_options()
- ("prefix", po::value<std::string>(), "Interest name");
+ ("name", po::value<std::string>(), "Interest name");
po::options_description optDesc;
optDesc.add(visibleOptDesc).add(hiddenOptDesc);
po::positional_options_description optPos;
- optPos.add("prefix", -1);
+ optPos.add("name", -1);
po::variables_map vm;
try {
@@ -120,8 +108,8 @@
return 0;
}
- if (vm.count("prefix") > 0) {
- options.prefix = vm["prefix"].as<std::string>();
+ if (vm.count("name") > 0) {
+ options.name = vm["name"].as<std::string>();
}
else {
std::cerr << "ERROR: Interest name is missing" << std::endl;
@@ -129,18 +117,6 @@
return 2;
}
- if (vm.count("minsuffix") > 0 && options.minSuffixComponents < 0) {
- std::cerr << "ERROR: MinSuffixComponents must be a non-negative integer" << std::endl;
- usage(std::cerr, visibleOptDesc);
- return 2;
- }
-
- if (vm.count("maxsuffix") > 0 && options.maxSuffixComponents < 0) {
- std::cerr << "ERROR: MaxSuffixComponents must be a non-negative integer" << std::endl;
- usage(std::cerr, visibleOptDesc);
- return 2;
- }
-
if (vm.count("lifetime") > 0) {
if (vm["lifetime"].as<int>() >= 0) {
options.interestLifetime = time::milliseconds(vm["lifetime"].as<int>());
diff --git a/tools/peek/ndnpeek/ndnpeek.cpp b/tools/peek/ndnpeek/ndnpeek.cpp
index 372a419..23833f1 100644
--- a/tools/peek/ndnpeek/ndnpeek.cpp
+++ b/tools/peek/ndnpeek/ndnpeek.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,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -37,8 +37,8 @@
, m_timeout(options.timeout)
, m_resultCode(ResultCode::TIMEOUT)
{
- if (m_timeout < time::milliseconds::zero()) {
- m_timeout = m_options.interestLifetime < time::milliseconds::zero() ?
+ if (m_timeout < 0_ms) {
+ m_timeout = m_options.interestLifetime < 0_ms ?
DEFAULT_INTEREST_LIFETIME : m_options.interestLifetime;
}
}
@@ -68,25 +68,15 @@
Interest
NdnPeek::createInterest() const
{
- Interest interest(m_options.prefix);
-
- if (m_options.minSuffixComponents >= 0)
- interest.setMinSuffixComponents(m_options.minSuffixComponents);
-
- if (m_options.maxSuffixComponents >= 0)
- interest.setMaxSuffixComponents(m_options.maxSuffixComponents);
-
- if (m_options.interestLifetime >= time::milliseconds::zero())
- interest.setInterestLifetime(m_options.interestLifetime);
-
- if (m_options.link != nullptr)
+ Interest interest(m_options.name);
+ interest.setCanBePrefix(m_options.canBePrefix);
+ interest.setMustBeFresh(m_options.mustBeFresh);
+ if (m_options.link != nullptr) {
interest.setForwardingHint(m_options.link->getDelegationList());
-
- if (m_options.mustBeFresh)
- interest.setMustBeFresh(true);
-
- if (m_options.wantRightmostChild)
- interest.setChildSelector(1);
+ }
+ if (m_options.interestLifetime >= 0_ms) {
+ interest.setInterestLifetime(m_options.interestLifetime);
+ }
if (m_options.isVerbose) {
std::cerr << "INTEREST: " << interest << std::endl;
diff --git a/tools/peek/ndnpeek/ndnpeek.hpp b/tools/peek/ndnpeek/ndnpeek.hpp
index c8c58b9..4eac8d3 100644
--- a/tools/peek/ndnpeek/ndnpeek.hpp
+++ b/tools/peek/ndnpeek/ndnpeek.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,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -40,16 +40,17 @@
*/
struct PeekOptions
{
- std::string prefix;
- int minSuffixComponents;
- int maxSuffixComponents;
- time::milliseconds interestLifetime;
- time::milliseconds timeout;
+ // Interest construction options
+ std::string name;
+ bool canBePrefix = false;
+ bool mustBeFresh = false;
shared_ptr<Link> link;
- bool isVerbose;
- bool mustBeFresh;
- bool wantRightmostChild;
- bool wantPayloadOnly;
+ time::milliseconds interestLifetime = -1_ms;
+
+ // output behavior options
+ bool isVerbose = false;
+ time::milliseconds timeout = -1_ms;
+ bool wantPayloadOnly = false;
};
enum class ResultCode {