blob: 1131317abaa3cacb7850c5df5d3f3ea28c33e468 [file] [log] [blame]
Qi Zhao078ac692017-03-02 16:28:51 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2017, Regents of the University of California,
4 *
5 * This file is part of NFD Control Center. See AUTHORS.md for complete list of NFD
6 * authors and contributors.
7 *
8 * NFD Control Center is free software: you can redistribute it and/or modify it under the
9 * terms of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with NFD
17 * Control Center, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef NCC_FACE_STATUS_HPP
21#define NCC_FACE_STATUS_HPP
22
23#include <QtCore/QAbstractListModel>
24#include <QtCore/QStringList>
25
26#include <ndn-cxx/mgmt/nfd/face-status.hpp>
27
28namespace ndn {
29
30class FaceStatusItem
31{
32public:
33 FaceStatusItem(uint64_t faceId, const QString& remote, const QString& local, const QString& scope, const QString& persistency,
34 const QString& linkType, uint64_t inInterest, uint64_t outInterest, uint64_t inData, uint64_t outData,
35 uint64_t inByte, uint64_t outByte, uint64_t inNack, uint64_t outNack)
36 : m_faceId(faceId)
37 , m_remote(remote)
38 , m_local(local)
39 , m_scope(scope)
40 , m_persistency(persistency)
41 , m_linkType(linkType)
42 , m_inInterest(inInterest)
43 , m_outInterest(outInterest)
44 , m_inData(inData)
45 , m_outData(outData)
46 , m_inByte(inByte)
47 , m_outByte(outByte)
48 , m_inNack(inNack)
49 , m_outNack(outNack)
50 {
51 }
52
53 uint64_t
54 faceId() const
55 {
56 return m_faceId;
57 }
58
59 const QString&
60 remote() const
61 {
62 return m_remote;
63 }
64
65 const QString&
66 local() const
67 {
68 return m_local;
69 }
70
71 const QString&
72 scope() const
73 {
74 return m_scope;
75 }
76
77 const QString&
78 persistency() const
79 {
80 return m_persistency;
81 }
82
83 const QString&
84 linkType() const
85 {
86 return m_linkType;
87 }
88
89 uint64_t
90 inInterest() const
91 {
92 return m_inInterest;
93 }
94
95 uint64_t
96 outInterest() const
97 {
98 return m_outInterest;
99 }
100
101 uint64_t
102 inData() const
103 {
104 return m_inData;
105 }
106
107 uint64_t
108 outData() const
109 {
110 return m_outData;
111 }
112
113 uint64_t
114 inByte() const
115 {
116 return m_inByte;
117 }
118
119 uint64_t
120 outByte() const
121 {
122 return m_outByte;
123 }
124
125 uint64_t
126 inNack() const
127 {
128 return m_inNack;
129 }
130
131 uint64_t
132 outNack() const
133 {
134 return m_outNack;
135 }
136
137private:
138 uint64_t m_faceId;
139 QString m_remote;
140 QString m_local;
141 QString m_scope;
142 QString m_persistency;
143 QString m_linkType;
144 uint64_t m_inInterest;
145 uint64_t m_outInterest;
146 uint64_t m_inData;
147 uint64_t m_outData;
148 uint64_t m_inByte;
149 uint64_t m_outByte;
150 uint64_t m_inNack;
151 uint64_t m_outNack;
152};
153
154class FaceStatusModel : public QAbstractListModel
155{
156 Q_OBJECT
157
158signals:
159 void
160 onDataReceived(std::vector<ndn::nfd::FaceStatus> status);
161
162public:
163 enum FaceStatusRoles {
164 FaceIdRole = Qt::UserRole + 1,
165 RemoteRole,
166 LocalRole,
167 ScopeRole,
168 PersistencyRole,
169 LinkTypeRole,
170 InInterestRole,
171 OutInterestRole,
172 InDataRole,
173 OutDataRole,
174 InByteRole,
175 OutByteRole,
176 InNackRole,
177 OutNackRole
178 };
179
180 explicit
181 FaceStatusModel(QObject* parent = 0);
182
183 int
184 rowCount(const QModelIndex& parent = QModelIndex()) const;
185
186 void
187 addItem(const FaceStatusItem& item);
188
189 QVariant
190 data(const QModelIndex& index, int role) const;
191
192 QHash<int, QByteArray>
193 roleNames() const;
194
195 void
196 clear();
197
198 void
199 onTimeout();
200
201private slots:
202
203 void
204 updateStatus(std::vector<ndn::nfd::FaceStatus> status);
205
206private:
207 QList<FaceStatusItem> m_items;
208};
209
210} // namespace ndn
211
212#endif // NCC_FACE_STATUS_HPP