Another set of refactoring
diff --git a/model/fib/ndn-fib-entry.cc b/model/fib/ndn-fib-entry.cc
index 965886f..01e2970 100644
--- a/model/fib/ndn-fib-entry.cc
+++ b/model/fib/ndn-fib-entry.cc
@@ -32,30 +32,25 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnFibEntry");
+NS_LOG_COMPONENT_DEFINE ("ndn.fib.Entry");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
+namespace fib {
//////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////
-namespace __ndn_private {
-struct NdnFibFaceMetricByFace
+struct FaceMetricByFace
{
- typedef NdnFibFaceMetricContainer::type::index<i_face>::type
+ typedef FaceMetricContainer::type::index<i_face>::type
type;
};
-}
-//////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////
-
-using namespace __ndn_private;
void
-NdnFibFaceMetric::UpdateRtt (const Time &rttSample)
+FaceMetric::UpdateRtt (const Time &rttSample)
{
// const Time & this->m_rttSample
@@ -78,56 +73,56 @@
/////////////////////////////////////////////////////////////////////
void
-NdnFibEntry::UpdateFaceRtt (Ptr<NdnFace> face, const Time &sample)
+Entry::UpdateFaceRtt (Ptr<Face> face, const Time &sample)
{
- NdnFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
+ FaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
NS_ASSERT_MSG (record != m_faces.get<i_face> ().end (),
"Update status can be performed only on existing faces of CcxnFibEntry");
m_faces.modify (record,
- ll::bind (&NdnFibFaceMetric::UpdateRtt, ll::_1, sample));
+ ll::bind (&FaceMetric::UpdateRtt, ll::_1, sample));
// reordering random access index same way as by metric index
m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
}
void
-NdnFibEntry::UpdateStatus (Ptr<NdnFace> face, NdnFibFaceMetric::Status status)
+Entry::UpdateStatus (Ptr<Face> face, FaceMetric::Status status)
{
NS_LOG_FUNCTION (this << boost::cref(*face) << status);
- NdnFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
+ FaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
NS_ASSERT_MSG (record != m_faces.get<i_face> ().end (),
"Update status can be performed only on existing faces of CcxnFibEntry");
m_faces.modify (record,
- (&ll::_1)->*&NdnFibFaceMetric::m_status = status);
+ (&ll::_1)->*&FaceMetric::m_status = status);
// reordering random access index same way as by metric index
m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
}
void
-NdnFibEntry::AddOrUpdateRoutingMetric (Ptr<NdnFace> face, int32_t metric)
+Entry::AddOrUpdateRoutingMetric (Ptr<Face> face, int32_t metric)
{
NS_LOG_FUNCTION (this);
NS_ASSERT_MSG (face != NULL, "Trying to Add or Update NULL face");
- NdnFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
+ FaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
if (record == m_faces.get<i_face> ().end ())
{
- m_faces.insert (NdnFibFaceMetric (face, metric));
+ m_faces.insert (FaceMetric (face, metric));
}
else
{
// don't update metric to higher value
- if (record->m_routingCost > metric || record->m_status == NdnFibFaceMetric::NDN_FIB_RED)
+ if (record->m_routingCost > metric || record->m_status == FaceMetric::NDN_FIB_RED)
{
m_faces.modify (record,
- (&ll::_1)->*&NdnFibFaceMetric::m_routingCost = metric);
+ (&ll::_1)->*&FaceMetric::m_routingCost = metric);
m_faces.modify (record,
- (&ll::_1)->*&NdnFibFaceMetric::m_status = NdnFibFaceMetric::NDN_FIB_YELLOW);
+ (&ll::_1)->*&FaceMetric::m_status = FaceMetric::NDN_FIB_YELLOW);
}
}
@@ -136,31 +131,31 @@
}
void
-NdnFibEntry::Invalidate ()
+Entry::Invalidate ()
{
- for (NdnFibFaceMetricByFace::type::iterator face = m_faces.begin ();
+ for (FaceMetricByFace::type::iterator face = m_faces.begin ();
face != m_faces.end ();
face++)
{
m_faces.modify (face,
- (&ll::_1)->*&NdnFibFaceMetric::m_routingCost = std::numeric_limits<uint16_t>::max ());
+ (&ll::_1)->*&FaceMetric::m_routingCost = std::numeric_limits<uint16_t>::max ());
m_faces.modify (face,
- (&ll::_1)->*&NdnFibFaceMetric::m_status = NdnFibFaceMetric::NDN_FIB_RED);
+ (&ll::_1)->*&FaceMetric::m_status = FaceMetric::NDN_FIB_RED);
}
}
-const NdnFibFaceMetric &
-NdnFibEntry::FindBestCandidate (uint32_t skip/* = 0*/) const
+const FaceMetric &
+Entry::FindBestCandidate (uint32_t skip/* = 0*/) const
{
- if (m_faces.size () == 0) throw NdnFibEntry::NoFaces ();
+ if (m_faces.size () == 0) throw Entry::NoFaces ();
skip = skip % m_faces.size();
return m_faces.get<i_nth> () [skip];
}
-std::ostream& operator<< (std::ostream& os, const NdnFibEntry &entry)
+std::ostream& operator<< (std::ostream& os, const Entry &entry)
{
- for (NdnFibFaceMetricContainer::type::index<i_nth>::type::iterator metric =
+ for (FaceMetricContainer::type::index<i_nth>::type::iterator metric =
entry.m_faces.get<i_nth> ().begin ();
metric != entry.m_faces.get<i_nth> ().end ();
metric++)
@@ -173,7 +168,7 @@
return os;
}
-std::ostream& operator<< (std::ostream& os, const NdnFibFaceMetric &metric)
+std::ostream& operator<< (std::ostream& os, const FaceMetric &metric)
{
static const std::string statusString[] = {"","g","y","r"};
@@ -181,5 +176,6 @@
return os;
}
-
-} // ns3
+} // namespace fib
+} // namespace ndn
+} // namespace ns3
diff --git a/model/fib/ndn-fib-entry.h b/model/fib/ndn-fib-entry.h
index cf8cbe6..532120f 100644
--- a/model/fib/ndn-fib-entry.h
+++ b/model/fib/ndn-fib-entry.h
@@ -23,8 +23,8 @@
#include "ns3/ptr.h"
#include "ns3/nstime.h"
-#include "ns3/ndn.h"
#include "ns3/ndn-face.h"
+#include "ns3/ndn-name-components.h"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/tag.hpp>
@@ -35,16 +35,18 @@
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/mem_fun.hpp>
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-class NdnNameComponents;
+class NameComponents;
+
+namespace fib {
/**
* \ingroup ndn
* \brief Structure holding various parameters associated with a (FibEntry, Face) tuple
*/
-class NdnFibFaceMetric
+class FaceMetric
{
public:
/**
@@ -60,7 +62,7 @@
* \param face Face for which metric
* \param cost Initial value for routing cost
*/
- NdnFibFaceMetric (Ptr<NdnFace> face, int32_t cost)
+ FaceMetric (Ptr<Face> face, int32_t cost)
: m_face (face)
, m_status (NDN_FIB_YELLOW)
, m_routingCost (cost)
@@ -72,18 +74,18 @@
* \brief Comparison operator used by boost::multi_index::identity<>
*/
bool
- operator< (const NdnFibFaceMetric &fm) const { return *m_face < *fm.m_face; } // return identity of the face
+ operator< (const FaceMetric &fm) const { return *m_face < *fm.m_face; } // return identity of the face
/**
- * @brief Comparison between NdnFibFaceMetric and NdnFace
+ * @brief Comparison between FaceMetric and Face
*/
bool
- operator< (const Ptr<NdnFace> &face) const { return *m_face < *face; }
+ operator< (const Ptr<Face> &face) const { return *m_face < *face; }
/**
- * @brief Return NdnFace associated with NdnFibFaceMetric
+ * @brief Return Face associated with FaceMetric
*/
- Ptr<NdnFace>
+ Ptr<Face>
GetFace () const { return m_face; }
/**
@@ -94,9 +96,9 @@
UpdateRtt (const Time &rttSample);
private:
- friend std::ostream& operator<< (std::ostream& os, const NdnFibFaceMetric &metric);
+ friend std::ostream& operator<< (std::ostream& os, const FaceMetric &metric);
public:
- Ptr<NdnFace> m_face; ///< Face
+ Ptr<Face> m_face; ///< Face
Status m_status; ///< \brief Status of the next hop:
///< - NDN_FIB_GREEN
@@ -109,9 +111,16 @@
Time m_rttVar; ///< \brief round-trip time variation
};
+/// @cond include_hidden
+class i_face {};
+class i_metric {};
+class i_nth {};
+/// @endcond
+
+
/**
* \ingroup ndn
- * \brief Typedef for indexed face container of NdnFibEntry
+ * \brief Typedef for indexed face container of Entry
*
* Currently, there are 2 indexes:
* - by face (used to find record and update metric)
@@ -119,31 +128,31 @@
* - random access index (for fast lookup on nth face). Order is
* maintained manually to be equal to the 'by metric' order
*/
-struct NdnFibFaceMetricContainer
+struct FaceMetricContainer
{
/// @cond include_hidden
typedef boost::multi_index::multi_index_container<
- NdnFibFaceMetric,
+ FaceMetric,
boost::multi_index::indexed_by<
- // For fast access to elements using NdnFace
+ // For fast access to elements using Face
boost::multi_index::ordered_unique<
- boost::multi_index::tag<__ndn_private::i_face>,
- boost::multi_index::member<NdnFibFaceMetric,Ptr<NdnFace>,&NdnFibFaceMetric::m_face>
+ boost::multi_index::tag<i_face>,
+ boost::multi_index::member<FaceMetric,Ptr<Face>,&FaceMetric::m_face>
>,
// List of available faces ordered by (status, m_routingCost)
boost::multi_index::ordered_non_unique<
- boost::multi_index::tag<__ndn_private::i_metric>,
+ boost::multi_index::tag<i_metric>,
boost::multi_index::composite_key<
- NdnFibFaceMetric,
- boost::multi_index::member<NdnFibFaceMetric,NdnFibFaceMetric::Status,&NdnFibFaceMetric::m_status>,
- boost::multi_index::member<NdnFibFaceMetric,int32_t,&NdnFibFaceMetric::m_routingCost>
+ FaceMetric,
+ boost::multi_index::member<FaceMetric,FaceMetric::Status,&FaceMetric::m_status>,
+ boost::multi_index::member<FaceMetric,int32_t,&FaceMetric::m_routingCost>
>
>,
// To optimize nth candidate selection (sacrifice a little bit space to gain speed)
boost::multi_index::random_access<
- boost::multi_index::tag<__ndn_private::i_nth>
+ boost::multi_index::tag<i_nth>
>
>
> type;
@@ -155,7 +164,7 @@
* \brief Structure for FIB table entry, holding indexed list of
* available faces and their respective metrics
*/
-class NdnFibEntry : public SimpleRefCount<NdnFibEntry>
+class Entry : public SimpleRefCount<Entry>
{
public:
class NoFaces {}; ///< @brief Exception class for the case when FIB entry is not found
@@ -164,7 +173,7 @@
* \brief Constructor
* \param prefix smart pointer to the prefix for the FIB entry
*/
- NdnFibEntry (const Ptr<const NdnNameComponents> &prefix)
+ Entry (const Ptr<const NameComponents> &prefix)
: m_prefix (prefix)
, m_needsProbing (false)
{ }
@@ -173,14 +182,14 @@
* \brief Update status of FIB next hop
* \param status Status to set on the FIB entry
*/
- void UpdateStatus (Ptr<NdnFace> face, NdnFibFaceMetric::Status status);
+ void UpdateStatus (Ptr<Face> face, FaceMetric::Status status);
/**
* \brief Add or update routing metric of FIB next hop
*
* Initial status of the next hop is set to YELLOW
*/
- void AddOrUpdateRoutingMetric (Ptr<NdnFace> face, int32_t metric);
+ void AddOrUpdateRoutingMetric (Ptr<Face> face, int32_t metric);
/**
* @brief Invalidate face
@@ -194,44 +203,46 @@
* @brief Update RTT averages for the face
*/
void
- UpdateFaceRtt (Ptr<NdnFace> face, const Time &sample);
+ UpdateFaceRtt (Ptr<Face> face, const Time &sample);
/**
* \brief Get prefix for the FIB entry
*/
- const NdnNameComponents&
+ const NameComponents&
GetPrefix () const { return *m_prefix; }
/**
* \brief Find "best route" candidate, skipping `skip' first candidates (modulo # of faces)
*
- * throws NdnFibEntry::NoFaces if m_faces.size()==0
+ * throws Entry::NoFaces if m_faces.size()==0
*/
- const NdnFibFaceMetric &
+ const FaceMetric &
FindBestCandidate (uint32_t skip = 0) const;
/**
* @brief Remove record associated with `face`
*/
void
- RemoveFace (const Ptr<NdnFace> &face)
+ RemoveFace (const Ptr<Face> &face)
{
m_faces.erase (face);
}
private:
- friend std::ostream& operator<< (std::ostream& os, const NdnFibEntry &entry);
+ friend std::ostream& operator<< (std::ostream& os, const Entry &entry);
public:
- Ptr<const NdnNameComponents> m_prefix; ///< \brief Prefix of the FIB entry
- NdnFibFaceMetricContainer::type m_faces; ///< \brief Indexed list of faces
+ Ptr<const NameComponents> m_prefix; ///< \brief Prefix of the FIB entry
+ FaceMetricContainer::type m_faces; ///< \brief Indexed list of faces
bool m_needsProbing; ///< \brief flag indicating that probing should be performed
};
-std::ostream& operator<< (std::ostream& os, const NdnFibEntry &entry);
-std::ostream& operator<< (std::ostream& os, const NdnFibFaceMetric &metric);
+std::ostream& operator<< (std::ostream& os, const Entry &entry);
+std::ostream& operator<< (std::ostream& os, const FaceMetric &metric);
-} // ns3
+} // namespace fib
+} // namespace ndn
+} // namespace ns3
#endif // _NDN_FIB_ENTRY_H_
diff --git a/model/fib/ndn-fib-impl.cc b/model/fib/ndn-fib-impl.cc
index 747c689..a55e9fd 100644
--- a/model/fib/ndn-fib-impl.cc
+++ b/model/fib/ndn-fib-impl.cc
@@ -34,43 +34,45 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnFibImpl");
+NS_LOG_COMPONENT_DEFINE ("ndn.fib.FibImpl");
namespace ns3 {
+namespace ndn {
+namespace fib {
-NS_OBJECT_ENSURE_REGISTERED (NdnFibImpl);
+NS_OBJECT_ENSURE_REGISTERED (FibImpl);
TypeId
-NdnFibImpl::GetTypeId (void)
+FibImpl::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnFib") // cheating ns3 object system
- .SetParent<NdnFib> ()
+ static TypeId tid = TypeId ("ns3::ndn::fib::Default") // cheating ns3 object system
+ .SetParent<Fib> ()
.SetGroupName ("Ndn")
- .AddConstructor<NdnFibImpl> ()
+ .AddConstructor<FibImpl> ()
;
return tid;
}
-NdnFibImpl::NdnFibImpl ()
+FibImpl::FibImpl ()
{
}
void
-NdnFibImpl::NotifyNewAggregate ()
+FibImpl::NotifyNewAggregate ()
{
Object::NotifyNewAggregate ();
}
void
-NdnFibImpl::DoDispose (void)
+FibImpl::DoDispose (void)
{
clear ();
Object::DoDispose ();
}
-Ptr<NdnFibEntry>
-NdnFibImpl::LongestPrefixMatch (const NdnInterestHeader &interest)
+Ptr<Entry>
+FibImpl::LongestPrefixMatch (const InterestHeader &interest)
{
super::iterator item = super::longest_prefix_match (interest.GetName ());
// @todo use predicate to search with exclude filters
@@ -82,14 +84,14 @@
}
-Ptr<NdnFibEntry>
-NdnFibImpl::Add (const NdnNameComponents &prefix, Ptr<NdnFace> face, int32_t metric)
+Ptr<Entry>
+FibImpl::Add (const NameComponents &prefix, Ptr<Face> face, int32_t metric)
{
- return Add (Create<NdnNameComponents> (prefix), face, metric);
+ return Add (Create<NameComponents> (prefix), face, metric);
}
-Ptr<NdnFibEntry>
-NdnFibImpl::Add (const Ptr<const NdnNameComponents> &prefix, Ptr<NdnFace> face, int32_t metric)
+Ptr<Entry>
+FibImpl::Add (const Ptr<const NameComponents> &prefix, Ptr<Face> face, int32_t metric)
{
NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix) << boost::cref(*face) << metric);
@@ -99,13 +101,13 @@
{
if (result.second)
{
- Ptr<NdnFibEntryImpl> newEntry = Create<NdnFibEntryImpl> (prefix);
+ Ptr<EntryImpl> newEntry = Create<EntryImpl> (prefix);
newEntry->SetTrie (result.first);
result.first->set_payload (newEntry);
}
super::modify (result.first,
- ll::bind (&NdnFibEntry::AddOrUpdateRoutingMetric, ll::_1, face, metric));
+ ll::bind (&Entry::AddOrUpdateRoutingMetric, ll::_1, face, metric));
return result.first->payload ();
}
@@ -114,7 +116,7 @@
}
void
-NdnFibImpl::Remove (const Ptr<const NdnNameComponents> &prefix)
+FibImpl::Remove (const Ptr<const NameComponents> &prefix)
{
NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
@@ -122,7 +124,7 @@
}
// void
-// NdnFibImpl::Invalidate (const Ptr<const NdnNameComponents> &prefix)
+// FibImpl::Invalidate (const Ptr<const NameComponents> &prefix)
// {
// NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
@@ -134,11 +136,11 @@
// return; // nothing to invalidate
// super::modify (lastItem,
-// ll::bind (&NdnFibEntry::Invalidate, ll::_1));
+// ll::bind (&Entry::Invalidate, ll::_1));
// }
void
-NdnFibImpl::InvalidateAll ()
+FibImpl::InvalidateAll ()
{
NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId ());
@@ -149,28 +151,28 @@
if (item->payload () == 0) continue;
super::modify (&(*item),
- ll::bind (&NdnFibEntry::Invalidate, ll::_1));
+ ll::bind (&Entry::Invalidate, ll::_1));
}
}
void
-NdnFibImpl::RemoveFace (super::parent_trie &item, Ptr<NdnFace> face)
+FibImpl::RemoveFace (super::parent_trie &item, Ptr<Face> face)
{
if (item.payload () == 0) return;
NS_LOG_FUNCTION (this);
super::modify (&item,
- ll::bind (&NdnFibEntry::RemoveFace, ll::_1, face));
+ ll::bind (&Entry::RemoveFace, ll::_1, face));
}
void
-NdnFibImpl::RemoveFromAll (Ptr<NdnFace> face)
+FibImpl::RemoveFromAll (Ptr<Face> face)
{
NS_LOG_FUNCTION (this);
std::for_each (super::parent_trie::recursive_iterator (super::getTrie ()),
super::parent_trie::recursive_iterator (0),
- ll::bind (&NdnFibImpl::RemoveFace,
+ ll::bind (&FibImpl::RemoveFace,
this, ll::_1, face));
super::parent_trie::recursive_iterator trieNode (super::getTrie ());
@@ -187,7 +189,7 @@
}
void
-NdnFibImpl::Print (std::ostream &os) const
+FibImpl::Print (std::ostream &os) const
{
// !!! unordered_set imposes "random" order of item in the same level !!!
super::parent_trie::const_recursive_iterator item (super::getTrie ());
@@ -201,13 +203,13 @@
}
uint32_t
-NdnFibImpl::GetSize () const
+FibImpl::GetSize () const
{
return super::getPolicy ().size ();
}
-Ptr<const NdnFibEntry>
-NdnFibImpl::Begin ()
+Ptr<const Entry>
+FibImpl::Begin ()
{
super::parent_trie::const_recursive_iterator item (super::getTrie ());
super::parent_trie::const_recursive_iterator end (0);
@@ -223,18 +225,18 @@
return item->payload ();
}
-Ptr<const NdnFibEntry>
-NdnFibImpl::End ()
+Ptr<const Entry>
+FibImpl::End ()
{
return 0;
}
-Ptr<const NdnFibEntry>
-NdnFibImpl::Next (Ptr<const NdnFibEntry> from)
+Ptr<const Entry>
+FibImpl::Next (Ptr<const Entry> from)
{
if (from == 0) return 0;
- super::parent_trie::const_recursive_iterator item (*StaticCast<const NdnFibEntryImpl> (from)->to_iterator ());
+ super::parent_trie::const_recursive_iterator item (*StaticCast<const EntryImpl> (from)->to_iterator ());
super::parent_trie::const_recursive_iterator end (0);
for (item++; item != end; item++)
{
@@ -248,5 +250,6 @@
return item->payload ();
}
-
+} // namespace fib
+} // namespace ndn
} // namespace ns3
diff --git a/model/fib/ndn-fib-impl.h b/model/fib/ndn-fib-impl.h
index 562f06e..4c78997 100644
--- a/model/fib/ndn-fib-impl.h
+++ b/model/fib/ndn-fib-impl.h
@@ -28,18 +28,20 @@
#include "../../utils/counting-policy.h"
namespace ns3 {
+namespace ndn {
+namespace fib {
-class NdnFibEntryImpl : public NdnFibEntry
+class EntryImpl : public Entry
{
public:
typedef ndnSIM::trie_with_policy<
- NdnNameComponents,
- ndnSIM::smart_pointer_payload_traits<NdnFibEntryImpl>,
+ NameComponents,
+ ndnSIM::smart_pointer_payload_traits<EntryImpl>,
ndnSIM::counting_policy_traits
> trie;
- NdnFibEntryImpl (const Ptr<const NdnNameComponents> &prefix)
- : NdnFibEntry (prefix)
+ EntryImpl (const Ptr<const NameComponents> &prefix)
+ : Entry (prefix)
, item_ (0)
{
}
@@ -57,24 +59,19 @@
trie::iterator item_;
};
-struct NdnFibEntryContainer
-{
- typedef ndnSIM::trie_with_policy<
- NdnNameComponents,
- ndnSIM::smart_pointer_payload_traits<NdnFibEntryImpl>,
- ndnSIM::counting_policy_traits
- > type;
-};
-
/**
* \ingroup ndn
* \brief Class implementing FIB functionality
*/
-class NdnFibImpl : public NdnFib,
- private NdnFibEntryContainer::type
+class FibImpl : public Fib,
+ protected ndnSIM::trie_with_policy< NameComponents,
+ ndnSIM::smart_pointer_payload_traits< EntryImpl >,
+ ndnSIM::counting_policy_traits >
{
public:
- typedef NdnFibEntryContainer::type super;
+ typedef ndnSIM::trie_with_policy< NameComponents,
+ ndnSIM::smart_pointer_payload_traits<EntryImpl>,
+ ndnSIM::counting_policy_traits > super;
/**
* \brief Interface ID
@@ -86,25 +83,25 @@
/**
* \brief Constructor
*/
- NdnFibImpl ();
+ FibImpl ();
- virtual Ptr<NdnFibEntry>
- LongestPrefixMatch (const NdnInterestHeader &interest);
+ virtual Ptr<Entry>
+ LongestPrefixMatch (const InterestHeader &interest);
- virtual Ptr<NdnFibEntry>
- Add (const NdnNameComponents &prefix, Ptr<NdnFace> face, int32_t metric);
+ virtual Ptr<Entry>
+ Add (const NameComponents &prefix, Ptr<Face> face, int32_t metric);
- virtual Ptr<NdnFibEntry>
- Add (const Ptr<const NdnNameComponents> &prefix, Ptr<NdnFace> face, int32_t metric);
+ virtual Ptr<Entry>
+ Add (const Ptr<const NameComponents> &prefix, Ptr<Face> face, int32_t metric);
virtual void
- Remove (const Ptr<const NdnNameComponents> &prefix);
+ Remove (const Ptr<const NameComponents> &prefix);
virtual void
InvalidateAll ();
virtual void
- RemoveFromAll (Ptr<NdnFace> face);
+ RemoveFromAll (Ptr<Face> face);
virtual void
Print (std::ostream &os) const;
@@ -112,24 +109,14 @@
virtual uint32_t
GetSize () const;
- virtual Ptr<const NdnFibEntry>
+ virtual Ptr<const Entry>
Begin ();
- virtual Ptr<const NdnFibEntry>
+ virtual Ptr<const Entry>
End ();
- virtual Ptr<const NdnFibEntry>
- Next (Ptr<const NdnFibEntry> item);
-
- // /**
- // * @brief Modify element in container
- // */
- // template<typename Modifier>
- // bool
- // modify (Ptr<NdnFibEntry> item, Modifier mod)
- // {
- // return super::modify (StaticCast<NdnFibEntryImpl> (item)->to_iterator (), mod);
- // }
+ virtual Ptr<const Entry>
+ Next (Ptr<const Entry> item);
protected:
// inherited from Object class
@@ -142,12 +129,14 @@
* entry will be removed
*/
void
- RemoveFace (super::parent_trie &item, Ptr<NdnFace> face);
+ RemoveFace (super::parent_trie &item, Ptr<Face> face);
private:
Ptr<Node> m_node;
};
-
+
+} // namespace fib
+} // namespace ndn
} // namespace ns3
#endif /* _NDN_FIB_IMPL_H_ */
diff --git a/model/fib/ndn-fib.cc b/model/fib/ndn-fib.cc
index 7046634..f63dadf 100644
--- a/model/fib/ndn-fib.cc
+++ b/model/fib/ndn-fib.cc
@@ -20,36 +20,24 @@
#include "ndn-fib.h"
-#include "ndn-fib-impl.h"
-
-#include "ns3/ndn.h"
-#include "ns3/ndn-face.h"
-#include "ns3/ndn-interest-header.h"
-#include "ns3/ndn-name-components.h"
-
#include "ns3/node.h"
#include "ns3/names.h"
-#include <boost/ref.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-namespace ll = boost::lambda;
-
namespace ns3 {
-
-using namespace __ndn_private;
+namespace ndn {
TypeId
-NdnFib::GetTypeId (void)
+Fib::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::private::NdnFib") // cheating ns3 object system
+ static TypeId tid = TypeId ("ns3::ndn::Fib") // cheating ns3 object system
.SetParent<Object> ()
.SetGroupName ("Ndn")
;
return tid;
}
-std::ostream& operator<< (std::ostream& os, const NdnFib &fib)
+std::ostream&
+operator<< (std::ostream& os, const Fib &fib)
{
os << "Node " << Names::FindName (fib.GetObject<Node>()) << "\n";
os << " Dest prefix Interfaces(Costs) \n";
@@ -59,4 +47,5 @@
return os;
}
+} // namespace ndn
} // namespace ns3
diff --git a/model/fib/ndn-fib.h b/model/fib/ndn-fib.h
index 12a6148..b1b4be7 100644
--- a/model/fib/ndn-fib.h
+++ b/model/fib/ndn-fib.h
@@ -27,14 +27,15 @@
#include "ns3/ndn-fib-entry.h"
namespace ns3 {
+namespace ndn {
-class NdnInterestHeader;
+class InterestHeader;
/**
* \ingroup ndn
* \brief Class implementing FIB functionality
*/
-class NdnFib : public Object
+class Fib : public Object
{
public:
/**
@@ -46,12 +47,12 @@
/**
* @brief Default constructor
*/
- NdnFib () {}
+ Fib () {}
/**
* @brief Virtual destructor
*/
- virtual ~NdnFib () { };
+ virtual ~Fib () { };
/**
* \brief Perform longest prefix match
@@ -61,8 +62,8 @@
* \param interest Interest packet header
* \returns If entry found a valid iterator will be returned, otherwise end ()
*/
- virtual Ptr<NdnFibEntry>
- LongestPrefixMatch (const NdnInterestHeader &interest) = 0;
+ virtual Ptr<fib::Entry>
+ LongestPrefixMatch (const InterestHeader &interest) = 0;
/**
* \brief Add or update FIB entry
@@ -75,8 +76,8 @@
* @param face Forwarding face
* @param metric Routing metric
*/
- virtual Ptr<NdnFibEntry>
- Add (const NdnNameComponents &prefix, Ptr<NdnFace> face, int32_t metric) = 0;
+ virtual Ptr<fib::Entry>
+ Add (const NameComponents &prefix, Ptr<Face> face, int32_t metric) = 0;
/**
* \brief Add or update FIB entry using smart pointer to prefix
@@ -89,8 +90,8 @@
* @param face Forwarding face
* @param metric Routing metric
*/
- virtual Ptr<NdnFibEntry>
- Add (const Ptr<const NdnNameComponents> &prefix, Ptr<NdnFace> face, int32_t metric) = 0;
+ virtual Ptr<fib::Entry>
+ Add (const Ptr<const NameComponents> &prefix, Ptr<Face> face, int32_t metric) = 0;
/**
* @brief Remove FIB entry
@@ -101,7 +102,7 @@
* @param name Smart pointer to prefix
*/
virtual void
- Remove (const Ptr<const NdnNameComponents> &prefix) = 0;
+ Remove (const Ptr<const NameComponents> &prefix) = 0;
// /**
// * @brief Invalidate FIB entry ("Safe" version of Remove)
@@ -110,7 +111,7 @@
// * @param name Smart pointer to prefix
// */
// virtual void
- // Invalidate (const Ptr<const NdnNameComponents> &prefix) = 0;
+ // Invalidate (const Ptr<const NameComponents> &prefix) = 0;
/**
* @brief Invalidate all FIB entries
@@ -123,7 +124,7 @@
* this FIB entry will be removed.
*/
virtual void
- RemoveFromAll (Ptr<NdnFace> face) = 0;
+ RemoveFromAll (Ptr<Face> face) = 0;
/**
* @brief Print out entries in FIB
@@ -140,20 +141,20 @@
/**
* @brief Return first element of FIB (no order guaranteed)
*/
- virtual Ptr<const NdnFibEntry>
+ virtual Ptr<const fib::Entry>
Begin () = 0;
/**
* @brief Return item next after last (no order guaranteed)
*/
- virtual Ptr<const NdnFibEntry>
+ virtual Ptr<const fib::Entry>
End () = 0;
/**
* @brief Advance the iterator
*/
- virtual Ptr<const NdnFibEntry>
- Next (Ptr<const NdnFibEntry>) = 0;
+ virtual Ptr<const fib::Entry>
+ Next (Ptr<const fib::Entry>) = 0;
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
@@ -162,28 +163,29 @@
/**
* @brief Static call to cheat python bindings
*/
- static inline Ptr<NdnFib>
- GetNdnFib (Ptr<Object> node);
+ static inline Ptr<Fib>
+ GetFib (Ptr<Object> node);
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
private:
- NdnFib(const NdnFib&) {} ; ///< \brief copy constructor is disabled
+ Fib (const Fib&) {} ; ///< \brief copy constructor is disabled
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-std::ostream& operator<< (std::ostream& os, const NdnFib &fib);
+std::ostream& operator<< (std::ostream& os, const Fib &fib);
-Ptr<NdnFib>
-NdnFib::GetNdnFib (Ptr<Object> node)
+Ptr<Fib>
+Fib::GetFib (Ptr<Object> node)
{
- return node->GetObject<NdnFib> ();
+ return node->GetObject<Fib> ();
}
+} // namespace ndn
} // namespace ns3
#endif // _NDN_FIB_H_