Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 1 | /* -*- 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 Zhao | bd19e07 | 2017-03-05 15:12:46 -0800 | [diff] [blame] | 24 | #include "channel-status.hpp" |
Qi Zhao | 078ac69 | 2017-03-02 16:28:51 -0800 | [diff] [blame] | 25 | #include "face-status.hpp" |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 26 | #include "fib-status.hpp" |
| 27 | #include "rib-status.hpp" |
Qi Zhao | bd19e07 | 2017-03-05 15:12:46 -0800 | [diff] [blame] | 28 | #include "strategy-status.hpp" |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 29 | |
| 30 | #include <ndn-cxx/face.hpp> |
| 31 | #include <ndn-cxx/name.hpp> |
| 32 | #include <ndn-cxx/util/scheduler.hpp> |
Qi Zhao | bd19e07 | 2017-03-05 15:12:46 -0800 | [diff] [blame] | 33 | #include <ndn-cxx/mgmt/nfd/channel-status.hpp> |
Qi Zhao | 078ac69 | 2017-03-02 16:28:51 -0800 | [diff] [blame] | 34 | #include <ndn-cxx/mgmt/nfd/face-status.hpp> |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 35 | #include <ndn-cxx/mgmt/nfd/fib-entry.hpp> |
| 36 | #include <ndn-cxx/mgmt/nfd/rib-entry.hpp> |
Qi Zhao | bd19e07 | 2017-03-05 15:12:46 -0800 | [diff] [blame] | 37 | #include <ndn-cxx/mgmt/nfd/strategy-choice.hpp> |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 38 | #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 | |
| 45 | namespace ndn { |
| 46 | |
| 47 | class StatusViewer : public QObject |
| 48 | { |
| 49 | Q_OBJECT |
| 50 | public: |
| 51 | explicit |
| 52 | StatusViewer(Face& face, KeyChain& keyChain); |
| 53 | |
| 54 | void |
| 55 | onStatusRetrieved(const nfd::ForwarderStatus& status); |
| 56 | |
| 57 | void |
Qi Zhao | bd19e07 | 2017-03-05 15:12:46 -0800 | [diff] [blame] | 58 | onChannelStatusRetrieved(const std::vector<nfd::ChannelStatus>& status); |
| 59 | |
| 60 | void |
Qi Zhao | 078ac69 | 2017-03-02 16:28:51 -0800 | [diff] [blame] | 61 | onFaceStatusRetrieved(const std::vector<nfd::FaceStatus>& status); |
| 62 | |
| 63 | void |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 64 | onFibStatusRetrieved(const std::vector<nfd::FibEntry>& status); |
| 65 | |
| 66 | void |
| 67 | onRibStatusRetrieved(const std::vector<nfd::RibEntry>& status); |
| 68 | |
| 69 | void |
Qi Zhao | bd19e07 | 2017-03-05 15:12:46 -0800 | [diff] [blame] | 70 | onStrategyChoiceStatusRetrieved(const std::vector<nfd::StrategyChoice>& status); |
| 71 | |
| 72 | void |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 73 | onStatusTimeout(); |
| 74 | |
| 75 | private: |
| 76 | void |
| 77 | requestNfdStatus(); |
| 78 | |
| 79 | signals: |
| 80 | void |
| 81 | showStatus(); |
| 82 | |
| 83 | public slots: |
| 84 | void |
| 85 | present(); |
| 86 | |
Alexander Afanasyev | 8d1a3a0 | 2017-03-11 13:00:24 -0800 | [diff] [blame] | 87 | void |
| 88 | cancelEvents(); |
| 89 | |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 90 | private: |
Alexander Afanasyev | 8d1a3a0 | 2017-03-11 13:00:24 -0800 | [diff] [blame] | 91 | QQmlApplicationEngine m_engine; |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 92 | |
Alexander Afanasyev | 8d1a3a0 | 2017-03-11 13:00:24 -0800 | [diff] [blame] | 93 | Face& m_face; |
| 94 | KeyChain& m_keyChain; |
| 95 | nfd::Controller* m_controller; |
| 96 | Scheduler m_scheduler; |
| 97 | util::scheduler::ScopedEventId m_nextStatusRetrieval; |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 98 | |
Alexander Afanasyev | 8d1a3a0 | 2017-03-11 13:00:24 -0800 | [diff] [blame] | 99 | ForwarderStatusModel m_forwarderStatusModel; |
| 100 | ChannelStatusModel m_channelModel; |
| 101 | FaceStatusModel m_faceModel; |
| 102 | FibStatusModel m_fibModel; |
| 103 | RibStatusModel m_ribModel; |
| 104 | StrategyStatusModel m_strategyModel; |
Qi Zhao | 7e52449 | 2017-03-02 15:05:45 -0800 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | } // namespace ndn |
| 108 | |
| 109 | #endif // NCC_STATUS_VIEWER_HPP |