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