]>
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 | ||
33 | namespace pv { | |
34 | ||
35 | class SigSession; | |
36 | ||
37 | namespace data { | |
38 | class LogicSnapshot; | |
39 | } | |
40 | ||
41 | class StoreSession : public QObject | |
42 | { | |
43 | Q_OBJECT | |
44 | ||
45 | private: | |
46 | static const size_t BlockSize; | |
47 | ||
48 | public: | |
49 | StoreSession(const std::string &file_name, | |
50 | const SigSession &session); | |
51 | ||
52 | ~StoreSession(); | |
53 | ||
e40b2f29 | 54 | std::pair<int, int> progress() const; |
0fbda3c2 JH |
55 | |
56 | const QString& error() const; | |
57 | ||
58 | bool start(); | |
59 | ||
60 | void wait(); | |
61 | ||
62 | void cancel(); | |
63 | ||
64 | private: | |
f9abf97e | 65 | void store_proc(std::shared_ptr<pv::data::LogicSnapshot> snapshot); |
0fbda3c2 JH |
66 | |
67 | signals: | |
68 | void progress_updated(); | |
69 | ||
70 | private: | |
71 | const std::string _file_name; | |
72 | const SigSession &_session; | |
73 | ||
3b68d03d JH |
74 | std::thread _thread; |
75 | ||
76 | std::atomic<bool> _interrupt; | |
0fbda3c2 | 77 | |
e40b2f29 | 78 | std::atomic<int> _units_stored, _unit_count; |
b101c41e | 79 | |
3b68d03d | 80 | mutable std::mutex _mutex; |
0fbda3c2 JH |
81 | QString _error; |
82 | }; | |
83 | ||
84 | } // pv | |
85 | ||
86 | #endif // PULSEVIEW_PV_STORESESSION_H |