blob: 969053a001a05f700cf464fe05bd80305c216ece [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 Shid9ee45c2014-02-27 15:38:11 -070014namespace tests {
Junxiao Shicbba04c2014-01-26 14:21:22 -070015
16/** \class DummyFace
Junxiao Shi9b27bd22014-02-26 20:29:58 -070017 * \brief a Face for unit testing
Junxiao Shicbba04c2014-01-26 14:21:22 -070018 */
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080019template<class FaceBase>
20class DummyFaceImpl : public FaceBase
Junxiao Shicbba04c2014-01-26 14:21:22 -070021{
22public:
Junxiao Shicbba04c2014-01-26 14:21:22 -070023 virtual void
Junxiao Shi8c8d2182014-01-30 22:33:00 -070024 sendInterest(const Interest& interest)
Junxiao Shicbba04c2014-01-26 14:21:22 -070025 {
Junxiao Shi9b27bd22014-02-26 20:29:58 -070026 m_sentInterests.push_back(interest);
27 this->afterSend();
Junxiao Shicbba04c2014-01-26 14:21:22 -070028 }
Junxiao Shi9b27bd22014-02-26 20:29:58 -070029
Junxiao Shicbba04c2014-01-26 14:21:22 -070030 virtual void
Junxiao Shi8c8d2182014-01-30 22:33:00 -070031 sendData(const Data& data)
Junxiao Shicbba04c2014-01-26 14:21:22 -070032 {
Junxiao Shi9b27bd22014-02-26 20:29:58 -070033 m_sentDatas.push_back(data);
34 this->afterSend();
Junxiao Shicbba04c2014-01-26 14:21:22 -070035 }
Alexander Afanasyeva0a10fb2014-02-13 19:56:15 -080036
37 virtual void
38 close()
39 {
40 }
Alexander Afanasyev93ce75e2014-02-18 19:45:34 -080041
Junxiao Shi9b27bd22014-02-26 20:29:58 -070042 void
43 receiveInterest(const Interest& interest)
44 {
45 this->onReceiveInterest(interest);
46 }
47
48 void
49 receiveData(const Data& data)
50 {
51 this->onReceiveData(data);
52 }
53
Junxiao Shid9ee45c2014-02-27 15:38:11 -070054 EventEmitter<> afterSend;
Junxiao Shi9b27bd22014-02-26 20:29:58 -070055
56public:
57 std::vector<Interest> m_sentInterests;
58 std::vector<Data> m_sentDatas;
Junxiao Shicbba04c2014-01-26 14:21:22 -070059};
60
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080061typedef DummyFaceImpl<Face> DummyFace;
62typedef DummyFaceImpl<LocalFace> DummyLocalFace;
63
Junxiao Shid9ee45c2014-02-27 15:38:11 -070064} // namespace tests
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080065} // namespace nfd
Junxiao Shicbba04c2014-01-26 14:21:22 -070066
67#endif // TEST_FACE_DUMMY_FACE_HPP