29 #include <boost/range/adaptor/reversed.hpp> 34 BOOST_CONCEPT_ASSERT((StatusDatasetItem<Route>));
35 BOOST_CONCEPT_ASSERT((StatusDatasetItem<RibEntry>));
85 if (expirationPeriod == time::milliseconds::max())
88 m_expirationPeriod = expirationPeriod;
101 template<encoding::Tag TAG>
105 size_t totalLength = 0;
107 if (m_expirationPeriod) {
109 static_cast<uint64_t>(m_expirationPeriod->count()));
116 totalLength += block.prependVarNumber(totalLength);
135 m_wire = buffer.block();
159 m_origin = readNonNegativeIntegerAs<RouteOrigin>(*val);
205 <<
"FaceId: " << route.
getFaceId() <<
", " 206 <<
"Origin: " << route.
getOrigin() <<
", " 207 <<
"Cost: " << route.
getCost() <<
", " 214 os <<
"ExpirationPeriod: infinite";
240 m_routes.push_back(route);
253 template<encoding::Tag TAG>
257 size_t totalLength = 0;
259 for (
const auto& route : m_routes | boost::adaptors::reversed) {
260 totalLength += route.wireEncode(block);
262 totalLength += m_prefix.wireEncode(block);
264 totalLength += block.prependVarNumber(totalLength);
283 m_wire = buffer.block();
304 m_prefix.wireDecode(*val);
312 m_routes.emplace_back(*val);
323 aRoutes.
size() != bRoutes.size())
326 std::vector<bool> matched(bRoutes.size(),
false);
327 return std::all_of(aRoutes.begin(), aRoutes.end(),
328 [&] (
const Route& route) {
329 for (
size_t i = 0; i < bRoutes.size(); ++i) {
330 if (!matched[i] && bRoutes[i] == route) {
342 os <<
"RibEntry(Prefix: " << entry.
getName() <<
",\n"
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
Route & setFlags(uint64_t flags)
uint64_t getFaceId() const
void wireDecode(const Block &block)
Route & setOrigin(RouteOrigin origin)
Helper class to convert a number to hexadecimal format, for use with stream insertion operators...
Represents a TLV element of NDN packet format.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
represents a route in a RibEntry
void wireDecode(const Block &block)
Route & setCost(uint64_t cost)
bool hasExpirationPeriod() const
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
const Name & getName() const
const Block & wireEncode() const
time::milliseconds getExpirationPeriod() const
void reset() noexcept
Reset the Block to a default-constructed state.
const std::vector< Route > & getRoutes() const
uint64_t getFlags() const
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)
#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
RibEntry & addRoute(const Route &route)
size_t size() const
Get number of components.
const Block & wireEncode() const
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
Represents an absolute name.
void parse() const
Parse TLV-VALUE into sub-elements.
uint32_t type() const
Return the TLV-TYPE of the Block.
Route & unsetExpirationPeriod()
Route & setFaceId(uint64_t faceId)
RouteOrigin getOrigin() const
element_const_iterator elements_end() const
Equivalent to elements().end()
element_const_iterator elements_begin() const
Equivalent to elements().begin()
Route & setExpirationPeriod(time::milliseconds expirationPeriod)
RibEntry & setName(const Name &prefix)
represents an item in NFD RIB dataset
EncodingImpl< EncoderTag > EncodingBuffer
const nullopt_t nullopt((nullopt_t::init()))
const uint64_t INVALID_FACE_ID
EncodingImpl< EstimatorTag > EncodingEstimator