]>
Commit | Line | Data |
---|---|---|
0fbda3c2 JH |
1 | /* |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
21 | #ifndef PULSEVIEW_PV_STORESESSION_H | |
22 | #define PULSEVIEW_PV_STORESESSION_H | |
23 | ||
24 | #include <stdint.h> | |
25 | ||
3b68d03d JH |
26 | #include <atomic> |
27 | #include <mutex> | |
0fbda3c2 | 28 | #include <string> |
3b68d03d | 29 | #include <thread> |
0fbda3c2 JH |
30 | |
31 | #include <QObject> | |
32 | ||
7223eb62 ML |
33 | namespace sigrok { |
34 | class Output; | |
35 | } | |
36 | ||
0fbda3c2 JH |
37 | namespace pv { |
38 | ||
2b81ae46 | 39 | class Session; |
0fbda3c2 JH |
40 | |
41 | namespace data { | |
42 | class LogicSnapshot; | |
43 | } | |
44 | ||
45 | class StoreSession : public QObject | |
46 | { | |
47 | Q_OBJECT | |
48 | ||
49 | private: | |
50 | static const size_t BlockSize; | |
51 | ||
52 | public: | |
53 | StoreSession(const std::string &file_name, | |
2b81ae46 | 54 | const Session &session); |
0fbda3c2 JH |
55 | |
56 | ~StoreSession(); | |
57 | ||
e40b2f29 | 58 | std::pair<int, int> progress() const; |
0fbda3c2 JH |
59 | |
60 | const QString& error() const; | |
61 | ||
62 | bool start(); | |
63 | ||
64 | void wait(); | |
65 | ||
66 | void cancel(); | |
67 | ||
68 | private: | |
f9abf97e | 69 | void store_proc(std::shared_ptr<pv::data::LogicSnapshot> snapshot); |
0fbda3c2 | 70 | |
e9213170 | 71 | Q_SIGNALS: |
0fbda3c2 JH |
72 | void progress_updated(); |
73 | ||
74 | private: | |
8dbbc7f0 | 75 | const std::string file_name_; |
2b81ae46 | 76 | const Session &session_; |
0fbda3c2 | 77 | |
8dbbc7f0 | 78 | std::shared_ptr<sigrok::Output> output_; |
7223eb62 | 79 | |
8dbbc7f0 | 80 | std::thread thread_; |
3b68d03d | 81 | |
8dbbc7f0 | 82 | std::atomic<bool> interrupt_; |
0fbda3c2 | 83 | |
8dbbc7f0 | 84 | std::atomic<int> units_stored_, unit_count_; |
b101c41e | 85 | |
8dbbc7f0 JH |
86 | mutable std::mutex mutex_; |
87 | QString error_; | |
0fbda3c2 JH |
88 | }; |
89 | ||
90 | } // pv | |
91 | ||
92 | #endif // PULSEVIEW_PV_STORESESSION_H |