Debian Codegraph @

analyzers/src/watch/nc_windows/statistics_window.h

raw
1 //------------------------------------------------------------------------------
2 // Author: Vitali Adamenka
3 // Description: Header for describe ncurses statistic window.
4 // Copyright (c) 2015 EPAM Systems. All Rights Reserved.
5 //------------------------------------------------------------------------------
6 /*
7 This file is part of Nfstrace.
8
9 Nfstrace is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, version 2 of the License.
12
13 Nfstrace is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
20 */
21 //------------------------------------------------------------------------------
22 #ifndef STATISTICS_WINDOW_H
23 #define STATISTICS_WINDOW_H
24 //------------------------------------------------------------------------------
25 #include <vector>
26 #include <unordered_map>
27
28 #include "../protocols/abstract_protocol.h"
29 #include "main_window.h"
30 //------------------------------------------------------------------------------
31 class StatisticsWindow
32 {
33 using ProtocolStatistic = std::vector<std::size_t>;
34 using StatisticsContainers = std::unordered_map<AbstractProtocol*, ProtocolStatistic>;
35
36 public:
37 StatisticsWindow(MainWindow&, StatisticsContainers&);
38 ~StatisticsWindow();
39
40 /*! Scroll content of Statistic Winodow Up or Down
41 */
42 void scrollContent(int);
43
44 /*! Change active protocol. Print new protocl's commands.
45 */
46 void updateProtocol(AbstractProtocol*);
47
48 /*! Update counters on Statistics Window
49 */
50 void update(const ProtocolStatistic&);
51
52 /*! Resize Statistic Window
53 */
54 void resize(MainWindow&);
55
56 /*! Only set active protocol, do not update new protocol's commands.
57 */
58 void setProtocol(AbstractProtocol*);
59
60 private:
61 void destroy();
62 bool canWrite(unsigned int);
63
64 WINDOW* _window;
65 AbstractProtocol* _activeProtocol;
66 std::vector<std::string> _allProtocols;
67 std::unordered_map<AbstractProtocol*, unsigned int> _scrollOffset;
68 ProtocolStatistic _statistic;
69 };
70 //------------------------------------------------------------------------------
71 #endif //STATISTICS_WINDOWS_H
72 //------------------------------------------------------------------------------