management: adding all high-level methods in nrd::Controller
Change-Id: Ib8d50dae5168f6f3ed3d30b22787cb3574f87e87
diff --git a/src/management/nrd-prefix-reg-options.hpp b/src/management/nrd-prefix-reg-options.hpp
index 12136e8..412194b 100644
--- a/src/management/nrd-prefix-reg-options.hpp
+++ b/src/management/nrd-prefix-reg-options.hpp
@@ -44,21 +44,21 @@
template<bool T>
size_t
wireEncode(EncodingImpl<T>& block) const;
-
+
const Block&
wireEncode() const;
-
- void
+
+ void
wireDecode(const Block& wire);
-
+
////////////////////////////////////////////////////////
-
- const Name&
+
+ const Name&
getName() const
{
return m_name;
}
-
+
PrefixRegOptions&
setName(const Name& name)
{
@@ -68,7 +68,7 @@
}
//
-
+
uint64_t
getFaceId() const
{
@@ -84,8 +84,8 @@
}
//
-
- uint64_t
+
+ uint64_t
getFlags() const
{
return m_flags;
@@ -100,8 +100,8 @@
}
//
-
- uint64_t
+
+ uint64_t
getCost() const
{
return m_cost;
@@ -116,7 +116,7 @@
}
//
-
+
Milliseconds
getExpirationPeriod() const
{
@@ -132,24 +132,8 @@
}
//
-
- const Name&
- getStrategy() const
- {
- return m_strategy;
- }
- PrefixRegOptions&
- setStrategy(const Name& strategy)
- {
- m_strategy = strategy;
- m_wire.reset();
- return *this;
- }
-
- //
-
- const std::string&
+ const std::string&
getProtocol() const
{
return m_protocol;
@@ -162,16 +146,15 @@
m_wire.reset();
return *this;
}
-
+
private:
Name m_name;
uint64_t m_faceId;
uint64_t m_flags;
uint64_t m_cost;
Milliseconds m_expirationPeriod;
- Name m_strategy;
std::string m_protocol;
-
+
mutable Block m_wire;
};
@@ -185,9 +168,8 @@
// Name
// FaceId?
// Flags?
- // Cost?
+ // Cost?
// ExpirationPeriod?
- // StrategyName?
// Protocol?
// (reverse encoding)
@@ -201,12 +183,6 @@
m_protocol.size());
}
- // StrategyName
- if (!m_strategy.empty())
- {
- total_len += prependNestedBlock(block, tlv::nrd::StrategyName, m_strategy);
- }
-
// ExpirationPeriod
if (m_expirationPeriod > 0)
{
@@ -248,24 +224,23 @@
EncodingEstimator estimator;
size_t estimatedSize = wireEncode(estimator);
-
+
EncodingBuffer buffer(estimatedSize, 0);
wireEncode(buffer);
m_wire = buffer.block();
return m_wire;
}
-
-inline void
+
+inline void
PrefixRegOptions::wireDecode(const Block& wire)
{
// PrefixRegOptions ::= PREFIX-REG-OPTIONS-TYPE TLV-LENGTH
// Name
// FaceId?
// Flags?
- // Cost?
+ // Cost?
// ExpirationPeriod?
- // StrategyName?
// Protocol?
m_name.clear();
@@ -273,14 +248,13 @@
m_flags = DEFAULT_FLAGS;
m_cost = DEFAULT_COST;
m_expirationPeriod = -1;
- m_strategy.clear();
m_protocol.clear();
m_wire = wire;
if (m_wire.type() != tlv::nrd::PrefixRegOptions)
throw Error("Requested decoding of PrefixRegOptions, but Block is of different type");
-
+
m_wire.parse ();
// Name
@@ -296,7 +270,7 @@
{
m_faceId = readNonNegativeInteger(*val);
}
-
+
// Flags
val = m_wire.find(tlv::nrd::Flags);
if (val != m_wire.elements_end())
@@ -318,15 +292,6 @@
m_expirationPeriod = readNonNegativeInteger(*val);
}
- // StrategyName
- val = m_wire.find(tlv::nrd::StrategyName);
- if (val != m_wire.elements_end())
- {
- val->parse();
- if (!val->elements().empty())
- m_strategy.wireDecode(*val->elements_begin());
- }
-
// Protocol
val = m_wire.find(tlv::nrd::Protocol);
if (val != m_wire.elements_end())
@@ -336,26 +301,32 @@
}
}
-// inline std::ostream&
-// operator << (std::ostream &os, const PrefixRegOptions &option)
-// {
-// os << "ForwardingEntry(";
-
-// // Name
-// os << "Prefix: " << option.getName() << ", ";
+inline std::ostream&
+operator << (std::ostream &os, const PrefixRegOptions &option)
+{
+ os << "PrefixRegOptions(";
-// // FaceID
-// os << "FaceID: " << option.getFaceId() << ", ";
+ // Name
+ os << "Prefix: " << option.getName() << ", ";
-// // Cost
-// os << "Cost: " << option.getCost() << ", ";
+ // FaceID
+ os << "FaceID: " << option.getFaceId() << ", ";
-// // Strategy
-// os << "Strategy: " << option.getStrategy() << ", ";
-
-// os << ")";
-// return os;
-// }
+ // Flags
+ os << "Flags: " << option.getFlags() << ", ";
+
+ // Cost
+ os << "Cost: " << option.getCost() << ", ";
+
+ // ExpirationPeriod
+ os << "ExpirationPeriod: " << option.getExpirationPeriod() << ", ";
+
+ // Protocol
+ os << "Protocol: " << option.getProtocol();
+
+ os << ")";
+ return os;
+}
} // namespace nrd
} // namespace ndn