30 #include <boost/range/adaptor/reversed.hpp>
35 BOOST_CONCEPT_ASSERT((StatusDatasetItem<Route>));
36 BOOST_CONCEPT_ASSERT((StatusDatasetItem<RibEntry>));
86 if (expirationPeriod == time::milliseconds::max())
89 m_expirationPeriod = expirationPeriod;
97 m_expirationPeriod = nullopt;
102 template<encoding::Tag TAG>
106 size_t totalLength = 0;
108 if (m_expirationPeriod) {
110 static_cast<uint64_t
>(m_expirationPeriod->count()));
117 totalLength += block.prependVarNumber(totalLength);
136 m_wire = buffer.block();
160 m_origin = readNonNegativeIntegerAs<RouteOrigin>(*val);
188 m_expirationPeriod = nullopt;
206 <<
"FaceId: " << route.
getFaceId() <<
", "
207 <<
"Origin: " << route.
getOrigin() <<
", "
208 <<
"Cost: " << route.
getCost() <<
", "
215 os <<
"ExpirationPeriod: infinite";
241 m_routes.push_back(route);
254 template<encoding::Tag TAG>
258 size_t totalLength = 0;
260 for (
const auto& route : m_routes | boost::adaptors::reversed) {
261 totalLength += route.wireEncode(block);
265 totalLength += block.prependVarNumber(totalLength);
284 m_wire = buffer.block();
313 m_routes.emplace_back(*val);
324 aRoutes.
size() != bRoutes.size())
327 std::vector<bool> matched(bRoutes.size(),
false);
328 return std::all_of(aRoutes.begin(), aRoutes.end(),
329 [&] (
const Route& route) {
330 for (size_t i = 0; i < bRoutes.size(); ++i) {
331 if (!matched[i] && bRoutes[i] == route) {
343 os <<
"RibEntry(Prefix: " << entry.
getName() <<
",\n"
Helper class to convert a number to hexadecimal format, for use with stream insertion operators.
Represents a TLV element of the NDN packet format.
element_const_iterator elements_begin() const noexcept
Equivalent to elements().begin().
element_const_iterator elements_end() const noexcept
Equivalent to elements().end().
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
uint32_t type() const noexcept
Return the TLV-TYPE of the Block.
void reset() noexcept
Reset the Block to a default-constructed state.
void parse() const
Parse TLV-VALUE into sub-elements.
Represents an absolute name.
size_t size() const noexcept
Returns the number of components.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
void wireDecode(const Block &wire)
Decode name from wire encoding.
Represents an item in NFD RIB dataset.
const Name & getName() const
RibEntry & addRoute(const Route &route)
void wireDecode(const Block &block)
const std::vector< Route > & getRoutes() const
const Block & wireEncode() const
RibEntry & setName(const Name &prefix)
Represents a route in a RibEntry.
Route & unsetExpirationPeriod()
Route & setFlags(uint64_t flags)
bool hasExpirationPeriod() const
RouteOrigin getOrigin() const
Route & setCost(uint64_t cost)
Route & setOrigin(RouteOrigin origin)
uint64_t getFaceId() const
Route & setFaceId(uint64_t faceId)
const Block & wireEncode() const
uint64_t getFlags() const
Route & setExpirationPeriod(time::milliseconds expirationPeriod)
time::milliseconds getExpirationPeriod() const
void wireDecode(const Block &block)
#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
@ ROUTE_FLAG_CHILD_INHERIT
EncodingImpl< EstimatorTag > EncodingEstimator
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
EncodingImpl< EncoderTag > EncodingBuffer
const uint64_t INVALID_FACE_ID
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
bool operator==(const ChannelStatus &a, const ChannelStatus &b)
boost::chrono::milliseconds milliseconds
std::ostream & operator<<(std::ostream &os, const Data &data)
ostream_joiner< std::decay_t< DelimT >, CharT, Traits > make_ostream_joiner(std::basic_ostream< CharT, Traits > &os, DelimT &&delimiter)
Backport of ostream_joiner from the Library Fundamentals v2 TS.