From: Uwe Hermann Date: Fri, 11 Jan 2019 00:26:21 +0000 (+0100) Subject: Factor out legacy_input.hpp. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3d1f327fde7fe33f08e3c3407135cd0bc2ffe7f3;p=libsigrokflow.git Factor out legacy_input.hpp. --- diff --git a/Makefile.am b/Makefile.am index 7d2409e..a131850 100644 --- a/Makefile.am +++ b/Makefile.am @@ -43,7 +43,8 @@ library_include_HEADERS = \ include/libsigrokflow/libsigrokflow.hpp \ include/libsigrokflow/main.hpp \ include/libsigrokflow/init.hpp \ - include/libsigrokflow/legacy_capture_device.hpp + include/libsigrokflow/legacy_capture_device.hpp \ + include/libsigrokflow/legacy_input.hpp pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libsigrokflow.pc diff --git a/include/libsigrokflow/legacy_input.hpp b/include/libsigrokflow/legacy_input.hpp new file mode 100644 index 0000000..2516adc --- /dev/null +++ b/include/libsigrokflow/legacy_input.hpp @@ -0,0 +1,79 @@ +/* + * This file is part of the libsigrokflow project. + * + * Copyright (C) 2018 Martin Ling + * Copyright (C) 2018 Uwe Hermann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LIBSIGROKFLOW_LEGACY_INPUT_HPP +#define LIBSIGROKFLOW_LEGACY_INPUT_HPP + +/* Temporary workaround, will be dropped later. */ +#define HAVE_LIBSIGROKCXX 1 + +#include +#ifdef HAVE_LIBSIGROKCXX +#include +#endif +#include + +namespace Srf +{ + +using namespace std; + +#ifdef HAVE_LIBSIGROKCXX +class LegacyInput : + public Gst::Element +{ +public: + /* Create from libsigrok input. */ + static Glib::RefPtr create( + shared_ptr format, + map options = map()); + + /* Chain function (not an override). */ + Gst::FlowReturn chain(const Glib::RefPtr &pad, + const Glib::RefPtr &buf); + + /* Event function (not an override). */ + bool event(const Glib::RefPtr &pad, + Glib::RefPtr &event); + + /* Gst class init. */ + static void class_init(Gst::ElementClass *klass); + + /* Register class with plugin. */ + static bool register_element(Glib::RefPtr plugin); + + /* Constructor used by element factory. */ + explicit LegacyInput(GstElement *gobj); + +private: + shared_ptr libsigrok_input_format_; + shared_ptr libsigrok_input_; + shared_ptr session_; + map options_; + Glib::RefPtr sink_pad_; + Glib::RefPtr src_pad_; + + void datafeed_callback(shared_ptr device, + shared_ptr packet); +}; +#endif + +} +#endif diff --git a/include/libsigrokflow/libsigrokflow.hpp b/include/libsigrokflow/libsigrokflow.hpp index 1a561a2..50c5eea 100644 --- a/include/libsigrokflow/libsigrokflow.hpp +++ b/include/libsigrokflow/libsigrokflow.hpp @@ -38,6 +38,7 @@ #include #include #include +#include namespace Srf { @@ -45,44 +46,6 @@ namespace Srf using namespace std; #ifdef HAVE_LIBSIGROKCXX -class LegacyInput : - public Gst::Element -{ -public: - /* Create from libsigrok input. */ - static Glib::RefPtr create( - shared_ptr format, - map options = map()); - - /* Chain function (not an override). */ - Gst::FlowReturn chain(const Glib::RefPtr &pad, - const Glib::RefPtr &buf); - - /* Event function (not an override). */ - bool event(const Glib::RefPtr &pad, - Glib::RefPtr &event); - - /* Gst class init. */ - static void class_init(Gst::ElementClass *klass); - - /* Register class with plugin. */ - static bool register_element(Glib::RefPtr plugin); - - /* Constructor used by element factory. */ - explicit LegacyInput(GstElement *gobj); - -private: - shared_ptr libsigrok_input_format_; - shared_ptr libsigrok_input_; - shared_ptr session_; - map options_; - Glib::RefPtr sink_pad_; - Glib::RefPtr src_pad_; - - void datafeed_callback(shared_ptr device, - shared_ptr packet); -}; - class LegacyOutput : public Sink { diff --git a/src/legacy_input.cpp b/src/legacy_input.cpp index 8a7c47c..084bf27 100644 --- a/src/legacy_input.cpp +++ b/src/legacy_input.cpp @@ -19,7 +19,8 @@ */ #include -#include +#include +#include namespace Srf {