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