NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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 unique_ptr<Strategy>
34 {
35  return make_unique<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
bool hasStrategy(const Name &strategyName, bool isExact=false) const
determines if a strategy is installed
unique_ptr< Strategy > makeDefaultStrategy(Forwarder &forwarder)
void registerStrategyImpl(const Name &strategyName, const StrategyCreateFunc &createFunc)
void installStrategies(Forwarder &forwarder)
main class of NFD
Definition: forwarder.hpp:54
StrategyChoice & getStrategyChoice()
Definition: forwarder.hpp:161
std::pair< bool, fw::Strategy * > install(unique_ptr< fw::Strategy > strategy)
install a strategy
std::function< unique_ptr< Strategy >Forwarder &)> StrategyCreateFunc
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
static std::map< Name, StrategyCreateFunc > & getStrategyFactories()
Name abstraction to represent an absolute name.
Definition: name.hpp:46
represents the Strategy Choice table