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;
74 size_t valLength = encoder.prependByteArray(
75 reinterpret_cast<const uint8_t*>(m_uri.c_str()), m_uri.size());
76 totalLength += valLength;
77 totalLength += encoder.prependVarNumber(valLength);
87 totalLength += encoder.prependVarNumber(totalLength);
110 m_wire = buffer.block();
118 BOOST_THROW_EXCEPTION(
Error(
"Expecting TLV-TYPE ControlParameters"));
139 m_uri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
170 if (val->elements().empty()) {
171 BOOST_THROW_EXCEPTION(
Error(
"Expecting Strategy/Name"));
174 m_strategy.
wireDecode(*val->elements_begin());
188 os <<
"ControlParameters(";
191 os <<
"Name: " << parameters.
getName() <<
", ";
195 os <<
"FaceId: " << parameters.
getFaceId() <<
", ";
198 if (parameters.
hasUri()) {
199 os <<
"Uri: " << parameters.
getUri() <<
", ";
207 os <<
"Origin: " << parameters.
getOrigin() <<
", ";
211 os <<
"Cost: " << parameters.
getCost() <<
", ";
215 os <<
"Flags: " << parameters.
getFlags() <<
", ";
219 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
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 ...