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;
81 size_t valLength = encoder.prependByteArray(
82 reinterpret_cast<const uint8_t*>(m_uri.c_str()), m_uri.size());
83 totalLength += valLength;
84 totalLength += encoder.prependVarNumber(valLength);
94 totalLength += encoder.prependVarNumber(totalLength);
117 m_wire = buffer.block();
125 BOOST_THROW_EXCEPTION(
Error(
"Expecting TLV-TYPE ControlParameters"));
146 m_uri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
183 if (val->elements().empty()) {
184 BOOST_THROW_EXCEPTION(
Error(
"Expecting Strategy/Name"));
187 m_strategy.
wireDecode(*val->elements_begin());
208 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
222 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
236 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
244 flags &= ~(1 << bit);
261 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
280 os <<
"ControlParameters(";
283 os <<
"Name: " << parameters.
getName() <<
", ";
287 os <<
"FaceId: " << parameters.
getFaceId() <<
", ";
290 if (parameters.
hasUri()) {
291 os <<
"Uri: " << parameters.
getUri() <<
", ";
299 os <<
"Origin: " << parameters.
getOrigin() <<
", ";
303 os <<
"Cost: " << parameters.
getCost() <<
", ";
307 std::ios_base::fmtflags osFlags = os.flags();
308 os <<
"Flags: " << std::showbase << std::hex << parameters.
getFlags() <<
", ";
313 std::ios_base::fmtflags osFlags = os.flags();
314 os <<
"Mask: " << std::showbase << std::hex << parameters.
getMask() <<
", ";
319 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.
ControlParameters & setFlags(uint64_t flags)
ControlParameters & unsetMask()
Class representing a wire element of NDN-TLV packet format.
ControlParameters & unsetFlags()
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
uint64_t getOrigin() const
ControlParameters & unsetFlagBit(size_t bit)
disable a bit in Mask
FacePersistency getFacePersistency() 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)
bool hasFlagBit(size_t bit) const
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.
bool getFlagBit(size_t bit) const
void wireDecode(const Block &wire)
LocalControlFeature getLocalControlFeature() const
a concept check for TLV abstraction with .wireEncode method
const Name & getStrategy() const
ControlParameters & setMask(uint64_t mask)
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
ControlParameters & setFlagBit(size_t bit, bool value, bool wantMask=true)
set a bit in Flags