blob: 0d4282e3286d9233c1bc8895308e67880792d1a7 [file] [log] [blame]
taylorchuc27dd482014-05-17 20:06:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Qi Zhao7e524492017-03-02 15:05:45 -08003 * Copyright (c) 2013-2017, Regents of the University of California,
taylorchuc27dd482014-05-17 20:06:49 -07004 *
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_FORWARDER_STATUS_HPP
21#define NCC_FORWARDER_STATUS_HPP
22
23#include <QtCore/QAbstractListModel>
24#include <QtCore/QStringList>
25
Qi Zhao7e524492017-03-02 15:05:45 -080026#include <ndn-cxx/interest.hpp>
Qi Zhao0e043e52016-12-05 18:27:09 -080027#include <ndn-cxx/mgmt/nfd/forwarder-status.hpp>
taylorchuc27dd482014-05-17 20:06:49 -070028
29namespace ndn {
30
31class ForwarderStatusItem
32{
33public:
34 ForwarderStatusItem(const QString& type, const QString& value)
35 : m_type(type)
36 , m_value(value)
37 {
38 }
39
40 const QString&
41 type() const
42 {
43 return m_type;
44 }
45
46 const QString&
47 value() const
48 {
49 return m_value;
50 }
51
52private:
53 QString m_type;
54 QString m_value;
55};
56
57
58class ForwarderStatusModel : public QAbstractListModel
59{
60 Q_OBJECT
61
62signals:
63 void
Qi Zhao0e043e52016-12-05 18:27:09 -080064 onDataReceived(ndn::nfd::ForwarderStatus status);
taylorchuc27dd482014-05-17 20:06:49 -070065
66public:
67
68 enum ForwarderStatusRoles {
69 TypeRole = Qt::UserRole + 1,
70 ValueRole
71 };
72
73 explicit
Alexander Afanasyev4086d512014-07-11 15:56:33 -070074 ForwarderStatusModel(QObject* parent = 0);
taylorchuc27dd482014-05-17 20:06:49 -070075
76 int
77 rowCount(const QModelIndex& parent = QModelIndex()) const;
78
79 void
80 addItem(const ForwarderStatusItem& item);
81
82 QVariant
83 data(const QModelIndex& index, int role) const;
84
85 QHash<int, QByteArray>
86 roleNames() const;
87
taylorchuc27dd482014-05-17 20:06:49 -070088 void
89 clear();
90
91 void
taylorchuc27dd482014-05-17 20:06:49 -070092 onTimeout(const Interest& interest);
93
94private slots:
95
96 void
Qi Zhao0e043e52016-12-05 18:27:09 -080097 updateStatus(ndn::nfd::ForwarderStatus status);
taylorchuc27dd482014-05-17 20:06:49 -070098
99private:
taylorchuc27dd482014-05-17 20:06:49 -0700100 QList<ForwarderStatusItem> m_items;
101};
102
103} // namespace ndn
104
105#endif // NCC_FORWARDER_STATUS_HPP