]>
Commit | Line | Data |
---|---|---|
da30ecb7 JH |
1 | /* |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2015 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 | |
efdec55a | 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
da30ecb7 JH |
18 | */ |
19 | ||
20 | #include <libsigrokcxx/libsigrokcxx.hpp> | |
21 | ||
b485408f JH |
22 | #include <boost/filesystem.hpp> |
23 | ||
da30ecb7 JH |
24 | #include "sessionfile.hpp" |
25 | ||
6f925ba9 UH |
26 | using std::shared_ptr; |
27 | using std::string; | |
28 | ||
da30ecb7 JH |
29 | namespace pv { |
30 | namespace devices { | |
31 | ||
6f925ba9 UH |
32 | SessionFile::SessionFile(const shared_ptr<sigrok::Context> context, |
33 | const string &file_name) : | |
474e817a | 34 | File(file_name), |
2ad82c2e UH |
35 | context_(context) |
36 | { | |
b485408f JH |
37 | } |
38 | ||
2ad82c2e UH |
39 | void SessionFile::open() |
40 | { | |
4d6c6ea3 SA |
41 | if (session_) |
42 | close(); | |
43 | ||
da30ecb7 JH |
44 | session_ = context_->load_session(file_name_); |
45 | device_ = session_->devices()[0]; | |
46 | } | |
47 | ||
2ad82c2e UH |
48 | void SessionFile::close() |
49 | { | |
4d6c6ea3 SA |
50 | if (session_) |
51 | session_->remove_devices(); | |
52 | } | |
53 | ||
da30ecb7 JH |
54 | } // namespace devices |
55 | } // namespace pv |