blob: 8d8fe23f70df9f936eb05008abb6bcac6a93c31f [file] [log] [blame]
Qi Zhao7e524492017-03-02 15:05:45 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 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_STATUS_VIEWER_HPP
21#define NCC_STATUS_VIEWER_HPP
22
23#include "forwarder-status.hpp"
Qi Zhaobd19e072017-03-05 15:12:46 -080024#include "channel-status.hpp"
Qi Zhao078ac692017-03-02 16:28:51 -080025#include "face-status.hpp"
Qi Zhao7e524492017-03-02 15:05:45 -080026#include "fib-status.hpp"
27#include "rib-status.hpp"
Qi Zhaobd19e072017-03-05 15:12:46 -080028#include "strategy-status.hpp"
Qi Zhao7e524492017-03-02 15:05:45 -080029
30#include <ndn-cxx/face.hpp>
31#include <ndn-cxx/name.hpp>
32#include <ndn-cxx/util/scheduler.hpp>
Qi Zhaobd19e072017-03-05 15:12:46 -080033#include <ndn-cxx/mgmt/nfd/channel-status.hpp>
Qi Zhao078ac692017-03-02 16:28:51 -080034#include <ndn-cxx/mgmt/nfd/face-status.hpp>
Qi Zhao7e524492017-03-02 15:05:45 -080035#include <ndn-cxx/mgmt/nfd/fib-entry.hpp>
36#include <ndn-cxx/mgmt/nfd/rib-entry.hpp>
Qi Zhaobd19e072017-03-05 15:12:46 -080037#include <ndn-cxx/mgmt/nfd/strategy-choice.hpp>
Qi Zhao7e524492017-03-02 15:05:45 -080038#include <ndn-cxx/mgmt/nfd/controller.hpp>
39#include <ndn-cxx/mgmt/nfd/status-dataset.hpp>
40
41#include <QObject>
42#include <QtQml/QQmlContext>
43#include <QtQml/QQmlApplicationEngine>
44
45namespace ndn {
46
47class StatusViewer : public QObject
48{
49 Q_OBJECT
50public:
51 explicit
52 StatusViewer(Face& face, KeyChain& keyChain);
53
54 void
55 onStatusRetrieved(const nfd::ForwarderStatus& status);
56
57 void
Qi Zhaobd19e072017-03-05 15:12:46 -080058 onChannelStatusRetrieved(const std::vector<nfd::ChannelStatus>& status);
59
60 void
Qi Zhao078ac692017-03-02 16:28:51 -080061 onFaceStatusRetrieved(const std::vector<nfd::FaceStatus>& status);
62
63 void
Qi Zhao7e524492017-03-02 15:05:45 -080064 onFibStatusRetrieved(const std::vector<nfd::FibEntry>& status);
65
66 void
67 onRibStatusRetrieved(const std::vector<nfd::RibEntry>& status);
68
69 void
Qi Zhaobd19e072017-03-05 15:12:46 -080070 onStrategyChoiceStatusRetrieved(const std::vector<nfd::StrategyChoice>& status);
71
72 void
Qi Zhao7e524492017-03-02 15:05:45 -080073 onStatusTimeout();
74
75private:
76 void
77 requestNfdStatus();
78
79signals:
80 void
81 showStatus();
82
83public slots:
84 void
85 present();
86
Alexander Afanasyev8d1a3a02017-03-11 13:00:24 -080087 void
88 cancelEvents();
89
Qi Zhao7e524492017-03-02 15:05:45 -080090private:
Alexander Afanasyev8d1a3a02017-03-11 13:00:24 -080091 QQmlApplicationEngine m_engine;
Qi Zhao7e524492017-03-02 15:05:45 -080092
Alexander Afanasyev8d1a3a02017-03-11 13:00:24 -080093 Face& m_face;
94 KeyChain& m_keyChain;
95 nfd::Controller* m_controller;
96 Scheduler m_scheduler;
97 util::scheduler::ScopedEventId m_nextStatusRetrieval;
Qi Zhao7e524492017-03-02 15:05:45 -080098
Alexander Afanasyev8d1a3a02017-03-11 13:00:24 -080099 ForwarderStatusModel m_forwarderStatusModel;
100 ChannelStatusModel m_channelModel;
101 FaceStatusModel m_faceModel;
102 FibStatusModel m_fibModel;
103 RibStatusModel m_ribModel;
104 StrategyStatusModel m_strategyModel;
Qi Zhao7e524492017-03-02 15:05:45 -0800105};
106
107} // namespace ndn
108
109#endif // NCC_STATUS_VIEWER_HPP