NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
strategy-choice.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_TABLE_STRATEGY_CHOICE_HPP
27 #define NFD_DAEMON_TABLE_STRATEGY_CHOICE_HPP
28 
30 #include "name-tree.hpp"
31 
32 namespace nfd {
33 
45 class StrategyChoice : noncopyable
46 {
47 public:
48  StrategyChoice(NameTree& nameTree, shared_ptr<fw::Strategy> defaultStrategy);
49 
50 public: // available Strategy types
55  bool
56  hasStrategy(const Name& strategyName, bool isExact = false) const;
57 
62  bool
63  install(shared_ptr<fw::Strategy> strategy);
64 
65 public: // Strategy Choice table
75  bool
76  insert(const Name& prefix, const Name& strategyName);
77 
82  void
83  erase(const Name& prefix);
84 
88  std::pair<bool, Name>
89  get(const Name& prefix) const;
90 
91 public: // effective strategy
94  findEffectiveStrategy(const Name& prefix) const;
95 
98  findEffectiveStrategy(const pit::Entry& pitEntry) const;
99 
101  fw::Strategy&
102  findEffectiveStrategy(const measurements::Entry& measurementsEntry) const;
103 
104 public: // enumeration
106  : public std::iterator<std::forward_iterator_tag, const strategy_choice::Entry>
107  {
108  public:
109  explicit
111 
112  ~const_iterator();
113 
115  operator*() const;
116 
117  shared_ptr<strategy_choice::Entry>
118  operator->() const;
119 
121  operator++();
122 
124  operator++(int);
125 
126  bool
127  operator==(const const_iterator& other) const;
128 
129  bool
130  operator!=(const const_iterator& other) const;
131 
132  private:
133  NameTree::const_iterator m_nameTreeIterator;
134  };
135 
137  size_t
138  size() const;
139 
141  begin() const;
142 
144  end() const;
145 
146 private:
150  fw::Strategy*
151  getStrategy(const Name& strategyName) const;
152 
153  void
154  setDefaultStrategy(shared_ptr<fw::Strategy> strategy);
155 
156  void
157  changeStrategy(strategy_choice::Entry& entry,
158  fw::Strategy& oldStrategy,
159  fw::Strategy& newStrategy);
160 
161  fw::Strategy&
162  findEffectiveStrategy(shared_ptr<name_tree::Entry> nte) const;
163 
164 private:
165  NameTree& m_nameTree;
166  size_t m_nItems;
167 
168  typedef std::map<Name, shared_ptr<fw::Strategy> > StrategyInstanceTable;
169  StrategyInstanceTable m_strategyInstances;
170 };
171 
172 inline size_t
174 {
175  return m_nItems;
176 }
177 
180 {
181  return const_iterator(m_nameTree.end());
182 }
183 
184 inline
186  : m_nameTreeIterator(it)
187 {
188 }
189 
190 inline
192 {
193 }
194 
195 inline
198 {
199  StrategyChoice::const_iterator temp(*this);
200  ++(*this);
201  return temp;
202 }
203 
206 {
207  ++m_nameTreeIterator;
208  return *this;
209 }
210 
211 inline const strategy_choice::Entry&
213 {
214  return *(m_nameTreeIterator->getStrategyChoiceEntry());
215 }
216 
217 inline shared_ptr<strategy_choice::Entry>
219 {
220  return m_nameTreeIterator->getStrategyChoiceEntry();
221 }
222 
223 inline bool
225 {
226  return m_nameTreeIterator == other.m_nameTreeIterator;
227 }
228 
229 inline bool
231 {
232  return m_nameTreeIterator != other.m_nameTreeIterator;
233 }
234 
235 } // namespace nfd
236 
237 #endif // NFD_DAEMON_TABLE_STRATEGY_CHOICE_HPP
size_t size() const
number of entries stored
fw::Strategy & findEffectiveStrategy(const Name &prefix) const
get effective strategy for prefix
represents the Strategy Choice table
const strategy_choice::Entry & operator*() const
StrategyChoice(NameTree &nameTree, shared_ptr< fw::Strategy > defaultStrategy)
bool insert(const Name &prefix, const Name &strategyName)
set strategy of prefix to be strategyName
bool operator==(const const_iterator &other) const
represents a Measurements entry
Table::const_iterator iterator
Definition: cs-internal.hpp:41
bool operator!=(const const_iterator &other) const
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
represents a PIT entry
Definition: pit-entry.hpp:67
void erase(const Name &prefix)
make prefix to inherit strategy from its parent
Class Name Tree.
Definition: name-tree.hpp:79
Name abstraction to represent an absolute name.
Definition: name.hpp:46
represents a Strategy Choice entry
bool install(shared_ptr< fw::Strategy > strategy)
install a strategy
bool hasStrategy(const Name &strategyName, bool isExact=false) const
determines if a strategy is installed
const_iterator begin() const
represents a forwarding strategy
Definition: strategy.hpp:38
const_iterator end() const
const_iterator(const NameTree::const_iterator &it)
shared_ptr< strategy_choice::Entry > operator->() const