mgmt: StrategyChoice equality operators and formatted output
refs #3903
Change-Id: I458e80959b5a3ecdc1d0e55ec2ac361772a60e70
diff --git a/src/mgmt/nfd/strategy-choice.cpp b/src/mgmt/nfd/strategy-choice.cpp
index 2e294d7..3643be6 100644
--- a/src/mgmt/nfd/strategy-choice.cpp
+++ b/src/mgmt/nfd/strategy-choice.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -27,15 +27,14 @@
namespace ndn {
namespace nfd {
-//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<StrategyChoice>));
+BOOST_CONCEPT_ASSERT((boost::EqualityComparable<StrategyChoice>));
BOOST_CONCEPT_ASSERT((WireEncodable<StrategyChoice>));
+BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<StrategyChoice>));
BOOST_CONCEPT_ASSERT((WireDecodable<StrategyChoice>));
static_assert(std::is_base_of<tlv::Error, StrategyChoice::Error>::value,
"StrategyChoice::Error must inherit from tlv::Error");
-StrategyChoice::StrategyChoice()
-{
-}
+StrategyChoice::StrategyChoice() = default;
StrategyChoice::StrategyChoice(const Block& payload)
{
@@ -127,5 +126,20 @@
return *this;
}
+bool
+operator==(const StrategyChoice& a, const StrategyChoice& b)
+{
+ return a.getName() == b.getName() && a.getStrategy() == b.getStrategy();
+}
+
+std::ostream&
+operator<<(std::ostream& os, const StrategyChoice& sc)
+{
+ return os << "StrategyChoice("
+ << "Name: " << sc.getName() << ", "
+ << "Strategy: " << sc.getStrategy()
+ << ")";
+}
+
} // namespace nfd
} // namespace ndn
diff --git a/src/mgmt/nfd/strategy-choice.hpp b/src/mgmt/nfd/strategy-choice.hpp
index 8cdaa59..ec46348 100644
--- a/src/mgmt/nfd/strategy-choice.hpp
+++ b/src/mgmt/nfd/strategy-choice.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -87,6 +87,18 @@
mutable Block m_wire;
};
+bool
+operator==(const StrategyChoice& a, const StrategyChoice& b);
+
+inline bool
+operator!=(const StrategyChoice& a, const StrategyChoice& b)
+{
+ return !(a == b);
+}
+
+std::ostream&
+operator<<(std::ostream& os, const StrategyChoice& sc);
+
} // namespace nfd
} // namespace ndn