From: Uwe Hermann Date: Fri, 11 Jan 2019 00:22:40 +0000 (+0100) Subject: Factor out legacy_capture_device.hpp. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a43e20056ce0df6e576459095dff9784a14f0895;p=libsigrokflow.git Factor out legacy_capture_device.hpp. --- diff --git a/Makefile.am b/Makefile.am index c37e17e..7d2409e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,7 +42,8 @@ library_includedir = $(includedir)/libsigrokflow library_include_HEADERS = \ include/libsigrokflow/libsigrokflow.hpp \ include/libsigrokflow/main.hpp \ - include/libsigrokflow/init.hpp + include/libsigrokflow/init.hpp \ + include/libsigrokflow/legacy_capture_device.hpp pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libsigrokflow.pc diff --git a/include/libsigrokflow/legacy_capture_device.hpp b/include/libsigrokflow/legacy_capture_device.hpp new file mode 100644 index 0000000..03ff571 --- /dev/null +++ b/include/libsigrokflow/legacy_capture_device.hpp @@ -0,0 +1,76 @@ +/* + * 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_CAPTURE_DEVICE_HPP +#define LIBSIGROKFLOW_LEGACY_CAPTURE_DEVICE_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 LegacyCaptureDevice : + public CaptureDevice +{ +public: + /* Create from libsigrok device object. */ + static Glib::RefPtr create( + shared_ptr libsigrok_device); + + /* Retrieve libsigrok device object. */ + shared_ptr libsigrok_device(); + + /* Override state change. */ + Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition) override; + + /* 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 LegacyCaptureDevice(GstElement *gobj); + +private: + shared_ptr libsigrok_device_; + Glib::RefPtr src_pad_; + Glib::Threads::RecMutex mutex_; + Glib::RefPtr task_; + shared_ptr session_; + + void datafeed_callback(shared_ptr device, + shared_ptr packet); + void run(); +}; +#endif + +} +#endif diff --git a/include/libsigrokflow/libsigrokflow.hpp b/include/libsigrokflow/libsigrokflow.hpp index 6bd159f..1a561a2 100644 --- a/include/libsigrokflow/libsigrokflow.hpp +++ b/include/libsigrokflow/libsigrokflow.hpp @@ -37,6 +37,7 @@ #include #include +#include namespace Srf { @@ -44,41 +45,6 @@ namespace Srf using namespace std; #ifdef HAVE_LIBSIGROKCXX -class LegacyCaptureDevice : - public CaptureDevice -{ -public: - /* Create from libsigrok device object. */ - static Glib::RefPtr create( - shared_ptr libsigrok_device); - - /* Retrieve libsigrok device object. */ - shared_ptr libsigrok_device(); - - /* Override state change. */ - Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition) override; - - /* 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 LegacyCaptureDevice(GstElement *gobj); - -private: - shared_ptr libsigrok_device_; - Glib::RefPtr src_pad_; - Glib::Threads::RecMutex mutex_; - Glib::RefPtr task_; - shared_ptr session_; - - void datafeed_callback(shared_ptr device, - shared_ptr packet); - void run(); -}; - class LegacyInput : public Gst::Element { diff --git a/src/legacy_capture_device.cpp b/src/legacy_capture_device.cpp index 2930ad5..09b7bbd 100644 --- a/src/legacy_capture_device.cpp +++ b/src/legacy_capture_device.cpp @@ -19,7 +19,8 @@ */ #include -#include +#include +#include namespace Srf {