NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
strategy-registry.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #include "strategy-registry.hpp"
27 #include "best-route-strategy2.hpp"
28 
29 namespace nfd {
30 namespace fw {
31 
32 shared_ptr<Strategy>
34 {
35  return make_shared<BestRouteStrategy2>(ref(forwarder));
36 }
37 
38 static std::map<Name, StrategyCreateFunc>&
40 {
41  static std::map<Name, StrategyCreateFunc> strategyFactories;
42  return strategyFactories;
43 }
44 
45 void
46 registerStrategyImpl(const Name& strategyName, const StrategyCreateFunc& createFunc)
47 {
48  getStrategyFactories().insert({strategyName, createFunc});
49 }
50 
51 void
53 {
54  StrategyChoice& sc = forwarder.getStrategyChoice();
55  for (const auto& pair : getStrategyFactories()) {
56  if (!sc.hasStrategy(pair.first, true)) {
57  sc.install(pair.second(forwarder));
58  }
59  }
60 }
61 
62 } // namespace fw
63 } // namespace nfd
represents the Strategy Choice table
void registerStrategyImpl(const Name &strategyName, const StrategyCreateFunc &createFunc)
StrategyChoice & getStrategyChoice()
Definition: forwarder.hpp:308
void installStrategies(Forwarder &forwarder)
main class of NFD
Definition: forwarder.hpp:54
shared_ptr< Strategy > makeDefaultStrategy(Forwarder &forwarder)
std::function< shared_ptr< Strategy >Forwarder &)> StrategyCreateFunc
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
static std::map< Name, StrategyCreateFunc > & getStrategyFactories()
Name abstraction to represent an absolute name.
Definition: name.hpp:46
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