NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
name-tree-entry.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_TABLE_NAME_TREE_ENTRY_HPP
27 #define NFD_DAEMON_TABLE_NAME_TREE_ENTRY_HPP
28 
29 #include "table/fib-entry.hpp"
30 #include "table/pit-entry.hpp"
33 
34 namespace nfd {
35 namespace name_tree {
36 
37 class Node;
38 
41 class Entry : noncopyable
42 {
43 public:
44  Entry(const Name& prefix, Node* node);
45 
46  const Name&
47  getName() const
48  {
49  return m_name;
50  }
51 
55  Entry*
56  getParent() const
57  {
58  return m_parent;
59  }
60 
67  void
68  setParent(Entry& entry);
69 
74  void
75  unsetParent();
76 
80  bool
81  hasChildren() const
82  {
83  return !this->getChildren().empty();
84  }
85 
88  const std::vector<Entry*>&
89  getChildren() const
90  {
91  return m_children;
92  }
93 
97  bool
98  isEmpty() const
99  {
100  return !this->hasChildren() && !this->hasTableEntries();
101  }
102 
103 public: // attached table entries
107  bool
108  hasTableEntries() const;
109 
110  fib::Entry*
111  getFibEntry() const
112  {
113  return m_fibEntry.get();
114  }
115 
116  void
117  setFibEntry(unique_ptr<fib::Entry> fibEntry);
118 
119  bool
121  {
122  return !this->getPitEntries().empty();
123  }
124 
125  const std::vector<shared_ptr<pit::Entry>>&
127  {
128  return m_pitEntries;
129  }
130 
131  void
132  insertPitEntry(shared_ptr<pit::Entry> pitEntry);
133 
134  void
135  erasePitEntry(pit::Entry* pitEntry);
136 
139  {
140  return m_measurementsEntry.get();
141  }
142 
143  void
144  setMeasurementsEntry(unique_ptr<measurements::Entry> measurementsEntry);
145 
148  {
149  return m_strategyChoiceEntry.get();
150  }
151 
152  void
153  setStrategyChoiceEntry(unique_ptr<strategy_choice::Entry> strategyChoiceEntry);
154 
160  template<typename ENTRY>
161  static Entry*
162  get(const ENTRY& tableEntry)
163  {
164  return tableEntry.m_nameTreeEntry;
165  }
166 
167 private:
168  Name m_name;
169  Node* m_node;
170  Entry* m_parent;
171  std::vector<Entry*> m_children;
172 
173  unique_ptr<fib::Entry> m_fibEntry;
174  std::vector<shared_ptr<pit::Entry>> m_pitEntries;
175  unique_ptr<measurements::Entry> m_measurementsEntry;
176  unique_ptr<strategy_choice::Entry> m_strategyChoiceEntry;
177 
178  friend Node* getNode(const Entry& entry);
179 };
180 
184 template<typename ENTRY>
186 {
187 public:
190  using Getter = ENTRY* (Entry::*)() const;
191 
195  explicit
196  GetTableEntry(Getter getter = nullptr)
197  : m_getter(getter)
198  {
199  }
200 
201  const ENTRY&
202  operator()(const Entry& nte) const
203  {
204  return *(nte.*m_getter)();
205  }
206 
207 private:
208  Getter m_getter;
209 };
210 
211 } // namespace name_tree
212 } // namespace nfd
213 
214 #endif // NFD_DAEMON_TABLE_NAME_TREE_ENTRY_HPP
void insertPitEntry(shared_ptr< pit::Entry > pitEntry)
friend Node * getNode(const Entry &entry)
const std::vector< shared_ptr< pit::Entry > > & getPitEntries() const
represents a FIB entry
Definition: fib-entry.hpp:51
fib::Entry * getFibEntry() const
void erasePitEntry(pit::Entry *pitEntry)
Entry(const Name &prefix, Node *node)
const std::vector< Entry * > & getChildren() const
void setParent(Entry &entry)
set parent of this entry
void setMeasurementsEntry(unique_ptr< measurements::Entry > measurementsEntry)
represents a Measurements entry
measurements::Entry * getMeasurementsEntry() const
bool hasTableEntries() const
ENTRY *(Entry::*)() const Getter
a function pointer to the getter on Entry class that returns ENTRY
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
an Interest table entry
Definition: pit-entry.hpp:59
static Entry * get(const ENTRY &tableEntry)
Represents an absolute name.
Definition: name.hpp:43
represents a Strategy Choice entry
const ENTRY & operator()(const Entry &nte) const
void unsetParent()
unset parent of this entry
strategy_choice::Entry * getStrategyChoiceEntry() const
Entry * getParent() const
GetTableEntry(Getter getter=nullptr)
a functor to get a table entry from a name tree entry
const Name & getName() const
void setFibEntry(unique_ptr< fib::Entry > fibEntry)
void setStrategyChoiceEntry(unique_ptr< strategy_choice::Entry > strategyChoiceEntry)
an entry in the name tree