blob: 83af2fa7e4d4e6c86b29c9499ee456134e83bc96 [file] [log] [blame]
Junxiao Shif3c07812014-03-11 21:48:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shi82e7f582014-09-07 15:15:40 -07003 * Copyright (c) 2014, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070010 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Junxiao Shi82e7f582014-09-07 15:15:40 -070024 */
Junxiao Shif3c07812014-03-11 21:48:49 -070025
Junxiao Shi82e7f582014-09-07 15:15:40 -070026#ifndef NFD_TESTS_DAEMON_FW_DUMMY_STRATEGY_HPP
27#define NFD_TESTS_DAEMON_FW_DUMMY_STRATEGY_HPP
Junxiao Shif3c07812014-03-11 21:48:49 -070028
29#include "fw/strategy.hpp"
30
31namespace nfd {
32namespace tests {
33
34/** \brief strategy for unit testing
35 *
36 * Triggers on DummyStrategy are recorded but does nothing
37 */
38class DummyStrategy : public fw::Strategy
39{
40public:
41 DummyStrategy(Forwarder& forwarder, const Name& name)
42 : Strategy(forwarder, name)
43 {
44 }
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070045
Junxiao Shif3c07812014-03-11 21:48:49 -070046 virtual void
47 afterReceiveInterest(const Face& inFace,
48 const Interest& interest,
49 shared_ptr<fib::Entry> fibEntry,
50 shared_ptr<pit::Entry> pitEntry)
51 {
52 ++m_afterReceiveInterest_count;
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070053
Junxiao Shif3c07812014-03-11 21:48:49 -070054 if (static_cast<bool>(m_interestOutFace)) {
55 this->sendInterest(pitEntry, m_interestOutFace);
56 }
57 else {
58 this->rejectPendingInterest(pitEntry);
59 }
60 }
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070061
Junxiao Shif3c07812014-03-11 21:48:49 -070062 virtual void
Junxiao Shi82e7f582014-09-07 15:15:40 -070063 beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
64 const Face& inFace, const Data& data)
Junxiao Shif3c07812014-03-11 21:48:49 -070065 {
Junxiao Shi82e7f582014-09-07 15:15:40 -070066 ++m_beforeSatisfyInterest_count;
Junxiao Shif3c07812014-03-11 21:48:49 -070067 }
68
69 virtual void
70 beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry)
71 {
72 ++m_beforeExpirePendingInterest_count;
73 }
74
75public:
76 int m_afterReceiveInterest_count;
Junxiao Shi82e7f582014-09-07 15:15:40 -070077 int m_beforeSatisfyInterest_count;
Junxiao Shif3c07812014-03-11 21:48:49 -070078 int m_beforeExpirePendingInterest_count;
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070079
Junxiao Shif3c07812014-03-11 21:48:49 -070080 /// outFace to use in afterReceiveInterest, nullptr to reject
81 shared_ptr<Face> m_interestOutFace;
82};
83
84} // namespace tests
85} // namespace nfd
86
Junxiao Shi82e7f582014-09-07 15:15:40 -070087#endif // NFD_TESTS_DAEMON_FW_DUMMY_STRATEGY_HPP