blob: f3d2c5e065f7b2de2134ce38682537132aef0357 [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
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -080040 * \sa https://redmine.named-data.net/projects/nfd/wiki/StatusDataset
Junxiao Shi7357ef22016-09-07 02:39:37 +000041 */
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
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800118 * \sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000119 */
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
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800153 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000154 */
155class FaceDataset : public FaceDatasetBase
156{
157public:
158 FaceDataset();
159};
160
161
162/**
163 * \ingroup management
164 * \brief represents a faces/query dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800165 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Query-Operation
Junxiao Shi7357ef22016-09-07 02:39:37 +0000166 */
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
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800204 * \sa https://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000205 */
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
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800221 * \sa https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy-Choice-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000222 */
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
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800238 * \sa https://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000239 */
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