management: ensure Element::Error inherits from tlv::Error
Add static asserts to ensure ndn::nfd::*::Error are subclasses of tlv::Error.
Add WireEncodable and WireDecodable concept checks to
ndn::nfd::* classes that represent TLV abstraction.
Move definition of ChannelStatus, FibEntry, ForwarderStatus,
StrategyChoice methods into .cpp.
Move declaration of FaceScope, FacePersistency, LinkType
into encoding/nfd-constants.hpp.
Eliminate duplicate RibFlags declaration.
refs #1983
Change-Id: I207bae479aa6da54a581a7cca5b2a13743827ff0
diff --git a/src/management/nfd-channel-status.hpp b/src/management/nfd-channel-status.hpp
index 78a2066..4bb2707 100644
--- a/src/management/nfd-channel-status.hpp
+++ b/src/management/nfd-channel-status.hpp
@@ -22,11 +22,7 @@
#ifndef NDN_MANAGEMENT_NFD_CHANNEL_STATUS_HPP
#define NDN_MANAGEMENT_NFD_CHANNEL_STATUS_HPP
-#include "../encoding/tlv-nfd.hpp"
-#include "../encoding/encoding-buffer.hpp"
-#include "../encoding/block-helpers.hpp"
-
-#include "../util/time.hpp"
+#include "../encoding/block.hpp"
namespace ndn {
namespace nfd {
@@ -49,15 +45,10 @@
}
};
- ChannelStatus()
- {
- }
+ ChannelStatus();
explicit
- ChannelStatus(const Block& payload)
- {
- this->wireDecode(payload);
- }
+ ChannelStatus(const Block& payload);
template<bool T>
size_t
@@ -77,12 +68,7 @@
}
ChannelStatus&
- setLocalUri(const std::string localUri)
- {
- m_wire.reset();
- m_localUri = localUri;
- return *this;
- }
+ setLocalUri(const std::string localUri);
private:
std::string m_localUri;
@@ -90,56 +76,6 @@
mutable Block m_wire;
};
-
-template<bool T>
-inline size_t
-ChannelStatus::wireEncode(EncodingImpl<T>& encoder) const
-{
- size_t totalLength = 0;
-
- totalLength += prependByteArrayBlock(encoder, tlv::nfd::LocalUri,
- reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size());
-
- totalLength += encoder.prependVarNumber(totalLength);
- totalLength += encoder.prependVarNumber(tlv::nfd::ChannelStatus);
- return totalLength;
-}
-
-inline const Block&
-ChannelStatus::wireEncode() const
-{
- if (m_wire.hasWire())
- return m_wire;
-
- EncodingEstimator estimator;
- size_t estimatedSize = wireEncode(estimator);
-
- EncodingBuffer buffer(estimatedSize, 0);
- wireEncode(buffer);
-
- m_wire = buffer.block();
- return m_wire;
-}
-
-inline void
-ChannelStatus::wireDecode(const Block& block)
-{
- if (block.type() != tlv::nfd::ChannelStatus) {
- throw Error("expecting ChannelStatus block");
- }
- m_wire = block;
- m_wire.parse();
- Block::element_const_iterator val = m_wire.elements_begin();
-
- if (val != m_wire.elements_end() && val->type() == tlv::nfd::LocalUri) {
- m_localUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
- ++val;
- }
- else {
- throw Error("missing required LocalUri field");
- }
-}
-
} // namespace nfd
} // namespace ndn