Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "best-route-strategy.hpp" |
| 8 | #include "broadcast-strategy.hpp" |
| 9 | #include "client-control-strategy.hpp" |
| 10 | #include "ncc-strategy.hpp" |
| 11 | |
| 12 | namespace nfd { |
| 13 | namespace fw { |
| 14 | |
| 15 | shared_ptr<Strategy> |
| 16 | makeDefaultStrategy(Forwarder& forwarder) |
| 17 | { |
| 18 | return make_shared<BestRouteStrategy>(boost::ref(forwarder)); |
| 19 | } |
| 20 | |
| 21 | template<typename S> |
| 22 | inline void |
| 23 | installStrategy(Forwarder& forwarder) |
| 24 | { |
| 25 | StrategyChoice& strategyChoice = forwarder.getStrategyChoice(); |
| 26 | if (!strategyChoice.hasStrategy(S::STRATEGY_NAME)) { |
| 27 | strategyChoice.install(make_shared<S>(boost::ref(forwarder))); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | void |
| 32 | installStrategies(Forwarder& forwarder) |
| 33 | { |
| 34 | installStrategy<BestRouteStrategy>(forwarder); |
| 35 | installStrategy<BroadcastStrategy>(forwarder); |
| 36 | installStrategy<ClientControlStrategy>(forwarder); |
| 37 | installStrategy<NccStrategy>(forwarder); |
| 38 | } |
| 39 | |
| 40 | } // namespace fw |
| 41 | } // namespace nfd |