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