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