]> sigrok.org Git - libsigrokflow.git/blame - src/init.cpp
Factor out legacy_decoder.hpp.
[libsigrokflow.git] / src / init.cpp
CommitLineData
fc5450cb
UH
1/*
2 * This file is part of the libsigrokflow project.
3 *
4 * Copyright (C) 2018 Martin Ling <martin-sigrok@earth.li>
5 * Copyright (C) 2018 Uwe Hermann <uwe@hermann-uwe.de>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <config.h>
8ab86460
UH
22#include <gstreamermm.h>
23#include <libsigrokflow/init.hpp>
24#include <libsigrokflow/legacy_capture_device.hpp>
25#include <libsigrokflow/legacy_input.hpp>
26#include <libsigrokflow/legacy_output.hpp>
27#include <libsigrokflow/legacy_decoder.hpp>
fc5450cb
UH
28
29namespace Srf
30{
8ab86460 31using namespace std;
fc5450cb
UH
32
33static bool srf_initialized_ = false;
34
35void init()
36{
37 if (srf_initialized_)
38 throw runtime_error("libsigrokflow is already initialized");
39
40 if (!Gst::is_initialized())
41 throw runtime_error("Gst::init() has not run yet");
42
43#ifdef HAVE_LIBSIGROKCXX
44 Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
45 "sigrok_legacy_capture_device",
46 "Wrapper for capture devices using legacy libsigrok APIs",
47 sigc::ptr_fun(&LegacyCaptureDevice::register_element),
6abc3268 48 "0.01", "GPL", "sigrok", "libsigrokflow", "https://sigrok.org");
fc5450cb
UH
49 Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
50 "sigrok_legacy_input",
51 "Wrapper for inputs using legacy libsigrok APIs",
52 sigc::ptr_fun(&LegacyInput::register_element),
6abc3268 53 "0.01", "GPL", "sigrok", "libsigrokflow", "https://sigrok.org");
fc5450cb
UH
54 Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
55 "sigrok_legacy_output",
56 "Wrapper for outputs using legacy libsigrok APIs",
57 sigc::ptr_fun(&LegacyOutput::register_element),
6abc3268 58 "0.01", "GPL", "sigrok", "libsigrokflow", "https://sigrok.org");
fc5450cb
UH
59#endif
60#ifdef HAVE_LIBSIGROKDECODE
61 Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
62 "sigrok_legacy_decoder",
63 "Wrapper for protocol decoders using legacy libsigrokdecode APIs",
64 sigc::ptr_fun(&LegacyDecoder::register_element),
6abc3268 65 "0.01", "GPL", "sigrok", "libsigrokflow", "https://sigrok.org");
fc5450cb
UH
66#endif
67
68 srf_initialized_ = true;
69}
70
71void deinit()
72{
73 if (!srf_initialized_)
74 throw runtime_error("libsigrokflow is not initialized");
75
76 srf_initialized_ = false;
77}
78
79}