mgmt: ForwarderStatus equality operators and formatted output
Change-Id: I6d814ef427a9db38ef46427888f3b3ba982bf641
Refs: #3903
diff --git a/src/mgmt/nfd/channel-status.cpp b/src/mgmt/nfd/channel-status.cpp
index c2a9b63..f3a7e2b 100644
--- a/src/mgmt/nfd/channel-status.cpp
+++ b/src/mgmt/nfd/channel-status.cpp
@@ -106,9 +106,9 @@
}
std::ostream&
-operator<<(std::ostream& os, const ChannelStatus& cs)
+operator<<(std::ostream& os, const ChannelStatus& status)
{
- return os << "Channel(" << "LocalUri: " << cs.getLocalUri() << ")";
+ return os << "Channel(LocalUri: " << status.getLocalUri() << ")";
}
} // namespace nfd
diff --git a/src/mgmt/nfd/channel-status.hpp b/src/mgmt/nfd/channel-status.hpp
index 16eb419..04b3ed6 100644
--- a/src/mgmt/nfd/channel-status.hpp
+++ b/src/mgmt/nfd/channel-status.hpp
@@ -28,9 +28,9 @@
namespace nfd {
/**
- * @ingroup management
- * @brief represents NFD Channel Status dataset
- * @sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset
+ * \ingroup management
+ * \brief represents an item in NFD Channel dataset
+ * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset
*/
class ChannelStatus
{
@@ -86,7 +86,7 @@
}
std::ostream&
-operator<<(std::ostream& os, const ChannelStatus& cs);
+operator<<(std::ostream& os, const ChannelStatus& status);
} // namespace nfd
} // namespace ndn
diff --git a/src/mgmt/nfd/forwarder-status.cpp b/src/mgmt/nfd/forwarder-status.cpp
index 21fee56..fbb6c73 100644
--- a/src/mgmt/nfd/forwarder-status.cpp
+++ b/src/mgmt/nfd/forwarder-status.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).
*
@@ -20,23 +20,18 @@
*/
#include "forwarder-status.hpp"
-#include "encoding/tlv-nfd.hpp"
#include "encoding/block-helpers.hpp"
+#include "encoding/encoding-buffer.hpp"
+#include "encoding/tlv-nfd.hpp"
#include "util/concepts.hpp"
namespace ndn {
namespace nfd {
-//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<ForwarderStatus>));
-BOOST_CONCEPT_ASSERT((WireEncodable<ForwarderStatus>));
-BOOST_CONCEPT_ASSERT((WireDecodable<ForwarderStatus>));
-static_assert(std::is_base_of<tlv::Error, ForwarderStatus::Error>::value,
- "ForwarderStatus::Error must inherit from tlv::Error");
+BOOST_CONCEPT_ASSERT((StatusDatasetItem<ForwarderStatus>));
ForwarderStatus::ForwarderStatus()
- : m_startTimestamp(time::system_clock::TimePoint::min())
- , m_currentTimestamp(time::system_clock::TimePoint::min())
- , m_nNameTreeEntries(0)
+ : m_nNameTreeEntries(0)
, m_nFibEntries(0)
, m_nPitEntries(0)
, m_nMeasurementsEntries(0)
@@ -88,8 +83,8 @@
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::StartTimestamp,
time::toUnixTimestamp(m_startTimestamp).count());
totalLength += encoder.prependByteArrayBlock(tlv::nfd::NfdVersion,
- reinterpret_cast<const uint8_t*>(m_nfdVersion.c_str()),
- m_nfdVersion.size());
+ reinterpret_cast<const uint8_t*>(m_nfdVersion.data()),
+ m_nfdVersion.size());
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(tlv::Content);
@@ -353,5 +348,46 @@
return *this;
}
+bool
+operator==(const ForwarderStatus& a, const ForwarderStatus& b)
+{
+ return a.getNfdVersion() == b.getNfdVersion() &&
+ a.getStartTimestamp() == b.getStartTimestamp() &&
+ a.getCurrentTimestamp() == b.getCurrentTimestamp() &&
+ a.getNNameTreeEntries() == b.getNNameTreeEntries() &&
+ a.getNFibEntries() == b.getNFibEntries() &&
+ a.getNPitEntries() == b.getNPitEntries() &&
+ a.getNMeasurementsEntries() == b.getNMeasurementsEntries() &&
+ a.getNCsEntries() == b.getNCsEntries() &&
+ a.getNInInterests() == b.getNInInterests() &&
+ a.getNInDatas() == b.getNInDatas() &&
+ a.getNInNacks() == b.getNInNacks() &&
+ a.getNOutInterests() == b.getNOutInterests() &&
+ a.getNOutDatas() == b.getNOutDatas() &&
+ a.getNOutNacks() == b.getNOutNacks();
+}
+
+std::ostream&
+operator<<(std::ostream& os, const ForwarderStatus& status)
+{
+ os << "GeneralStatus(NfdVersion: " << status.getNfdVersion() << ",\n"
+ << " StartTimestamp: " << status.getStartTimestamp() << ",\n"
+ << " CurrentTimestamp: " << status.getCurrentTimestamp() << ",\n"
+ << " Counters: {NameTreeEntries: " << status.getNNameTreeEntries() << ",\n"
+ << " FibEntries: " << status.getNFibEntries() << ",\n"
+ << " PitEntries: " << status.getNPitEntries() << ",\n"
+ << " MeasurementsEntries: " << status.getNMeasurementsEntries() << ",\n"
+ << " CsEntries: " << status.getNCsEntries() << ",\n"
+ << " Interests: {in: " << status.getNInInterests() << ", "
+ << "out: " << status.getNOutInterests() << "},\n"
+ << " Data: {in: " << status.getNInDatas() << ", "
+ << "out: " << status.getNOutDatas() << "},\n"
+ << " Nacks: {in: " << status.getNInNacks() << ", "
+ << "out: " << status.getNOutNacks() << "}}\n"
+ << " )";
+
+ return os;
+}
+
} // namespace nfd
} // namespace ndn
diff --git a/src/mgmt/nfd/forwarder-status.hpp b/src/mgmt/nfd/forwarder-status.hpp
index 4601610..7e1b35c 100644
--- a/src/mgmt/nfd/forwarder-status.hpp
+++ b/src/mgmt/nfd/forwarder-status.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).
*
@@ -30,8 +30,8 @@
/**
* \ingroup management
- * \brief represents NFD Forwarder Status
- * \sa http://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus
+ * \brief represents NFD General Status dataset
+ * \sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset
*/
class ForwarderStatus
{
@@ -53,7 +53,7 @@
/** \brief prepend ForwarderStatus as a Content block to the encoder
*
- * The outermost Content element isn't part of ForwardStatus structure.
+ * The outermost Content element isn't part of ForwarderStatus structure.
*/
template<encoding::Tag TAG>
size_t
@@ -61,14 +61,14 @@
/** \brief encode ForwarderStatus as a Content block
*
- * The outermost Content element isn't part of ForwardStatus structure.
+ * The outermost Content element isn't part of ForwarderStatus structure.
*/
const Block&
wireEncode() const;
/** \brief decode ForwarderStatus from a Content block
*
- * The outermost Content element isn't part of ForwardStatus structure.
+ * The outermost Content element isn't part of ForwarderStatus structure.
*/
void
wireDecode(const Block& wire);
@@ -219,6 +219,18 @@
mutable Block m_wire;
};
+bool
+operator==(const ForwarderStatus& a, const ForwarderStatus& b);
+
+inline bool
+operator!=(const ForwarderStatus& a, const ForwarderStatus& b)
+{
+ return !(a == b);
+}
+
+std::ostream&
+operator<<(std::ostream& os, const ForwarderStatus& status);
+
} // namespace nfd
} // namespace ndn
diff --git a/src/mgmt/nfd/strategy-choice.hpp b/src/mgmt/nfd/strategy-choice.hpp
index ec46348..ba840f0 100644
--- a/src/mgmt/nfd/strategy-choice.hpp
+++ b/src/mgmt/nfd/strategy-choice.hpp
@@ -29,9 +29,9 @@
namespace nfd {
/**
- * @ingroup management
- * @brief represents NFD StrategyChoice dataset
- * @sa http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy-Choice-Dataset
+ * \ingroup management
+ * \brief represents an item in NFD StrategyChoice dataset
+ * \sa https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy-Choice-Dataset
*/
class StrategyChoice
{