model: replacing direct usage of fib::FaceMetric variables by inline methods
diff --git a/model/fib/ndn-fib-entry.cc b/model/fib/ndn-fib-entry.cc
index c04e43b..35b3a99 100644
--- a/model/fib/ndn-fib-entry.cc
+++ b/model/fib/ndn-fib-entry.cc
@@ -54,13 +54,13 @@
FaceMetric::UpdateRtt (const Time &rttSample)
{
// const Time & this->m_rttSample
-
+
//update srtt and rttvar (RFC 2988)
if (m_sRtt.IsZero ())
{
//first RTT measurement
NS_ASSERT_MSG (m_rttVar.IsZero (), "SRTT is zero, but variation is not");
-
+
m_sRtt = rttSample;
m_rttVar = Time (m_sRtt / 2.0);
}
@@ -97,7 +97,7 @@
"Update status can be performed only on existing faces of CcxnFibEntry");
m_faces.modify (record,
- (&ll::_1)->*&FaceMetric::m_status = status);
+ ll::bind (&FaceMetric::SetStatus, ll::_1, status));
// reordering random access index same way as by metric index
m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
@@ -117,16 +117,16 @@
else
{
// don't update metric to higher value
- if (record->m_routingCost > metric || record->m_status == FaceMetric::NDN_FIB_RED)
+ if (record->GetRoutingCost () > metric || record->GetStatus () == FaceMetric::NDN_FIB_RED)
{
m_faces.modify (record,
- (&ll::_1)->*&FaceMetric::m_routingCost = metric);
+ ll::bind (&FaceMetric::SetRoutingCost, ll::_1, metric));
m_faces.modify (record,
- (&ll::_1)->*&FaceMetric::m_status = FaceMetric::NDN_FIB_YELLOW);
+ ll::bind (&FaceMetric::SetStatus, ll::_1, FaceMetric::NDN_FIB_YELLOW));
}
}
-
+
// reordering random access index same way as by metric index
m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
}
@@ -141,7 +141,7 @@
if (record != m_faces.get<i_face> ().end ())
{
m_faces.modify (record,
- (&ll::_1)->*&FaceMetric::m_realDelay = delay);
+ ll::bind (&FaceMetric::SetRealDelay, ll::_1, delay));
}
}
@@ -154,10 +154,10 @@
face++)
{
m_faces.modify (face,
- (&ll::_1)->*&FaceMetric::m_routingCost = std::numeric_limits<uint16_t>::max ());
+ ll::bind (&FaceMetric::SetRoutingCost, ll::_1, std::numeric_limits<uint16_t>::max ()));
m_faces.modify (face,
- (&ll::_1)->*&FaceMetric::m_status = FaceMetric::NDN_FIB_RED);
+ ll::bind (&FaceMetric::SetStatus, ll::_1, FaceMetric::NDN_FIB_RED));
}
}
diff --git a/model/fib/ndn-fib-entry.h b/model/fib/ndn-fib-entry.h
index 214b0eb..57e8916 100644
--- a/model/fib/ndn-fib-entry.h
+++ b/model/fib/ndn-fib-entry.h
@@ -82,7 +82,7 @@
* @brief Comparison between FaceMetric and Face
*/
bool
- operator< (const Ptr<Face> &face) const { return *m_face < *face; }
+ operator< (const Ptr<Face> &face) const { return *m_face < *face; }
/**
* @brief Return Face associated with FaceMetric
@@ -96,17 +96,72 @@
*/
void
UpdateRtt (const Time &rttSample);
-
+
+ /**
+ * @brief Get current status of FIB entry
+ */
+ Status
+ GetStatus () const
+ {
+ return m_status;
+ }
+
+ /**
+ * @brief Set current status of FIB entry
+ */
+ void
+ SetStatus (Status status)
+ {
+ m_status = status;
+ }
+
+ /**
+ * @brief Get current routing cost
+ */
+ int32_t
+ GetRoutingCost () const
+ {
+ return m_routingCost;
+ }
+
+ /**
+ * @brief Set routing cost
+ */
+ void
+ SetRoutingCost (int32_t routingCost)
+ {
+ m_routingCost = routingCost;
+ }
+
+ /**
+ * @brief Get real propagation delay to the producer, calculated based on NS-3 p2p link delays
+ */
+ Time
+ GetRealDelay () const
+ {
+ return m_realDelay;
+ }
+
+ /**
+ * @brief Set real propagation delay to the producer, calculated based on NS-3 p2p link delays
+ */
+ void
+ SetRealDelay (Time realDelay)
+ {
+ m_realDelay = realDelay;
+ }
+
private:
friend std::ostream& operator<< (std::ostream& os, const FaceMetric &metric);
-public:
+
+private:
Ptr<Face> m_face; ///< Face
-
- Status m_status; ///< \brief Status of the next hop:
+
+ Status m_status; ///< \brief Status of the next hop:
///< - NDN_FIB_GREEN
///< - NDN_FIB_YELLOW
///< - NDN_FIB_RED
-
+
int32_t m_routingCost; ///< \brief routing protocol cost (interpretation of the value depends on the underlying routing protocol)
Time m_sRtt; ///< \brief smoothed round-trip time
@@ -141,7 +196,7 @@
// For fast access to elements using Face
boost::multi_index::ordered_unique<
boost::multi_index::tag<i_face>,
- boost::multi_index::member<FaceMetric,Ptr<Face>,&FaceMetric::m_face>
+ boost::multi_index::const_mem_fun<FaceMetric,Ptr<Face>,&FaceMetric::GetFace>
>,
// List of available faces ordered by (status, m_routingCost)
@@ -149,8 +204,8 @@
boost::multi_index::tag<i_metric>,
boost::multi_index::composite_key<
FaceMetric,
- boost::multi_index::member<FaceMetric,FaceMetric::Status,&FaceMetric::m_status>,
- boost::multi_index::member<FaceMetric,int32_t,&FaceMetric::m_routingCost>
+ boost::multi_index::const_mem_fun<FaceMetric,FaceMetric::Status,&FaceMetric::GetStatus>,
+ boost::multi_index::const_mem_fun<FaceMetric,int32_t,&FaceMetric::GetRoutingCost>
>
>,
@@ -172,10 +227,10 @@
{
public:
typedef Entry base_type;
-
+
public:
class NoFaces {}; ///< @brief Exception class for the case when FIB entry is not found
-
+
/**
* \brief Constructor
* \param prefix smart pointer to the prefix for the FIB entry
@@ -185,7 +240,7 @@
, m_needsProbing (false)
{
}
-
+
/**
* \brief Update status of FIB next hop
* \param status Status to set on the FIB entry
@@ -204,7 +259,7 @@
*/
void
SetRealDelayToProducer (Ptr<Face> face, Time delay);
-
+
/**
* @brief Invalidate face
*
@@ -218,7 +273,7 @@
*/
void
UpdateFaceRtt (Ptr<Face> face, const Time &sample);
-
+
/**
* \brief Get prefix for the FIB entry
*/