blob: 45a3d43db9970f1f7ed60730b3c5cca2ce4c0385 [file] [log] [blame]
Junxiao Shicbba04c2014-01-26 14:21:22 -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_FACE_DUMMY_FACE_HPP
8#define NFD_TEST_FACE_DUMMY_FACE_HPP
9
10#include "face/face.hpp"
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080011#include "face/local-face.hpp"
Junxiao Shicbba04c2014-01-26 14:21:22 -070012
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080013namespace nfd {
Junxiao Shicbba04c2014-01-26 14:21:22 -070014
15/** \class DummyFace
Junxiao Shi9b27bd22014-02-26 20:29:58 -070016 * \brief a Face for unit testing
Junxiao Shicbba04c2014-01-26 14:21:22 -070017 */
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080018template<class FaceBase>
19class DummyFaceImpl : public FaceBase
Junxiao Shicbba04c2014-01-26 14:21:22 -070020{
21public:
Junxiao Shicbba04c2014-01-26 14:21:22 -070022 virtual void
Junxiao Shi8c8d2182014-01-30 22:33:00 -070023 sendInterest(const Interest& interest)
Junxiao Shicbba04c2014-01-26 14:21:22 -070024 {
Junxiao Shi9b27bd22014-02-26 20:29:58 -070025 m_sentInterests.push_back(interest);
26 this->afterSend();
Junxiao Shicbba04c2014-01-26 14:21:22 -070027 }
Junxiao Shi9b27bd22014-02-26 20:29:58 -070028
Junxiao Shicbba04c2014-01-26 14:21:22 -070029 virtual void
Junxiao Shi8c8d2182014-01-30 22:33:00 -070030 sendData(const Data& data)
Junxiao Shicbba04c2014-01-26 14:21:22 -070031 {
Junxiao Shi9b27bd22014-02-26 20:29:58 -070032 m_sentDatas.push_back(data);
33 this->afterSend();
Junxiao Shicbba04c2014-01-26 14:21:22 -070034 }
Alexander Afanasyeva0a10fb2014-02-13 19:56:15 -080035
36 virtual void
37 close()
38 {
39 }
Alexander Afanasyev93ce75e2014-02-18 19:45:34 -080040
Junxiao Shi9b27bd22014-02-26 20:29:58 -070041 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
53protected:
54 virtual void
55 afterSend()
56 {
57 }
58
59public:
60 std::vector<Interest> m_sentInterests;
61 std::vector<Data> m_sentDatas;
Junxiao Shicbba04c2014-01-26 14:21:22 -070062};
63
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080064typedef DummyFaceImpl<Face> DummyFace;
65typedef DummyFaceImpl<LocalFace> DummyLocalFace;
66
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080067} // namespace nfd
Junxiao Shicbba04c2014-01-26 14:21:22 -070068
69#endif // TEST_FACE_DUMMY_FACE_HPP