blob: 363186e6099867fd53480dabce1b01b3fe0a3c6e [file] [log] [blame]
Junxiao Shi034c1882016-06-24 18:06:51 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2016 Regents of the University of California.
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_MANAGEMENT_NFD_STATUS_DATASET_HPP
23#define NDN_MANAGEMENT_NFD_STATUS_DATASET_HPP
24
25#include "../name.hpp"
26#include "nfd-forwarder-status.hpp"
27#include "nfd-face-status.hpp"
28#include "nfd-face-query-filter.hpp"
Junxiao Shi1eacb972016-07-07 22:51:07 +000029#include "nfd-channel-status.hpp"
Junxiao Shi034c1882016-06-24 18:06:51 +000030#include "nfd-fib-entry.hpp"
31#include "nfd-strategy-choice.hpp"
32#include "nfd-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:
45#ifdef DOXYGEN
46 /**
47 * \brief if defined, specifies constructor argument type;
48 * otherwise, constructor has no argument
49 */
50 typedef int ParamType;
51#endif
52
53 /**
54 * \brief constructs a name prefix for the dataset
55 * \param prefix top-level prefix, such as ndn:/localhost/nfd
56 * \return name prefix without version and segment components
57 */
58 Name
59 getDatasetPrefix(const Name& prefix) const;
60
61#ifdef DOXYGEN
62 /**
63 * \brief provides the result type, usually a vector
64 */
65 typedef std::vector<int> ResultType;
66#endif
67
68 /**
69 * \brief indicates reassembled payload cannot be parsed as ResultType
70 */
71 class ParseResultError : public tlv::Error
72 {
73 public:
74 explicit
75 ParseResultError(const std::string& what)
76 : tlv::Error(what)
77 {
78 }
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
91protected:
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
99private:
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
107private:
108 PartialName m_datasetName;
109};
110
111
112/**
113 * \ingroup management
114 * \brief represents a status/general dataset
115 * \sa http://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset
116 */
117class ForwarderGeneralStatusDataset : public StatusDataset
118{
119public:
120 ForwarderGeneralStatusDataset();
121
122 typedef ForwarderStatus ResultType;
123
124 ResultType
125 parseResult(ConstBufferPtr payload) const;
126};
127
128
129/**
130 * \ingroup management
131 * \brief provides common functionality among FaceDataset and FaceQueryDataset
132 */
133class FaceDatasetBase : public StatusDataset
134{
135public:
136 typedef std::vector<FaceStatus> ResultType;
137
138 ResultType
139 parseResult(ConstBufferPtr payload) const;
140
141protected:
142 explicit
143 FaceDatasetBase(const PartialName& datasetName);
144};
145
146
147/**
148 * \ingroup management
149 * \brief represents a faces/list dataset
150 * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
151 */
152class FaceDataset : public FaceDatasetBase
153{
154public:
155 FaceDataset();
156};
157
158
159/**
160 * \ingroup management
161 * \brief represents a faces/query dataset
162 * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Query-Operation
163 */
164class FaceQueryDataset : public FaceDatasetBase
165{
166public:
167 typedef FaceQueryFilter ParamType;
168
169 explicit
170 FaceQueryDataset(const FaceQueryFilter& filter);
171
172private:
173 virtual void
174 addParameters(Name& name) const override;
175
176private:
177 FaceQueryFilter m_filter;
178};
179
180
181/**
182 * \ingroup management
Junxiao Shi1eacb972016-07-07 22:51:07 +0000183 * \brief represents a faces/channels dataset
184 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset
185 */
186class ChannelDataset : public StatusDataset
187{
188public:
189 ChannelDataset();
190
191 typedef std::vector<ChannelStatus> ResultType;
192
193 ResultType
194 parseResult(ConstBufferPtr payload) const;
195};
196
197
198/**
199 * \ingroup management
Junxiao Shi034c1882016-06-24 18:06:51 +0000200 * \brief represents a fib/list dataset
201 * \sa http://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset
202 */
203class FibDataset : public StatusDataset
204{
205public:
206 FibDataset();
207
208 typedef std::vector<FibEntry> ResultType;
209
210 ResultType
211 parseResult(ConstBufferPtr payload) const;
212};
213
214
215/**
216 * \ingroup management
217 * \brief represents a strategy-choice/list dataset
218 * \sa http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy-Choice-Dataset
219 */
220class StrategyChoiceDataset : public StatusDataset
221{
222public:
223 StrategyChoiceDataset();
224
225 typedef std::vector<StrategyChoice> ResultType;
226
227 ResultType
228 parseResult(ConstBufferPtr payload) const;
229};
230
231
232/**
233 * \ingroup management
234 * \brief represents a rib/list dataset
235 * \sa http://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset
236 */
237class RibDataset : public StatusDataset
238{
239public:
240 RibDataset();
241
242 typedef std::vector<RibEntry> ResultType;
243
244 ResultType
245 parseResult(ConstBufferPtr payload) const;
246};
247
248
249} // namespace nfd
250} // namespace ndn
251
252#endif // NDN_MANAGEMENT_NFD_STATUS_DATASET_HPP