blob: e3cc264bb5292c614b05852660b21cb3b9677c9d [file] [log] [blame]
Junxiao Shi7357ef22016-09-07 02:39:37 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Davide Pesavento7f20d6e2017-01-16 14:43:58 -05003 * Copyright (c) 2013-2017 Regents of the University of California.
Junxiao Shi7357ef22016-09-07 02:39:37 +00004 *
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
34namespace ndn {
35namespace nfd {
36
37/**
38 * \ingroup management
39 * \brief base class of NFD StatusDataset
40 * \sa http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
41 */
42class StatusDataset : noncopyable
43{
44public:
Davide Pesavento7f20d6e2017-01-16 14:43:58 -050045 virtual
46 ~StatusDataset();
47
Junxiao Shi7357ef22016-09-07 02:39:37 +000048#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
94protected:
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
102private:
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
110private:
111 PartialName m_datasetName;
112};
113
114
115/**
116 * \ingroup management
117 * \brief represents a status/general dataset
118 * \sa http://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset
119 */
120class ForwarderGeneralStatusDataset : public StatusDataset
121{
122public:
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 */
136class FaceDatasetBase : public StatusDataset
137{
138public:
139 typedef std::vector<FaceStatus> ResultType;
140
141 ResultType
142 parseResult(ConstBufferPtr payload) const;
143
144protected:
145 explicit
146 FaceDatasetBase(const PartialName& datasetName);
147};
148
149
150/**
151 * \ingroup management
152 * \brief represents a faces/list dataset
153 * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
154 */
155class FaceDataset : public FaceDatasetBase
156{
157public:
158 FaceDataset();
159};
160
161
162/**
163 * \ingroup management
164 * \brief represents a faces/query dataset
165 * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Query-Operation
166 */
167class FaceQueryDataset : public FaceDatasetBase
168{
169public:
170 typedef FaceQueryFilter ParamType;
171
172 explicit
173 FaceQueryDataset(const FaceQueryFilter& filter);
174
175private:
Davide Pesavento57c07df2016-12-11 18:41:45 -0500176 void
Junxiao Shi7357ef22016-09-07 02:39:37 +0000177 addParameters(Name& name) const override;
178
179private:
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 */
189class ChannelDataset : public StatusDataset
190{
191public:
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
204 * \sa http://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset
205 */
206class FibDataset : public StatusDataset
207{
208public:
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
221 * \sa http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy-Choice-Dataset
222 */
223class StrategyChoiceDataset : public StatusDataset
224{
225public:
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
238 * \sa http://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset
239 */
240class RibDataset : public StatusDataset
241{
242public:
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