Alexander Afanasyev | 77f6ae1 | 2018-06-14 17:54:17 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014-2018, Regents of the University of California |
| 4 | * |
| 5 | * NAC library is free software: you can redistribute it and/or modify it under the |
| 6 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 7 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * NAC library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 11 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 12 | * |
| 13 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 14 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 15 | * <http://www.gnu.org/licenses/>. |
| 16 | * |
| 17 | * See AUTHORS.md for complete list of NAC library authors and contributors. |
| 18 | */ |
| 19 | |
| 20 | #include <ndn-cxx/interest.hpp> |
| 21 | #include <ndn-cxx/data.hpp> |
| 22 | #include <ndn-cxx/lp/nack.hpp> |
| 23 | #include <ndn-cxx/util/dummy-client-face.hpp> |
| 24 | #include <ndn-cxx/security/key-chain.hpp> |
| 25 | |
| 26 | #ifndef NAC_TESTS_TEST_DUMMY_FORWARDER_HPP |
| 27 | #define NAC_TESTS_TEST_DUMMY_FORWARDER_HPP |
| 28 | |
| 29 | namespace ndn { |
| 30 | namespace nac { |
| 31 | namespace tests { |
| 32 | |
| 33 | /** |
| 34 | * @brief Very basic implementation of the dummy forwarder |
| 35 | * |
| 36 | * Interests expressed by any added face, will be forwarded to all other faces. |
| 37 | * Similarly, any pushed data, will be pushed to all other faces. |
| 38 | */ |
| 39 | class DummyForwarder |
| 40 | { |
| 41 | public: |
| 42 | DummyForwarder(boost::asio::io_service& io, KeyChain& keyChain); |
| 43 | |
| 44 | Face& |
| 45 | addFace(); |
| 46 | |
| 47 | Face& |
| 48 | getFace(size_t nFace) |
| 49 | { |
| 50 | return *m_faces.at(nFace); |
| 51 | } |
| 52 | |
| 53 | private: |
| 54 | boost::asio::io_service& m_io; |
| 55 | KeyChain& m_keyChain; |
| 56 | std::vector<shared_ptr<util::DummyClientFace>> m_faces; |
| 57 | }; |
| 58 | |
| 59 | } // namespace tests |
| 60 | } // namespace nac |
| 61 | } // namespace ndn |
| 62 | |
| 63 | #endif // NAC_TESTS_TEST_DUMMY_FORWARDER_HPP |