Eric Newberry | 3898262 | 2015-08-06 21:39:55 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2015 Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 6 | * |
| 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 20 | * |
| 21 | * @author Eric Newberry <enewberry@email.arizona.edu> |
| 22 | */ |
| 23 | |
| 24 | #ifndef NDN_CXX_LP_NACK_HPP |
| 25 | #define NDN_CXX_LP_NACK_HPP |
| 26 | |
| 27 | #include "../common.hpp" |
| 28 | #include "../tag-host.hpp" |
| 29 | #include "../interest.hpp" |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 30 | #include "../management/nfd-local-control-header.hpp" |
Eric Newberry | 3898262 | 2015-08-06 21:39:55 -0700 | [diff] [blame] | 31 | |
| 32 | #include "nack-header.hpp" |
| 33 | |
| 34 | namespace ndn { |
| 35 | namespace lp { |
| 36 | |
| 37 | /** |
| 38 | * \brief represents a Network NACK |
Davide Pesavento | 18cf81b | 2015-09-12 23:36:43 +0200 | [diff] [blame] | 39 | * \details This type binds a NackHeader and an Interest, and is intended for use in network layer. |
Eric Newberry | 3898262 | 2015-08-06 21:39:55 -0700 | [diff] [blame] | 40 | */ |
| 41 | class Nack : public TagHost |
| 42 | { |
| 43 | public: |
| 44 | Nack() = default; |
| 45 | |
| 46 | explicit |
| 47 | Nack(const Interest& interest); |
| 48 | |
| 49 | explicit |
| 50 | Nack(Interest&& interest); |
| 51 | |
| 52 | public: // getter/setter |
| 53 | const Interest& |
| 54 | getInterest() const |
| 55 | { |
| 56 | return m_interest; |
| 57 | } |
| 58 | |
| 59 | Interest& |
| 60 | getInterest() |
| 61 | { |
| 62 | return m_interest; |
| 63 | } |
| 64 | |
| 65 | const NackHeader& |
| 66 | getHeader() const |
| 67 | { |
| 68 | return m_header; |
| 69 | } |
| 70 | |
| 71 | NackHeader& |
| 72 | getHeader() |
| 73 | { |
| 74 | return m_header; |
| 75 | } |
| 76 | |
| 77 | Nack& |
| 78 | setHeader(const NackHeader& header) |
| 79 | { |
| 80 | m_header = header; |
| 81 | return *this; |
| 82 | } |
| 83 | |
| 84 | Nack& |
| 85 | setHeader(NackHeader&& header) |
| 86 | { |
| 87 | m_header = header; |
| 88 | return *this; |
| 89 | } |
| 90 | |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 91 | nfd::LocalControlHeader& |
| 92 | getLocalControlHeader() |
| 93 | { |
| 94 | return m_interest.getLocalControlHeader(); |
| 95 | } |
| 96 | |
| 97 | const nfd::LocalControlHeader& |
| 98 | getLocalControlHeader() const |
| 99 | { |
| 100 | return m_interest.getLocalControlHeader(); |
| 101 | } |
| 102 | |
Eric Newberry | 3898262 | 2015-08-06 21:39:55 -0700 | [diff] [blame] | 103 | public: // NackHeader proxy |
| 104 | NackReason |
| 105 | getReason() const |
| 106 | { |
| 107 | return m_header.getReason(); |
| 108 | } |
| 109 | |
| 110 | Nack& |
| 111 | setReason(NackReason reason) |
| 112 | { |
| 113 | m_header.setReason(reason); |
| 114 | return *this; |
| 115 | } |
| 116 | |
| 117 | private: |
| 118 | Interest m_interest; |
| 119 | NackHeader m_header; |
| 120 | }; |
| 121 | |
| 122 | } // namespace lp |
| 123 | } // namespace ndn |
| 124 | |
Davide Pesavento | 18cf81b | 2015-09-12 23:36:43 +0200 | [diff] [blame] | 125 | #endif // NDN_CXX_LP_NACK_HPP |