Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Davide Pesavento | 7f20d6e | 2017-01-16 14:43:58 -0500 | [diff] [blame] | 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 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 | |
| 22 | #ifndef NDN_MGMT_NFD_STATUS_DATASET_HPP |
| 23 | #define NDN_MGMT_NFD_STATUS_DATASET_HPP |
| 24 | |
| 25 | #include "../../name.hpp" |
| 26 | #include "forwarder-status.hpp" |
| 27 | #include "face-status.hpp" |
| 28 | #include "face-query-filter.hpp" |
| 29 | #include "channel-status.hpp" |
| 30 | #include "fib-entry.hpp" |
| 31 | #include "strategy-choice.hpp" |
| 32 | #include "rib-entry.hpp" |
| 33 | |
| 34 | namespace ndn { |
| 35 | namespace nfd { |
| 36 | |
| 37 | /** |
| 38 | * \ingroup management |
| 39 | * \brief base class of NFD StatusDataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame^] | 40 | * \sa https://redmine.named-data.net/projects/nfd/wiki/StatusDataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 41 | */ |
| 42 | class StatusDataset : noncopyable |
| 43 | { |
| 44 | public: |
Davide Pesavento | 7f20d6e | 2017-01-16 14:43:58 -0500 | [diff] [blame] | 45 | virtual |
| 46 | ~StatusDataset(); |
| 47 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 48 | #ifdef DOXYGEN |
| 49 | /** |
| 50 | * \brief if defined, specifies constructor argument type; |
| 51 | * otherwise, constructor has no argument |
| 52 | */ |
| 53 | typedef int ParamType; |
| 54 | #endif |
| 55 | |
| 56 | /** |
| 57 | * \brief constructs a name prefix for the dataset |
| 58 | * \param prefix top-level prefix, such as ndn:/localhost/nfd |
| 59 | * \return name prefix without version and segment components |
| 60 | */ |
| 61 | Name |
| 62 | getDatasetPrefix(const Name& prefix) const; |
| 63 | |
| 64 | #ifdef DOXYGEN |
| 65 | /** |
| 66 | * \brief provides the result type, usually a vector |
| 67 | */ |
| 68 | typedef std::vector<int> ResultType; |
| 69 | #endif |
| 70 | |
| 71 | /** |
| 72 | * \brief indicates reassembled payload cannot be parsed as ResultType |
| 73 | */ |
| 74 | class ParseResultError : public tlv::Error |
| 75 | { |
| 76 | public: |
| 77 | explicit |
| 78 | ParseResultError(const std::string& what) |
| 79 | : tlv::Error(what) |
| 80 | { |
| 81 | } |
| 82 | }; |
| 83 | |
| 84 | #ifdef DOXYGEN |
| 85 | /** |
| 86 | * \brief parses a result from reassembled payload |
| 87 | * \param payload reassembled payload |
| 88 | * \throw tlv::Error cannot parse payload |
| 89 | */ |
| 90 | ResultType |
| 91 | parseResult(ConstBufferPtr payload) const; |
| 92 | #endif |
| 93 | |
| 94 | protected: |
| 95 | /** |
| 96 | * \brief constructs a StatusDataset instance with given sub-prefix |
| 97 | * \param datasetName dataset name after top-level prefix, such as faces/list |
| 98 | */ |
| 99 | explicit |
| 100 | StatusDataset(const PartialName& datasetName); |
| 101 | |
| 102 | private: |
| 103 | /** |
| 104 | * \brief appends parameters to the dataset name prefix |
| 105 | * \param[in,out] the dataset name prefix onto which parameter components can be appended |
| 106 | */ |
| 107 | virtual void |
| 108 | addParameters(Name& name) const; |
| 109 | |
| 110 | private: |
| 111 | PartialName m_datasetName; |
| 112 | }; |
| 113 | |
| 114 | |
| 115 | /** |
| 116 | * \ingroup management |
| 117 | * \brief represents a status/general dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame^] | 118 | * \sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 119 | */ |
| 120 | class ForwarderGeneralStatusDataset : public StatusDataset |
| 121 | { |
| 122 | public: |
| 123 | ForwarderGeneralStatusDataset(); |
| 124 | |
| 125 | typedef ForwarderStatus ResultType; |
| 126 | |
| 127 | ResultType |
| 128 | parseResult(ConstBufferPtr payload) const; |
| 129 | }; |
| 130 | |
| 131 | |
| 132 | /** |
| 133 | * \ingroup management |
| 134 | * \brief provides common functionality among FaceDataset and FaceQueryDataset |
| 135 | */ |
| 136 | class FaceDatasetBase : public StatusDataset |
| 137 | { |
| 138 | public: |
| 139 | typedef std::vector<FaceStatus> ResultType; |
| 140 | |
| 141 | ResultType |
| 142 | parseResult(ConstBufferPtr payload) const; |
| 143 | |
| 144 | protected: |
| 145 | explicit |
| 146 | FaceDatasetBase(const PartialName& datasetName); |
| 147 | }; |
| 148 | |
| 149 | |
| 150 | /** |
| 151 | * \ingroup management |
| 152 | * \brief represents a faces/list dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame^] | 153 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 154 | */ |
| 155 | class FaceDataset : public FaceDatasetBase |
| 156 | { |
| 157 | public: |
| 158 | FaceDataset(); |
| 159 | }; |
| 160 | |
| 161 | |
| 162 | /** |
| 163 | * \ingroup management |
| 164 | * \brief represents a faces/query dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame^] | 165 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Query-Operation |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 166 | */ |
| 167 | class FaceQueryDataset : public FaceDatasetBase |
| 168 | { |
| 169 | public: |
| 170 | typedef FaceQueryFilter ParamType; |
| 171 | |
| 172 | explicit |
| 173 | FaceQueryDataset(const FaceQueryFilter& filter); |
| 174 | |
| 175 | private: |
Davide Pesavento | 57c07df | 2016-12-11 18:41:45 -0500 | [diff] [blame] | 176 | void |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 177 | addParameters(Name& name) const override; |
| 178 | |
| 179 | private: |
| 180 | FaceQueryFilter m_filter; |
| 181 | }; |
| 182 | |
| 183 | |
| 184 | /** |
| 185 | * \ingroup management |
| 186 | * \brief represents a faces/channels dataset |
| 187 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset |
| 188 | */ |
| 189 | class ChannelDataset : public StatusDataset |
| 190 | { |
| 191 | public: |
| 192 | ChannelDataset(); |
| 193 | |
| 194 | typedef std::vector<ChannelStatus> ResultType; |
| 195 | |
| 196 | ResultType |
| 197 | parseResult(ConstBufferPtr payload) const; |
| 198 | }; |
| 199 | |
| 200 | |
| 201 | /** |
| 202 | * \ingroup management |
| 203 | * \brief represents a fib/list dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame^] | 204 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 205 | */ |
| 206 | class FibDataset : public StatusDataset |
| 207 | { |
| 208 | public: |
| 209 | FibDataset(); |
| 210 | |
| 211 | typedef std::vector<FibEntry> ResultType; |
| 212 | |
| 213 | ResultType |
| 214 | parseResult(ConstBufferPtr payload) const; |
| 215 | }; |
| 216 | |
| 217 | |
| 218 | /** |
| 219 | * \ingroup management |
| 220 | * \brief represents a strategy-choice/list dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame^] | 221 | * \sa https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy-Choice-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 222 | */ |
| 223 | class StrategyChoiceDataset : public StatusDataset |
| 224 | { |
| 225 | public: |
| 226 | StrategyChoiceDataset(); |
| 227 | |
| 228 | typedef std::vector<StrategyChoice> ResultType; |
| 229 | |
| 230 | ResultType |
| 231 | parseResult(ConstBufferPtr payload) const; |
| 232 | }; |
| 233 | |
| 234 | |
| 235 | /** |
| 236 | * \ingroup management |
| 237 | * \brief represents a rib/list dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame^] | 238 | * \sa https://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 239 | */ |
| 240 | class RibDataset : public StatusDataset |
| 241 | { |
| 242 | public: |
| 243 | RibDataset(); |
| 244 | |
| 245 | typedef std::vector<RibEntry> ResultType; |
| 246 | |
| 247 | ResultType |
| 248 | parseResult(ConstBufferPtr payload) const; |
| 249 | }; |
| 250 | |
| 251 | |
| 252 | } // namespace nfd |
| 253 | } // namespace ndn |
| 254 | |
| 255 | #endif // NDN_MGMT_NFD_STATUS_DATASET_HPP |