Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -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_MGMT_INTERNAL_FACE_HPP |
| 8 | #define NFD_MGMT_INTERNAL_FACE_HPP |
| 9 | |
| 10 | #include "face/face.hpp" |
| 11 | #include "app-face.hpp" |
| 12 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 13 | #include "command-validator.hpp" |
| 14 | |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 15 | namespace nfd { |
| 16 | |
| 17 | class InternalFace : public Face, public AppFace |
| 18 | { |
| 19 | public: |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 20 | /** |
| 21 | * \brief InternalFace-related error |
| 22 | */ |
Junxiao Shi | 16d1b7d | 2014-03-27 21:29:09 -0700 | [diff] [blame] | 23 | class Error : public Face::Error |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 24 | { |
Junxiao Shi | 16d1b7d | 2014-03-27 21:29:09 -0700 | [diff] [blame] | 25 | public: |
| 26 | explicit |
| 27 | Error(const std::string& what) |
| 28 | : Face::Error(what) |
| 29 | { |
| 30 | } |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 31 | }; |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 32 | |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame] | 33 | InternalFace(); |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 34 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 35 | CommandValidator& |
| 36 | getValidator(); |
| 37 | |
| 38 | virtual |
| 39 | ~InternalFace(); |
| 40 | |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 41 | // Overridden Face methods for forwarder |
| 42 | |
| 43 | virtual void |
| 44 | sendInterest(const Interest& interest); |
| 45 | |
| 46 | virtual void |
| 47 | sendData(const Data& data); |
| 48 | |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 49 | virtual void |
| 50 | close(); |
| 51 | |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 52 | // Methods implementing AppFace interface. Do not invoke from forwarder. |
| 53 | |
| 54 | virtual void |
| 55 | setInterestFilter(const Name& filter, |
| 56 | OnInterest onInterest); |
| 57 | |
| 58 | virtual void |
| 59 | put(const Data& data); |
| 60 | |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 61 | private: |
Junxiao Shi | 16d1b7d | 2014-03-27 21:29:09 -0700 | [diff] [blame] | 62 | void |
| 63 | processInterest(const Interest& interest); |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 64 | |
Junxiao Shi | 16d1b7d | 2014-03-27 21:29:09 -0700 | [diff] [blame] | 65 | private: |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 66 | std::map<Name, OnInterest> m_interestFilters; |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 67 | CommandValidator m_validator; |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 70 | inline CommandValidator& |
| 71 | InternalFace::getValidator() |
| 72 | { |
| 73 | return m_validator; |
| 74 | } |
| 75 | |
| 76 | |
Steve DiBenedetto | 5b43398 | 2014-01-29 17:14:27 -0700 | [diff] [blame] | 77 | } // namespace nfd |
| 78 | |
| 79 | #endif //NFD_MGMT_INTERNAL_FACE_HPP |