NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
strategy-registry.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_FW_STRATEGY_REGISTRY_HPP
27 #define NFD_DAEMON_FW_STRATEGY_REGISTRY_HPP
28 
29 #include "common.hpp"
30 
31 namespace nfd {
32 
33 class Forwarder;
34 
35 namespace fw {
36 
37 class Strategy;
38 
39 shared_ptr<Strategy>
40 makeDefaultStrategy(Forwarder& forwarder);
41 
42 void
43 installStrategies(Forwarder& forwarder);
44 
45 
46 typedef std::function<shared_ptr<Strategy>(Forwarder&)> StrategyCreateFunc;
47 
48 void
49 registerStrategyImpl(const Name& strategyName, const StrategyCreateFunc& createFunc);
50 
53 template<typename S>
54 void
56 {
57  registerStrategyImpl(S::STRATEGY_NAME,
58  [] (Forwarder& forwarder) { return make_shared<S>(ref(forwarder)); });
59 }
60 
65 #define NFD_REGISTER_STRATEGY(StrategyType) \
66 static class NfdAuto ## StrategyType ## StrategyRegistrationClass \
67 { \
68 public: \
69  NfdAuto ## StrategyType ## StrategyRegistrationClass() \
70  { \
71  ::nfd::fw::registerStrategy<StrategyType>(); \
72  } \
73 } g_nfdAuto ## StrategyType ## StrategyRegistrationVariable
74 
75 } // namespace fw
76 } // namespace nfd
77 
78 #endif // NFD_DAEMON_FW_STRATEGY_REGISTRY_HPP
void registerStrategyImpl(const Name &strategyName, const StrategyCreateFunc &createFunc)
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:40
Name abstraction to represent an absolute name.
Definition: name.hpp:46
Forwarder
Definition: forwarder.cpp:38
void registerStrategy()
registers a strategy to be installed later