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" |
| 24 | #include "fib-status.hpp" |
| 25 | #include "rib-status.hpp" |
| 26 | |
| 27 | #include <ndn-cxx/face.hpp> |
| 28 | #include <ndn-cxx/name.hpp> |
| 29 | #include <ndn-cxx/util/scheduler.hpp> |
| 30 | #include <ndn-cxx/mgmt/nfd/fib-entry.hpp> |
| 31 | #include <ndn-cxx/mgmt/nfd/rib-entry.hpp> |
| 32 | #include <ndn-cxx/mgmt/nfd/controller.hpp> |
| 33 | #include <ndn-cxx/mgmt/nfd/status-dataset.hpp> |
| 34 | |
| 35 | #include <QObject> |
| 36 | #include <QtQml/QQmlContext> |
| 37 | #include <QtQml/QQmlApplicationEngine> |
| 38 | |
| 39 | namespace ndn { |
| 40 | |
| 41 | class StatusViewer : public QObject |
| 42 | { |
| 43 | Q_OBJECT |
| 44 | public: |
| 45 | explicit |
| 46 | StatusViewer(Face& face, KeyChain& keyChain); |
| 47 | |
| 48 | void |
| 49 | onStatusRetrieved(const nfd::ForwarderStatus& status); |
| 50 | |
| 51 | void |
| 52 | onFibStatusRetrieved(const std::vector<nfd::FibEntry>& status); |
| 53 | |
| 54 | void |
| 55 | onRibStatusRetrieved(const std::vector<nfd::RibEntry>& status); |
| 56 | |
| 57 | void |
| 58 | onStatusTimeout(); |
| 59 | |
| 60 | private: |
| 61 | void |
| 62 | requestNfdStatus(); |
| 63 | |
| 64 | signals: |
| 65 | void |
| 66 | showStatus(); |
| 67 | |
| 68 | public slots: |
| 69 | void |
| 70 | present(); |
| 71 | |
| 72 | private: |
| 73 | Face& s_face; |
| 74 | KeyChain& s_keyChain; |
| 75 | nfd::Controller* s_controller; |
| 76 | Scheduler s_scheduler; |
| 77 | |
| 78 | QQmlApplicationEngine s_engine; |
| 79 | |
| 80 | ForwarderStatusModel s_forwarderStatusModel; |
| 81 | FibStatusModel s_fibModel; |
| 82 | RibStatusModel s_ribModel; |
| 83 | }; |
| 84 | |
| 85 | } // namespace ndn |
| 86 | |
| 87 | #endif // NCC_STATUS_VIEWER_HPP |