33 static_assert(std::is_base_of<tlv::Error, ControlParameters::Error>::value,
34 "ControlParameters::Error must inherit from tlv::Error");
47 template<encoding::Tag TAG>
51 size_t totalLength = 0;
78 size_t valLength = encoder.prependByteArray(
79 reinterpret_cast<const uint8_t*>(m_uri.c_str()), m_uri.size());
80 totalLength += valLength;
81 totalLength += encoder.prependVarNumber(valLength);
91 totalLength += encoder.prependVarNumber(totalLength);
114 m_wire = buffer.block();
122 BOOST_THROW_EXCEPTION(
Error(
"Expecting TLV-TYPE ControlParameters"));
143 m_uri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
174 if (val->elements().empty()) {
175 BOOST_THROW_EXCEPTION(
Error(
"Expecting Strategy/Name"));
178 m_strategy.
wireDecode(*val->elements_begin());
198 os <<
"ControlParameters(";
201 os <<
"Name: " << parameters.
getName() <<
", ";
205 os <<
"FaceId: " << parameters.
getFaceId() <<
", ";
208 if (parameters.
hasUri()) {
209 os <<
"Uri: " << parameters.
getUri() <<
", ";
217 os <<
"Origin: " << parameters.
getOrigin() <<
", ";
221 os <<
"Cost: " << parameters.
getCost() <<
", ";
225 os <<
"Flags: " << parameters.
getFlags() <<
", ";
229 os <<
"Strategy: " << parameters.
getStrategy() <<
", ";
uint64_t getFlags() const
bool hasWire() const
Check if the Block has fully encoded wire.
virtual void wireDecode(const Block &wire) final
Copyright (c) 2011-2015 Regents of the University of California.
bool hasLocalControlFeature() const
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Helper to prepend TLV block type type containing non-negative integer value.
represents parameters in a ControlCommand request or response
EncodingImpl< EstimatorTag > EncodingEstimator
element_const_iterator elements_end() const
size_t prependNestedBlock(EncodingImpl< TAG > &encoder, uint32_t type, const U &value)
Prepend a TLV block of type type with WireEncodable value as a value.
void parse() const
Parse wire buffer into subblocks.
Class representing a wire element of NDN-TLV packet format.
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
uint64_t getOrigin() const
const Name & getName() const
virtual Block wireEncode() const final
EncodingImpl< EncoderTag > EncodingBuffer
Copyright (c) 2011-2015 Regents of the University of California.
element_const_iterator find(uint32_t type) const
bool hasExpirationPeriod() const
element_container::const_iterator element_const_iterator
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
uint64_t getFaceId() const
const std::string & getUri() const
bool hasFacePersistency() const
const time::milliseconds & getExpirationPeriod() const
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
void wireDecode(const Block &wire)
LocalControlFeature getLocalControlFeature() const
a concept check for TLV abstraction with .wireEncode method
const Name & getStrategy() const
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...