]> sigrok.org Git - pulseview.git/blame - pv/storesession.h
Header: Fixed mouse over coordinates
[pulseview.git] / pv / storesession.h
CommitLineData
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
33namespace sigrok {
34class Output;
35}
36
0fbda3c2
JH
37namespace pv {
38
39class SigSession;
40
41namespace data {
42class LogicSnapshot;
43}
44
45class StoreSession : public QObject
46{
47 Q_OBJECT
48
49private:
50 static const size_t BlockSize;
51
52public:
53 StoreSession(const std::string &file_name,
54 const SigSession &session);
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
68private:
f9abf97e 69 void store_proc(std::shared_ptr<pv::data::LogicSnapshot> snapshot);
0fbda3c2 70
e9213170 71Q_SIGNALS:
0fbda3c2
JH
72 void progress_updated();
73
74private:
75 const std::string _file_name;
76 const SigSession &_session;
77
7223eb62
ML
78 std::shared_ptr<sigrok::Output> _output;
79
3b68d03d
JH
80 std::thread _thread;
81
82 std::atomic<bool> _interrupt;
0fbda3c2 83
e40b2f29 84 std::atomic<int> _units_stored, _unit_count;
b101c41e 85
3b68d03d 86 mutable std::mutex _mutex;
0fbda3c2
JH
87 QString _error;
88};
89
90} // pv
91
92#endif // PULSEVIEW_PV_STORESESSION_H