]> sigrok.org Git - pulseview.git/blame_incremental - pv/storesession.h
property: add the necessary include file for std::function
[pulseview.git] / pv / storesession.h
... / ...
CommitLineData
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
33namespace pv {
34
35class SigSession;
36
37namespace data {
38class LogicSnapshot;
39}
40
41class StoreSession : public QObject
42{
43 Q_OBJECT
44
45private:
46 static const size_t BlockSize;
47
48public:
49 StoreSession(const std::string &file_name,
50 const SigSession &session);
51
52 ~StoreSession();
53
54 std::pair<uint64_t, uint64_t> progress() const;
55
56 const QString& error() const;
57
58 bool start();
59
60 void wait();
61
62 void cancel();
63
64private:
65 void store_proc(std::shared_ptr<pv::data::LogicSnapshot> snapshot);
66
67signals:
68 void progress_updated();
69
70private:
71 const std::string _file_name;
72 const SigSession &_session;
73
74 std::thread _thread;
75
76 std::atomic<bool> _interrupt;
77
78 std::atomic<uint64_t> _units_stored, _unit_count;
79
80 mutable std::mutex _mutex;
81 QString _error;
82};
83
84} // pv
85
86#endif // PULSEVIEW_PV_STORESESSION_H