33 static_assert(std::is_base_of<tlv::Error, Route::Error>::value,
34 "Route::Error must inherit from tlv::Error");
39 static_assert(std::is_base_of<tlv::Error, RibEntry::Error>::value,
40 "RibEntry::Error must inherit from tlv::Error");
49 , m_expirationPeriod(INFINITE_EXPIRATION_PERIOD)
50 , m_hasInfiniteExpirationPeriod(true)
59 template<encoding::Tag TAG>
63 size_t totalLength = 0;
66 if (!m_hasInfiniteExpirationPeriod) {
69 m_expirationPeriod.count());
88 totalLength += block.prependVarNumber(totalLength);
113 m_wire = buffer.block();
125 m_expirationPeriod = time::milliseconds::min();
130 std::stringstream error;
131 error <<
"Expected Route Block, but Block is of a different type: #" 133 BOOST_THROW_EXCEPTION(
Error(error.str()));
145 BOOST_THROW_EXCEPTION(
Error(
"Missing required FaceId field"));
153 BOOST_THROW_EXCEPTION(
Error(
"Missing required Origin field"));
161 BOOST_THROW_EXCEPTION(
Error(
"Missing required Cost field"));
169 BOOST_THROW_EXCEPTION(
Error(
"Missing required Flags field"));
174 m_hasInfiniteExpirationPeriod =
false;
178 m_hasInfiniteExpirationPeriod =
true;
186 <<
"FaceId: " << route.
getFaceId() <<
", " 187 <<
"Origin: " << route.
getOrigin() <<
", " 188 <<
"Cost: " << route.
getCost() <<
", " 189 <<
"Flags: " << route.
getFlags() <<
", ";
195 os <<
"ExpirationPeriod: Infinity";
219 template<encoding::Tag TAG>
223 size_t totalLength = 0;
225 for (std::list<Route>::const_reverse_iterator it = m_routes.rbegin();
226 it != m_routes.rend(); ++it)
228 totalLength += it->wireEncode(block);
233 totalLength += block.prependVarNumber(totalLength);
258 m_wire = buffer.block();
272 std::stringstream error;
273 error <<
"Expected RibEntry Block, but Block is of a different type: #" 275 BOOST_THROW_EXCEPTION(
Error(error.str()));
287 BOOST_THROW_EXCEPTION(
Error(
"Missing required Name field"));
293 m_routes.push_back(
Route(*val));
296 std::stringstream error;
297 error <<
"Expected Route Block, but Block is of a different type: #" 299 BOOST_THROW_EXCEPTION(
Error(error.str()));
308 <<
" Name: " << entry.
getName() <<
"\n";
311 os <<
" " << *it <<
"\n";
element_const_iterator elements_begin() const
bool hasWire() const
Check if the Block has fully encoded wire.
Copyright (c) 2011-2015 Regents of the University of California.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Helper to prepend TLV block type type containing non-negative integer value.
RouteList::const_iterator iterator
bool hasInfiniteExpirationPeriod() const
EncodingImpl< EstimatorTag > EncodingEstimator
const Name & getName() const
element_const_iterator elements_end() const
void parse() const
Parse wire buffer into subblocks.
Class representing a wire element of NDN-TLV packet format.
Data abstraction for Route.
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
static const time::milliseconds INFINITE_EXPIRATION_PERIOD
EncodingImpl< EncoderTag > EncodingBuffer
Copyright (c) 2011-2015 Regents of the University of California.
const Block & wireEncode() const
uint64_t getFaceId() const
void wireDecode(const Block &wire)
element_container::const_iterator element_const_iterator
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
uint64_t getOrigin() const
const Block & wireEncode() const
void wireDecode(const Block &wire)
const time::milliseconds & getExpirationPeriod() const
uint64_t getFlags() const
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
void wireDecode(const Block &wire)
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
void clear()
Clear all the components.
Data abstraction for RIB entry.