NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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 "common.hpp"
30 #include "table/fib-entry.hpp"
31 #include "table/pit-entry.hpp"
34 
35 namespace nfd {
36 
37 class NameTree;
38 
39 namespace name_tree {
40 
41 // Forward declarations
42 class Node;
43 class Entry;
44 
48 class Node
49 {
50 public:
51  Node();
52 
53  ~Node();
54 
55 public:
56  // variables are in public as this is just a data structure
57  shared_ptr<Entry> m_entry; // Name Tree Entry (i.e., Name Prefix Entry)
58  Node* m_prev; // Previous Name Tree Node (to resolve hash collision)
59  Node* m_next; // Next Name Tree Node (to resolve hash collision)
60 };
61 
65 class Entry : public enable_shared_from_this<Entry>, noncopyable
66 {
67 public:
68  explicit
69  Entry(const Name& prefix);
70 
71  ~Entry();
72 
73  const Name&
74  getPrefix() const;
75 
76  void
77  setHash(size_t hash);
78 
79  size_t
80  getHash() const;
81 
82  void
83  setParent(shared_ptr<Entry> parent);
84 
85  shared_ptr<Entry>
86  getParent() const;
87 
88  std::vector<shared_ptr<Entry> >&
89  getChildren();
90 
91  bool
92  hasChildren() const;
93 
94  bool
95  isEmpty() const;
96 
97 public: // attached table entries
98  void
99  setFibEntry(shared_ptr<fib::Entry> fibEntry);
100 
101  shared_ptr<fib::Entry>
102  getFibEntry() const;
103 
104  void
105  insertPitEntry(shared_ptr<pit::Entry> pitEntry);
106 
107  void
108  erasePitEntry(shared_ptr<pit::Entry> pitEntry);
109 
110  bool
111  hasPitEntries() const;
112 
113  const std::vector<shared_ptr<pit::Entry> >&
114  getPitEntries() const;
115 
116  void
117  setMeasurementsEntry(shared_ptr<measurements::Entry> measurementsEntry);
118 
119  shared_ptr<measurements::Entry>
120  getMeasurementsEntry() const;
121 
122  void
123  setStrategyChoiceEntry(shared_ptr<strategy_choice::Entry> strategyChoiceEntry);
124 
125  shared_ptr<strategy_choice::Entry>
126  getStrategyChoiceEntry() const;
127 
128 private:
129  // Benefits of storing m_hash
130  // 1. m_hash is compared before m_prefix is compared
131  // 2. fast hash table resize support
132  size_t m_hash;
133  Name m_prefix;
134  shared_ptr<Entry> m_parent; // Pointing to the parent entry.
135  std::vector<shared_ptr<Entry> > m_children; // Children pointers.
136  shared_ptr<fib::Entry> m_fibEntry;
137  std::vector<shared_ptr<pit::Entry> > m_pitEntries;
138  shared_ptr<measurements::Entry> m_measurementsEntry;
139  shared_ptr<strategy_choice::Entry> m_strategyChoiceEntry;
140 
141  // get the Name Tree Node that is associated with this Name Tree Entry
142  Node* m_node;
143 
144  // Make private members accessible by Name Tree
145  friend class nfd::NameTree;
146 };
147 
148 inline const Name&
150 {
151  return m_prefix;
152 }
153 
154 inline size_t
156 {
157  return m_hash;
158 }
159 
160 inline void
161 Entry::setHash(size_t hash)
162 {
163  m_hash = hash;
164 }
165 
166 inline shared_ptr<Entry>
168 {
169  return m_parent;
170 }
171 
172 inline void
173 Entry::setParent(shared_ptr<Entry> parent)
174 {
175  m_parent = parent;
176 }
177 
178 inline std::vector<shared_ptr<name_tree::Entry> >&
180 {
181  return m_children;
182 }
183 
184 inline bool
186 {
187  return !m_children.empty();
188 }
189 
190 inline shared_ptr<fib::Entry>
192 {
193  return m_fibEntry;
194 }
195 
196 inline bool
198 {
199  return !m_pitEntries.empty();
200 }
201 
202 inline const std::vector<shared_ptr<pit::Entry> >&
204 {
205  return m_pitEntries;
206 }
207 
208 inline shared_ptr<measurements::Entry>
210 {
211  return m_measurementsEntry;
212 }
213 
214 inline shared_ptr<strategy_choice::Entry>
216 {
217  return m_strategyChoiceEntry;
218 }
219 
220 } // namespace name_tree
221 } // namespace nfd
222 
223 #endif // NFD_DAEMON_TABLE_NAME_TREE_ENTRY_HPP
Name Tree Node Class.
shared_ptr< Entry > m_entry
const std::vector< shared_ptr< pit::Entry > > & getPitEntries() const
shared_ptr< Entry > getParent() const
void setParent(shared_ptr< Entry > parent)
void setHash(size_t hash)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
Class Name Tree.
Definition: name-tree.hpp:79
shared_ptr< strategy_choice::Entry > getStrategyChoiceEntry() const
Name abstraction to represent an absolute name.
Definition: name.hpp:46
const Name & getPrefix() const
NameTree
Definition: name-tree.cpp:36
std::vector< shared_ptr< Entry > > & getChildren()
shared_ptr< measurements::Entry > getMeasurementsEntry() const
Name Tree Entry Class.
shared_ptr< fib::Entry > getFibEntry() const