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 | /* |
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" |
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: |
| 78 | explicit |
| 79 | ParseResultError(const std::string& what) |
| 80 | : tlv::Error(what) |
| 81 | { |
| 82 | } |
| 83 | }; |
| 84 | |
| 85 | #ifdef DOXYGEN |
| 86 | /** |
| 87 | * \brief parses a result from reassembled payload |
| 88 | * \param payload reassembled payload |
| 89 | * \throw tlv::Error cannot parse payload |
| 90 | */ |
| 91 | ResultType |
| 92 | parseResult(ConstBufferPtr payload) const; |
| 93 | #endif |
| 94 | |
| 95 | protected: |
| 96 | /** |
| 97 | * \brief constructs a StatusDataset instance with given sub-prefix |
| 98 | * \param datasetName dataset name after top-level prefix, such as faces/list |
| 99 | */ |
| 100 | explicit |
| 101 | StatusDataset(const PartialName& datasetName); |
| 102 | |
| 103 | private: |
| 104 | /** |
| 105 | * \brief appends parameters to the dataset name prefix |
| 106 | * \param[in,out] the dataset name prefix onto which parameter components can be appended |
| 107 | */ |
| 108 | virtual void |
| 109 | addParameters(Name& name) const; |
| 110 | |
| 111 | private: |
| 112 | PartialName m_datasetName; |
| 113 | }; |
| 114 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 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 | |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 125 | using ResultType = ForwarderStatus; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 126 | |
| 127 | ResultType |
| 128 | parseResult(ConstBufferPtr payload) const; |
| 129 | }; |
| 130 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 131 | /** |
| 132 | * \ingroup management |
| 133 | * \brief provides common functionality among FaceDataset and FaceQueryDataset |
| 134 | */ |
| 135 | class FaceDatasetBase : public StatusDataset |
| 136 | { |
| 137 | public: |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 138 | using ResultType = std::vector<FaceStatus>; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 139 | |
| 140 | ResultType |
| 141 | parseResult(ConstBufferPtr payload) const; |
| 142 | |
| 143 | protected: |
| 144 | explicit |
| 145 | FaceDatasetBase(const PartialName& datasetName); |
| 146 | }; |
| 147 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 148 | /** |
| 149 | * \ingroup management |
| 150 | * \brief represents a faces/list dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame] | 151 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 152 | */ |
| 153 | class FaceDataset : public FaceDatasetBase |
| 154 | { |
| 155 | public: |
| 156 | FaceDataset(); |
| 157 | }; |
| 158 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 159 | /** |
| 160 | * \ingroup management |
| 161 | * \brief represents a faces/query dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame] | 162 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Query-Operation |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 163 | */ |
| 164 | class FaceQueryDataset : public FaceDatasetBase |
| 165 | { |
| 166 | public: |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 167 | using ParamType = FaceQueryFilter; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 168 | |
| 169 | explicit |
| 170 | FaceQueryDataset(const FaceQueryFilter& filter); |
| 171 | |
| 172 | private: |
Davide Pesavento | 57c07df | 2016-12-11 18:41:45 -0500 | [diff] [blame] | 173 | void |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 174 | addParameters(Name& name) const override; |
| 175 | |
| 176 | private: |
| 177 | FaceQueryFilter m_filter; |
| 178 | }; |
| 179 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 180 | /** |
| 181 | * \ingroup management |
| 182 | * \brief represents a faces/channels dataset |
| 183 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset |
| 184 | */ |
| 185 | class ChannelDataset : public StatusDataset |
| 186 | { |
| 187 | public: |
| 188 | ChannelDataset(); |
| 189 | |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 190 | using ResultType = std::vector<ChannelStatus>; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 191 | |
| 192 | ResultType |
| 193 | parseResult(ConstBufferPtr payload) const; |
| 194 | }; |
| 195 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 196 | /** |
| 197 | * \ingroup management |
| 198 | * \brief represents a fib/list dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame] | 199 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 200 | */ |
| 201 | class FibDataset : public StatusDataset |
| 202 | { |
| 203 | public: |
| 204 | FibDataset(); |
| 205 | |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 206 | using ResultType = std::vector<FibEntry>; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 207 | |
| 208 | ResultType |
| 209 | parseResult(ConstBufferPtr payload) const; |
| 210 | }; |
| 211 | |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 212 | /** |
| 213 | * \ingroup management |
| 214 | * \brief represents a cs/info dataset |
| 215 | * \sa https://redmine.named-data.net/projects/nfd/wiki/CsMgmt#CS-Information-Dataset |
| 216 | */ |
| 217 | class CsInfoDataset : public StatusDataset |
| 218 | { |
| 219 | public: |
| 220 | CsInfoDataset(); |
| 221 | |
| 222 | using ResultType = CsInfo; |
| 223 | |
| 224 | ResultType |
| 225 | parseResult(ConstBufferPtr payload) const; |
| 226 | }; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 227 | |
| 228 | /** |
| 229 | * \ingroup management |
| 230 | * \brief represents a strategy-choice/list dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame] | 231 | * \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] | 232 | */ |
| 233 | class StrategyChoiceDataset : public StatusDataset |
| 234 | { |
| 235 | public: |
| 236 | StrategyChoiceDataset(); |
| 237 | |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 238 | using ResultType = std::vector<StrategyChoice>; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 239 | |
| 240 | ResultType |
| 241 | parseResult(ConstBufferPtr payload) const; |
| 242 | }; |
| 243 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 244 | /** |
| 245 | * \ingroup management |
| 246 | * \brief represents a rib/list dataset |
Alexander Afanasyev | e6835fe | 2017-01-19 20:05:01 -0800 | [diff] [blame] | 247 | * \sa https://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 248 | */ |
| 249 | class RibDataset : public StatusDataset |
| 250 | { |
| 251 | public: |
| 252 | RibDataset(); |
| 253 | |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 254 | using ResultType = std::vector<RibEntry>; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 255 | |
| 256 | ResultType |
| 257 | parseResult(ConstBufferPtr payload) const; |
| 258 | }; |
| 259 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 260 | } // namespace nfd |
| 261 | } // namespace ndn |
| 262 | |
| 263 | #endif // NDN_MGMT_NFD_STATUS_DATASET_HPP |