blob: 81b9e70577111ea3ecd0e978dfbf9cea7898e3bf [file] [log] [blame]
Junxiao Shif3c07812014-03-11 21:48:49 -07001/* -*- 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#ifndef NFD_TEST_FW_DUMMY_STRATEGY_HPP
8#define NFD_TEST_FW_DUMMY_STRATEGY_HPP
9
10#include "fw/strategy.hpp"
11
12namespace nfd {
13namespace tests {
14
15/** \brief strategy for unit testing
16 *
17 * Triggers on DummyStrategy are recorded but does nothing
18 */
19class DummyStrategy : public fw::Strategy
20{
21public:
22 DummyStrategy(Forwarder& forwarder, const Name& name)
23 : Strategy(forwarder, name)
24 {
25 }
26
27 virtual void
28 afterReceiveInterest(const Face& inFace,
29 const Interest& interest,
30 shared_ptr<fib::Entry> fibEntry,
31 shared_ptr<pit::Entry> pitEntry)
32 {
33 ++m_afterReceiveInterest_count;
34
35 if (static_cast<bool>(m_interestOutFace)) {
36 this->sendInterest(pitEntry, m_interestOutFace);
37 }
38 else {
39 this->rejectPendingInterest(pitEntry);
40 }
41 }
42
43 virtual void
44 beforeSatisfyPendingInterest(shared_ptr<pit::Entry> pitEntry,
45 const Face& inFace, const Data& data)
46 {
47 ++m_beforeSatisfyPendingInterest_count;
48 }
49
50 virtual void
51 beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry)
52 {
53 ++m_beforeExpirePendingInterest_count;
54 }
55
56public:
57 int m_afterReceiveInterest_count;
58 int m_beforeSatisfyPendingInterest_count;
59 int m_beforeExpirePendingInterest_count;
60
61 /// outFace to use in afterReceiveInterest, nullptr to reject
62 shared_ptr<Face> m_interestOutFace;
63};
64
65} // namespace tests
66} // namespace nfd
67
68#endif // TEST_FW_DUMMY_STRATEGY_HPP