28 #include <boost/range/adaptor/reversed.hpp> 63 template<encoding::Tag TAG>
67 size_t totalLength = 0;
72 totalLength += block.prependVarNumber(totalLength);
91 m_wire = buffer.block();
99 BOOST_THROW_EXCEPTION(
Error(
"expecting NextHopRecord, but Block has type " +
to_string(block.
type())));
106 BOOST_THROW_EXCEPTION(
Error(
"unexpected end of NextHopRecord"));
109 BOOST_THROW_EXCEPTION(
Error(
"expecting FaceId, but Block has type " +
to_string(val->type())));
115 BOOST_THROW_EXCEPTION(
Error(
"unexpected end of NextHopRecord"));
118 BOOST_THROW_EXCEPTION(
Error(
"expecting Cost, but Block has type " +
to_string(val->type())));
134 return os <<
"NextHopRecord(" 160 m_nextHopRecords.push_back(nh);
168 m_nextHopRecords.clear();
173 template<encoding::Tag TAG>
177 size_t totalLength = 0;
179 for (
const auto& nh : m_nextHopRecords | boost::adaptors::reversed) {
180 totalLength += nh.wireEncode(block);
184 totalLength += block.prependVarNumber(totalLength);
203 m_wire = buffer.block();
211 BOOST_THROW_EXCEPTION(
Error(
"expecting FibEntry, but Block has type " +
to_string(block.
type())));
218 BOOST_THROW_EXCEPTION(
Error(
"unexpected end of FibEntry"));
221 BOOST_THROW_EXCEPTION(
Error(
"expecting Name, but Block has type " +
to_string(val->type())));
226 m_nextHopRecords.clear();
229 BOOST_THROW_EXCEPTION(
Error(
"expecting NextHopRecord, but Block has type " +
to_string(val->type())));
231 m_nextHopRecords.emplace_back(*val);
242 aNextHops.
size() != bNextHops.size())
245 std::vector<bool> matched(bNextHops.size(),
false);
246 return std::all_of(aNextHops.begin(), aNextHops.end(),
248 for (
size_t i = 0; i < bNextHops.size(); ++i) {
249 if (!matched[i] && bNextHops[i] == nh) {
261 os <<
"FibEntry(Prefix: " << entry.
getPrefix() <<
",\n" bool hasWire() const
Check if the Block has fully encoded wire.
Copyright (c) 2011-2015 Regents of the University of California.
void wireDecode(const Block &block)
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
NextHopRecord & setFaceId(uint64_t faceId)
FibEntry & setPrefix(const Name &prefix)
const std::vector< NextHopRecord > & getNextHopRecords() const
element_container::const_iterator element_const_iterator
void parse() const
Parse TLV-VALUE into sub elements.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ChannelStatus)
Represents a TLV element of NDN packet format.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
void wireDecode(const Block &block)
element_const_iterator elements_end() const
Equivalent to elements().end()
Copyright (c) 2011-2015 Regents of the University of California.
FibEntry & clearNextHopRecords()
bool operator==(const ChannelStatus &a, const ChannelStatus &b)
ostream_joiner< std::decay_t< DelimT >, CharT, Traits > make_ostream_joiner(std::basic_ostream< CharT, Traits > &os, DelimT &&delimiter)
NextHopRecord & setCost(uint64_t cost)
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
void reset()
Reset wire buffer of the element.
Represents an absolute name.
concept check for an item in a Status Dataset
size_t size() const
Get number of components.
const Block & wireEncode() const
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
std::string to_string(const V &v)
void wireDecode(const Block &wire)
Decode name from wire encoding.
const Name & getPrefix() const
uint64_t getFaceId() const
EncodingImpl< EncoderTag > EncodingBuffer
uint32_t type() const
Get TLV-TYPE.
const uint64_t INVALID_FACE_ID
const Block & wireEncode() const
EncodingImpl< EstimatorTag > EncodingEstimator
FibEntry & addNextHopRecord(const NextHopRecord &nh)