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
56  bool
57  hasStrategy(const Name& strategyName, bool isExact = false) const;
58 
63  bool
64  install(shared_ptr<fw::Strategy> strategy);
65 
66 public: // Strategy Choice table
77  bool
78  insert(const Name& prefix, const Name& strategyName);
79 
84  void
85  erase(const Name& prefix);
86 
90  std::pair<bool, Name>
91  get(const Name& prefix) const;
92 
93 public: // effective strategy
96  findEffectiveStrategy(const Name& prefix) const;
97 
100  findEffectiveStrategy(const pit::Entry& pitEntry) const;
101 
103  fw::Strategy&
104  findEffectiveStrategy(const measurements::Entry& measurementsEntry) const;
105 
106 public: // enumeration
108  : public std::iterator<std::forward_iterator_tag, const strategy_choice::Entry>
109  {
110  public:
111  explicit
113 
114  ~const_iterator();
115 
117  operator*() const;
118 
119  shared_ptr<strategy_choice::Entry>
120  operator->() const;
121 
123  operator++();
124 
126  operator++(int);
127 
128  bool
129  operator==(const const_iterator& other) const;
130 
131  bool
132  operator!=(const const_iterator& other) const;
133 
134  private:
135  NameTree::const_iterator m_nameTreeIterator;
136  };
137 
139  size_t
140  size() const;
141 
143  begin() const;
144 
146  end() const;
147 
148 private:
152  fw::Strategy*
153  getStrategy(const Name& strategyName) const;
154 
155  void
156  setDefaultStrategy(shared_ptr<fw::Strategy> strategy);
157 
158  void
159  changeStrategy(strategy_choice::Entry& entry,
160  fw::Strategy& oldStrategy,
161  fw::Strategy& newStrategy);
162 
163  fw::Strategy&
164  findEffectiveStrategy(shared_ptr<name_tree::Entry> nte) const;
165 
166 private:
167  NameTree& m_nameTree;
168  size_t m_nItems;
169 
170  typedef std::map<Name, shared_ptr<fw::Strategy> > StrategyInstanceTable;
171  StrategyInstanceTable m_strategyInstances;
172 };
173 
174 inline size_t
176 {
177  return m_nItems;
178 }
179 
182 {
183  return const_iterator(m_nameTree.end());
184 }
185 
186 inline
188  : m_nameTreeIterator(it)
189 {
190 }
191 
192 inline
194 {
195 }
196 
197 inline
200 {
201  StrategyChoice::const_iterator temp(*this);
202  ++(*this);
203  return temp;
204 }
205 
208 {
209  ++m_nameTreeIterator;
210  return *this;
211 }
212 
213 inline const strategy_choice::Entry&
215 {
216  return *(m_nameTreeIterator->getStrategyChoiceEntry());
217 }
218 
219 inline shared_ptr<strategy_choice::Entry>
221 {
222  return m_nameTreeIterator->getStrategyChoiceEntry();
223 }
224 
225 inline bool
227 {
228  return m_nameTreeIterator == other.m_nameTreeIterator;
229 }
230 
231 inline bool
233 {
234  return m_nameTreeIterator != other.m_nameTreeIterator;
235 }
236 
237 } // namespace nfd
238 
239 #endif // NFD_DAEMON_TABLE_STRATEGY_CHOICE_HPP
fw::Strategy & findEffectiveStrategy(const Name &prefix) const
get effective strategy for prefix
represents the Strategy Choice table
bool hasStrategy(const Name &strategyName, bool isExact=false) const
determines if a strategy is installed
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
bool operator!=(const const_iterator &other) const
represents a Measurements entry
Table::const_iterator iterator
Definition: cs-internal.hpp:41
shared_ptr< strategy_choice::Entry > operator->() const
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
represents a PIT entry
Definition: pit-entry.hpp:69
void erase(const Name &prefix)
make prefix to inherit strategy from its parent
Class Name Tree.
Definition: name-tree.hpp:79
const_iterator end() const
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
const_iterator begin() const
represents a forwarding strategy
Definition: strategy.hpp:38
const_iterator(const NameTree::const_iterator &it)
size_t size() const
number of entries stored
const strategy_choice::Entry & operator*() const