blob: 39537bc1d83376370d4695d6cc439ed0fe69ee9b [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"
29#include "nfd-fib-entry.hpp"
30#include "nfd-strategy-choice.hpp"
31#include "nfd-rib-entry.hpp"
32
33namespace ndn {
34namespace nfd {
35
36/**
37 * \ingroup management
38 * \brief base class of NFD StatusDataset
39 * \sa http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
40 */
41class StatusDataset : noncopyable
42{
43public:
44#ifdef DOXYGEN
45 /**
46 * \brief if defined, specifies constructor argument type;
47 * otherwise, constructor has no argument
48 */
49 typedef int ParamType;
50#endif
51
52 /**
53 * \brief constructs a name prefix for the dataset
54 * \param prefix top-level prefix, such as ndn:/localhost/nfd
55 * \return name prefix without version and segment components
56 */
57 Name
58 getDatasetPrefix(const Name& prefix) const;
59
60#ifdef DOXYGEN
61 /**
62 * \brief provides the result type, usually a vector
63 */
64 typedef std::vector<int> ResultType;
65#endif
66
67 /**
68 * \brief indicates reassembled payload cannot be parsed as ResultType
69 */
70 class ParseResultError : public tlv::Error
71 {
72 public:
73 explicit
74 ParseResultError(const std::string& what)
75 : tlv::Error(what)
76 {
77 }
78 };
79
80#ifdef DOXYGEN
81 /**
82 * \brief parses a result from reassembled payload
83 * \param payload reassembled payload
84 * \throw tlv::Error cannot parse payload
85 */
86 ResultType
87 parseResult(ConstBufferPtr payload) const;
88#endif
89
90protected:
91 /**
92 * \brief constructs a StatusDataset instance with given sub-prefix
93 * \param datasetName dataset name after top-level prefix, such as faces/list
94 */
95 explicit
96 StatusDataset(const PartialName& datasetName);
97
98private:
99 /**
100 * \brief appends parameters to the dataset name prefix
101 * \param[in,out] the dataset name prefix onto which parameter components can be appended
102 */
103 virtual void
104 addParameters(Name& name) const;
105
106private:
107 PartialName m_datasetName;
108};
109
110
111/**
112 * \ingroup management
113 * \brief represents a status/general dataset
114 * \sa http://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset
115 */
116class ForwarderGeneralStatusDataset : public StatusDataset
117{
118public:
119 ForwarderGeneralStatusDataset();
120
121 typedef ForwarderStatus ResultType;
122
123 ResultType
124 parseResult(ConstBufferPtr payload) const;
125};
126
127
128/**
129 * \ingroup management
130 * \brief provides common functionality among FaceDataset and FaceQueryDataset
131 */
132class FaceDatasetBase : public StatusDataset
133{
134public:
135 typedef std::vector<FaceStatus> ResultType;
136
137 ResultType
138 parseResult(ConstBufferPtr payload) const;
139
140protected:
141 explicit
142 FaceDatasetBase(const PartialName& datasetName);
143};
144
145
146/**
147 * \ingroup management
148 * \brief represents a faces/list dataset
149 * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
150 */
151class FaceDataset : public FaceDatasetBase
152{
153public:
154 FaceDataset();
155};
156
157
158/**
159 * \ingroup management
160 * \brief represents a faces/query dataset
161 * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Query-Operation
162 */
163class FaceQueryDataset : public FaceDatasetBase
164{
165public:
166 typedef FaceQueryFilter ParamType;
167
168 explicit
169 FaceQueryDataset(const FaceQueryFilter& filter);
170
171private:
172 virtual void
173 addParameters(Name& name) const override;
174
175private:
176 FaceQueryFilter m_filter;
177};
178
179
180/**
181 * \ingroup management
182 * \brief represents a fib/list dataset
183 * \sa http://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset
184 */
185class FibDataset : public StatusDataset
186{
187public:
188 FibDataset();
189
190 typedef std::vector<FibEntry> ResultType;
191
192 ResultType
193 parseResult(ConstBufferPtr payload) const;
194};
195
196
197/**
198 * \ingroup management
199 * \brief represents a strategy-choice/list dataset
200 * \sa http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy-Choice-Dataset
201 */
202class StrategyChoiceDataset : public StatusDataset
203{
204public:
205 StrategyChoiceDataset();
206
207 typedef std::vector<StrategyChoice> ResultType;
208
209 ResultType
210 parseResult(ConstBufferPtr payload) const;
211};
212
213
214/**
215 * \ingroup management
216 * \brief represents a rib/list dataset
217 * \sa http://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset
218 */
219class RibDataset : public StatusDataset
220{
221public:
222 RibDataset();
223
224 typedef std::vector<RibEntry> ResultType;
225
226 ResultType
227 parseResult(ConstBufferPtr payload) const;
228};
229
230
231} // namespace nfd
232} // namespace ndn
233
234#endif // NDN_MANAGEMENT_NFD_STATUS_DATASET_HPP