Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -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 | #ifndef NFD_TEST_FACE_DUMMY_FACE_HPP |
| 8 | #define NFD_TEST_FACE_DUMMY_FACE_HPP |
| 9 | |
| 10 | #include "face/face.hpp" |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 11 | #include "face/local-face.hpp" |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 12 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 13 | namespace nfd { |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 14 | |
| 15 | /** \class DummyFace |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 16 | * \brief a Face for unit testing |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 17 | */ |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 18 | template<class FaceBase> |
| 19 | class DummyFaceImpl : public FaceBase |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 20 | { |
| 21 | public: |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 22 | virtual void |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 23 | sendInterest(const Interest& interest) |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 24 | { |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 25 | m_sentInterests.push_back(interest); |
| 26 | this->afterSend(); |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 27 | } |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 28 | |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 29 | virtual void |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 30 | sendData(const Data& data) |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 31 | { |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 32 | m_sentDatas.push_back(data); |
| 33 | this->afterSend(); |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 34 | } |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 35 | |
| 36 | virtual void |
| 37 | close() |
| 38 | { |
| 39 | } |
Alexander Afanasyev | 93ce75e | 2014-02-18 19:45:34 -0800 | [diff] [blame] | 40 | |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 41 | void |
| 42 | receiveInterest(const Interest& interest) |
| 43 | { |
| 44 | this->onReceiveInterest(interest); |
| 45 | } |
| 46 | |
| 47 | void |
| 48 | receiveData(const Data& data) |
| 49 | { |
| 50 | this->onReceiveData(data); |
| 51 | } |
| 52 | |
| 53 | protected: |
| 54 | virtual void |
| 55 | afterSend() |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | public: |
| 60 | std::vector<Interest> m_sentInterests; |
| 61 | std::vector<Data> m_sentDatas; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 64 | typedef DummyFaceImpl<Face> DummyFace; |
| 65 | typedef DummyFaceImpl<LocalFace> DummyLocalFace; |
| 66 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 67 | } // namespace nfd |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 68 | |
| 69 | #endif // TEST_FACE_DUMMY_FACE_HPP |