Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 3 | * 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 | * |
| 10 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 11 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 12 | * |
| 13 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 14 | * of the GNU General Public License as published by the Free Software Foundation, |
| 15 | * either version 3 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 18 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 19 | * PURPOSE. See the GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along with |
| 22 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 23 | **/ |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 24 | |
| 25 | #ifndef NFD_MGMT_INTERNAL_FACE_HPP |
| 26 | #define NFD_MGMT_INTERNAL_FACE_HPP |
| 27 | |
| 28 | #include "face/face.hpp" |
| 29 | #include "app-face.hpp" |
| 30 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 31 | #include "command-validator.hpp" |
| 32 | |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 33 | namespace nfd { |
| 34 | |
| 35 | class InternalFace : public Face, public AppFace |
| 36 | { |
| 37 | public: |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 38 | /** |
| 39 | * \brief InternalFace-related error |
| 40 | */ |
Junxiao Shi | 16d1b7d | 2014-03-27 21:29:09 -0700 | [diff] [blame] | 41 | class Error : public Face::Error |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 42 | { |
Junxiao Shi | 16d1b7d | 2014-03-27 21:29:09 -0700 | [diff] [blame] | 43 | public: |
| 44 | explicit |
| 45 | Error(const std::string& what) |
| 46 | : Face::Error(what) |
| 47 | { |
| 48 | } |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 49 | }; |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 50 | |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame] | 51 | InternalFace(); |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 52 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 53 | CommandValidator& |
| 54 | getValidator(); |
| 55 | |
| 56 | virtual |
| 57 | ~InternalFace(); |
| 58 | |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 59 | // Overridden Face methods for forwarder |
| 60 | |
| 61 | virtual void |
| 62 | sendInterest(const Interest& interest); |
| 63 | |
| 64 | virtual void |
| 65 | sendData(const Data& data); |
| 66 | |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 67 | virtual void |
| 68 | close(); |
| 69 | |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 70 | // Methods implementing AppFace interface. Do not invoke from forwarder. |
| 71 | |
| 72 | virtual void |
| 73 | setInterestFilter(const Name& filter, |
| 74 | OnInterest onInterest); |
| 75 | |
| 76 | virtual void |
| 77 | put(const Data& data); |
| 78 | |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 79 | private: |
Junxiao Shi | 16d1b7d | 2014-03-27 21:29:09 -0700 | [diff] [blame] | 80 | void |
| 81 | processInterest(const Interest& interest); |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 82 | |
Junxiao Shi | 16d1b7d | 2014-03-27 21:29:09 -0700 | [diff] [blame] | 83 | private: |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 84 | std::map<Name, OnInterest> m_interestFilters; |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 85 | CommandValidator m_validator; |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 88 | inline CommandValidator& |
| 89 | InternalFace::getValidator() |
| 90 | { |
| 91 | return m_validator; |
| 92 | } |
| 93 | |
| 94 | |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 95 | } // namespace nfd |
| 96 | |
| 97 | #endif //NFD_MGMT_INTERNAL_FACE_HPP |