]> sigrok.org Git - pulseview.git/blob - pv/devices/sessionfile.cpp
1e8c3acda039f3184e32e701972f16b7f5617bfd
[pulseview.git] / pv / devices / sessionfile.cpp
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
17  * along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include <libsigrokcxx/libsigrokcxx.hpp>
21
22 #include <boost/filesystem.hpp>
23
24 #include "sessionfile.hpp"
25
26 namespace pv {
27 namespace devices {
28
29 SessionFile::SessionFile(const std::shared_ptr<sigrok::Context> context,
30         const std::string &file_name) :
31         File(file_name),
32         context_(context)
33 {
34 }
35
36 void SessionFile::open()
37 {
38         if (session_)
39                 close();
40
41         session_ = context_->load_session(file_name_);
42         device_ = session_->devices()[0];
43 }
44
45 void SessionFile::close()
46 {
47         if (session_)
48                 session_->remove_devices();
49 }
50
51 } // namespace devices
52 } // namespace pv