blob: 0ebd80ec48bc503e4eb721db1e2cd008294b5a42 [file] [log] [blame]
taylorchuc27dd482014-05-17 20:06:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2014, 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_FIB_STATUS_HPP
21#define NCC_FIB_STATUS_HPP
22
23#include <QtCore/QAbstractListModel>
24#include <QtCore/QStringList>
25
26namespace ndn {
27class Face;
28class Data;
29
30class FibStatusItem
31{
32public:
33 FibStatusItem(const QString &prefix, uint64_t faceId, uint64_t cost)
34 : m_prefix(prefix)
35 , m_faceId(faceId)
36 , m_cost(cost)
37 {
38 }
39
40 const QString&
41 prefix() const
42 {
43 return m_prefix;
44 }
45
46 uint64_t
47 faceId() const
48 {
49 return m_faceId;
50 }
51
52 uint64_t
53 cost() const
54 {
55 return m_cost;
56 }
57
58private:
59 QString m_prefix;
60 uint64_t m_faceId;
61 uint64_t m_cost;
62};
63
64class FibStatusModel : public QAbstractListModel
65{
66 Q_OBJECT
67
68public:
69 enum FibStatusRoles {
70 PrefixRole = Qt::UserRole + 1,
71 FaceIdRole,
72 CostRole
73 };
74
75 explicit
76 FibStatusModel(Face& face, QObject *parent = 0);
77
78 int
79 rowCount(const QModelIndex &parent = QModelIndex()) const;
80
81 void
82 addItem(const FibStatusItem &item);
83
84 QVariant
85 data(const QModelIndex & index, int role) const;
86
87 QHash<int, QByteArray>
88 roleNames() const;
89
90 void
91 clear();
92
93 Q_INVOKABLE void
94 fetchFibInformation();
95
96 void
97 afterFetchedFibEnumerationInformation();
98
99 void
100 fetchSegments(const Data& data, void (FibStatusModel::*onDone)());
101
102 void
103 onTimeout();
104
105private:
106 Face& m_face;
107 QList<FibStatusItem> m_items;
108 // shared_ptr<OBufferStream> m_buffer;
109};
110
111} // namespace ndn
112
113#endif // NCC_FIB_STATUS_HPP