table: StrategyChoice uses unique_ptr instead of shared_ptr

refs #3164

Change-Id: Id3110f72aab83982b0768e596a04bad9f7336975
diff --git a/tests/daemon/fw/ncc-strategy.t.cpp b/tests/daemon/fw/ncc-strategy.t.cpp
index b624c74..251e3d6 100644
--- a/tests/daemon/fw/ncc-strategy.t.cpp
+++ b/tests/daemon/fw/ncc-strategy.t.cpp
@@ -50,9 +50,8 @@
 {
   LimitedIo limitedIo(this);
   Forwarder forwarder;
-  typedef StrategyTester<NccStrategy> NccStrategyTester;
-  shared_ptr<NccStrategyTester> strategy = make_shared<NccStrategyTester>(ref(forwarder));
-  strategy->afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
+  StrategyTester<NccStrategy>& strategy = choose<StrategyTester<NccStrategy>>(forwarder);
+  strategy.afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
 
   shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
   shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
@@ -66,10 +65,6 @@
   fibEntry.addNextHop(*face1, 10);
   fibEntry.addNextHop(*face2, 20);
 
-  StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
-  strategyChoice.install(strategy);
-  strategyChoice.insert(Name(), strategy->getName());
-
   Pit& pit = forwarder.getPit();
 
   // first Interest: strategy knows nothing and follows routing
@@ -79,22 +74,22 @@
   shared_ptr<pit::Entry> pitEntry1 = pit.insert(interest1).first;
 
   pitEntry1->insertOrUpdateInRecord(face3, interest1);
-  strategy->afterReceiveInterest(*face3, interest1, pitEntry1);
+  strategy.afterReceiveInterest(*face3, interest1, pitEntry1);
 
   // forwards to face1 because routing says it's best
   // (no io run here: afterReceiveInterest has already sent the Interest)
-  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[0].outFaceId, face1->getId());
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId());
 
   // forwards to face2 because face1 doesn't respond
   limitedIo.run(1, time::milliseconds(500), time::milliseconds(10));
-  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 2);
-  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[1].outFaceId, face2->getId());
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 2);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face2->getId());
 
   // face2 responds
   shared_ptr<Data> data1p = makeData("ndn:/0Jm1ajrW/%00");
   Data& data1 = *data1p;
-  strategy->beforeSatisfyInterest(pitEntry1, *face2, data1);
+  strategy.beforeSatisfyInterest(pitEntry1, *face2, data1);
   this->advanceClocks(time::milliseconds(10), time::milliseconds(500));
 
   // second Interest: strategy knows face2 is best
@@ -104,19 +99,18 @@
   shared_ptr<pit::Entry> pitEntry2 = pit.insert(interest2).first;
 
   pitEntry2->insertOrUpdateInRecord(face3, interest2);
-  strategy->afterReceiveInterest(*face3, interest2, pitEntry2);
+  strategy.afterReceiveInterest(*face3, interest2, pitEntry2);
 
   // forwards to face2 because it responds previously
   this->advanceClocks(time::milliseconds(1));
-  BOOST_REQUIRE_GE(strategy->sendInterestHistory.size(), 3);
-  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[2].outFaceId, face2->getId());
+  BOOST_REQUIRE_GE(strategy.sendInterestHistory.size(), 3);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[2].outFaceId, face2->getId());
 }
 
 BOOST_AUTO_TEST_CASE(Bug1853)
 {
   Forwarder forwarder;
-  typedef StrategyTester<NccStrategy> NccStrategyTester;
-  shared_ptr<NccStrategyTester> strategy = make_shared<NccStrategyTester>(ref(forwarder));
+  StrategyTester<NccStrategy>& strategy = choose<StrategyTester<NccStrategy>>(forwarder);
 
   shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
   shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
@@ -129,10 +123,6 @@
   fib::Entry& fibEntry = *fib.insert(Name()).first;
   fibEntry.addNextHop(*face1, 10);
 
-  StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
-  strategyChoice.install(strategy);
-  strategyChoice.insert(Name(), strategy->getName());
-
   Pit& pit = forwarder.getPit();
 
   // first Interest: strategy follows routing and forwards to face1
@@ -141,15 +131,15 @@
   shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
 
   pitEntry1->insertOrUpdateInRecord(face3, *interest1);
-  strategy->afterReceiveInterest(*face3, *interest1, pitEntry1);
+  strategy.afterReceiveInterest(*face3, *interest1, pitEntry1);
 
   this->advanceClocks(time::milliseconds(1));
-  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[0].outFaceId, face1->getId());
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId());
 
   // face1 responds
   shared_ptr<Data> data1 = makeData("ndn:/nztwIvHX/%00");
-  strategy->beforeSatisfyInterest(pitEntry1, *face1, *data1);
+  strategy.beforeSatisfyInterest(pitEntry1, *face1, *data1);
   this->advanceClocks(time::milliseconds(10), time::milliseconds(500));
 
   // second Interest: bestFace is face1, nUpstreams becomes 0,
@@ -159,7 +149,7 @@
   shared_ptr<pit::Entry> pitEntry2 = pit.insert(*interest2).first;
 
   pitEntry2->insertOrUpdateInRecord(face3, *interest2);
-  strategy->afterReceiveInterest(*face3, *interest2, pitEntry2);
+  strategy.afterReceiveInterest(*face3, *interest2, pitEntry2);
 
   // FIB entry is changed before doPropagate executes
   fibEntry.addNextHop(*face2, 20);
@@ -170,9 +160,8 @@
 {
   LimitedIo limitedIo(this);
   Forwarder forwarder;
-  typedef StrategyTester<NccStrategy> NccStrategyTester;
-  shared_ptr<NccStrategyTester> strategy = make_shared<NccStrategyTester>(ref(forwarder));
-  strategy->afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
+  StrategyTester<NccStrategy>& strategy = choose<StrategyTester<NccStrategy>>(forwarder);
+  strategy.afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
 
   shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
   shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
@@ -186,10 +175,6 @@
   fibEntry.addNextHop(*face1, 10);
   fibEntry.addNextHop(*face2, 20);
 
-  StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
-  strategyChoice.install(strategy);
-  strategyChoice.insert(Name(), strategy->getName());
-
   Pit& pit = forwarder.getPit();
 
   // first Interest: strategy forwards to face1 and face2
@@ -198,20 +183,20 @@
   shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
 
   pitEntry1->insertOrUpdateInRecord(face3, *interest1);
-  strategy->afterReceiveInterest(*face3, *interest1, pitEntry1);
-  limitedIo.run(2 - strategy->sendInterestHistory.size(),
+  strategy.afterReceiveInterest(*face3, *interest1, pitEntry1);
+  limitedIo.run(2 - strategy.sendInterestHistory.size(),
                 time::milliseconds(2000), time::milliseconds(10));
-  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 2);
-  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[0].outFaceId, face1->getId());
-  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[1].outFaceId, face2->getId());
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 2);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId());
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face2->getId());
 
   // face1 responds
   shared_ptr<Data> data1 = makeData("ndn:/seRMz5a6/%00");
-  strategy->beforeSatisfyInterest(pitEntry1, *face1, *data1);
+  strategy.beforeSatisfyInterest(pitEntry1, *face1, *data1);
   pitEntry1->clearInRecords();
   this->advanceClocks(time::milliseconds(10));
   // face2 also responds
-  strategy->beforeSatisfyInterest(pitEntry1, *face2, *data1);
+  strategy.beforeSatisfyInterest(pitEntry1, *face2, *data1);
   this->advanceClocks(time::milliseconds(10));
 
   // second Interest: bestFace should be face 1
@@ -220,21 +205,20 @@
   shared_ptr<pit::Entry> pitEntry2 = pit.insert(*interest2).first;
 
   pitEntry2->insertOrUpdateInRecord(face3, *interest2);
-  strategy->afterReceiveInterest(*face3, *interest2, pitEntry2);
-  limitedIo.run(3 - strategy->sendInterestHistory.size(),
+  strategy.afterReceiveInterest(*face3, *interest2, pitEntry2);
+  limitedIo.run(3 - strategy.sendInterestHistory.size(),
                 time::milliseconds(2000), time::milliseconds(10));
 
-  BOOST_REQUIRE_GE(strategy->sendInterestHistory.size(), 3);
-  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[2].outFaceId, face1->getId());
+  BOOST_REQUIRE_GE(strategy.sendInterestHistory.size(), 3);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[2].outFaceId, face1->getId());
 }
 
 BOOST_AUTO_TEST_CASE(Bug1971)
 {
   LimitedIo limitedIo(this);
   Forwarder forwarder;
-  typedef StrategyTester<NccStrategy> NccStrategyTester;
-  shared_ptr<NccStrategyTester> strategy = make_shared<NccStrategyTester>(ref(forwarder));
-  strategy->afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
+  StrategyTester<NccStrategy>& strategy = choose<StrategyTester<NccStrategy>>(forwarder);
+  strategy.afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
 
   shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
   shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
@@ -245,10 +229,6 @@
   fib::Entry& fibEntry = *fib.insert(Name()).first;
   fibEntry.addNextHop(*face2, 10);
 
-  StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
-  strategyChoice.install(strategy);
-  strategyChoice.insert(Name(), strategy->getName());
-
   Pit& pit = forwarder.getPit();
 
   // first Interest: strategy forwards to face2
@@ -257,34 +237,33 @@
   shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
 
   pitEntry1->insertOrUpdateInRecord(face1, *interest1);
-  strategy->afterReceiveInterest(*face1, *interest1, pitEntry1);
-  limitedIo.run(1 - strategy->sendInterestHistory.size(),
+  strategy.afterReceiveInterest(*face1, *interest1, pitEntry1);
+  limitedIo.run(1 - strategy.sendInterestHistory.size(),
                 time::milliseconds(2000), time::milliseconds(10));
-  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[0].outFaceId, face2->getId());
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face2->getId());
 
   // face2 responds
   shared_ptr<Data> data1 = makeData("ndn:/M4mBXCsd");
   data1->setFreshnessPeriod(time::milliseconds(5));
-  strategy->beforeSatisfyInterest(pitEntry1, *face2, *data1);
+  strategy.beforeSatisfyInterest(pitEntry1, *face2, *data1);
   pitEntry1->deleteOutRecord(*face2);
   pitEntry1->clearInRecords();
   this->advanceClocks(time::milliseconds(10));
 
   // similar Interest: strategy should still forward it
   pitEntry1->insertOrUpdateInRecord(face1, *interest1);
-  strategy->afterReceiveInterest(*face1, *interest1, pitEntry1);
-  limitedIo.run(2 - strategy->sendInterestHistory.size(),
+  strategy.afterReceiveInterest(*face1, *interest1, pitEntry1);
+  limitedIo.run(2 - strategy.sendInterestHistory.size(),
                 time::milliseconds(2000), time::milliseconds(10));
-  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 2);
-  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[1].outFaceId, face2->getId());
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 2);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face2->getId());
 }
 
 BOOST_AUTO_TEST_CASE(Bug1998)
 {
   Forwarder forwarder;
-  typedef StrategyTester<NccStrategy> NccStrategyTester;
-  shared_ptr<NccStrategyTester> strategy = make_shared<NccStrategyTester>(ref(forwarder));
+  StrategyTester<NccStrategy>& strategy = choose<StrategyTester<NccStrategy>>(forwarder);
 
   shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
   shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
@@ -296,10 +275,6 @@
   fibEntry.addNextHop(*face1, 10); // face1 is top-ranked nexthop
   fibEntry.addNextHop(*face2, 20);
 
-  StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
-  strategyChoice.install(strategy);
-  strategyChoice.insert(Name(), strategy->getName());
-
   Pit& pit = forwarder.getPit();
 
   // Interest comes from face1, which is sole downstream
@@ -307,11 +282,11 @@
   shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
   pitEntry1->insertOrUpdateInRecord(face1, *interest1);
 
-  strategy->afterReceiveInterest(*face1, *interest1, pitEntry1);
+  strategy.afterReceiveInterest(*face1, *interest1, pitEntry1);
 
   // Interest shall go to face2, not loop back to face1
-  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[0].outFaceId, face2->getId());
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face2->getId());
 }
 
 BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(PredictionAdjustment, 1)