]>
Commit | Line | Data |
---|---|---|
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 | ||
26 | #include <atomic> | |
27 | #include <mutex> | |
28 | #include <string> | |
29 | #include <thread> | |
30 | ||
31 | #include <QObject> | |
32 | ||
33 | namespace sigrok { | |
34 | class Output; | |
35 | } | |
36 | ||
37 | namespace pv { | |
38 | ||
39 | class Session; | |
40 | ||
41 | namespace data { | |
42 | class LogicSegment; | |
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, | |
54 | const Session &session); | |
55 | ||
56 | ~StoreSession(); | |
57 | ||
58 | std::pair<int, int> progress() const; | |
59 | ||
60 | const QString& error() const; | |
61 | ||
62 | bool start(); | |
63 | ||
64 | void wait(); | |
65 | ||
66 | void cancel(); | |
67 | ||
68 | private: | |
69 | void store_proc(std::shared_ptr<pv::data::LogicSegment> segment); | |
70 | ||
71 | Q_SIGNALS: | |
72 | void progress_updated(); | |
73 | ||
74 | private: | |
75 | const std::string file_name_; | |
76 | const Session &session_; | |
77 | ||
78 | std::shared_ptr<sigrok::Output> output_; | |
79 | ||
80 | std::thread thread_; | |
81 | ||
82 | std::atomic<bool> interrupt_; | |
83 | ||
84 | std::atomic<int> units_stored_, unit_count_; | |
85 | ||
86 | mutable std::mutex mutex_; | |
87 | QString error_; | |
88 | }; | |
89 | ||
90 | } // pv | |
91 | ||
92 | #endif // PULSEVIEW_PV_STORESESSION_H |