]> sigrok.org Git - libsigrokflow.git/commitdiff
Factor out src/init.cpp.
authorUwe Hermann <redacted>
Wed, 9 Jan 2019 01:15:47 +0000 (02:15 +0100)
committerUwe Hermann <redacted>
Wed, 9 Jan 2019 01:21:21 +0000 (02:21 +0100)
Makefile.am
src/init.cpp [new file with mode: 0644]
src/main.cpp

index 533813a95ea127b19fc87a5132d419ad42e397f4..a0f34fe766e60ed9f607fd0a288fde600cfb47a7 100644 (file)
@@ -28,7 +28,8 @@ AM_CXXFLAGS = $(SRF_WXXFLAGS) $(LIBSIGROKFLOW_CFLAGS)
 lib_LTLIBRARIES = libsigrokflow.la
 
 libsigrokflow_la_SOURCES = \
-       src/main.cpp
+       src/main.cpp \
+       src/init.cpp
 
 libsigrokflow_la_LIBADD = $(LIBSIGROKFLOW_LIBS)
 libsigrokflow_la_LDFLAGS = -version-info $(SRF_LIB_VERSION) -no-undefined
diff --git a/src/init.cpp b/src/init.cpp
new file mode 100644 (file)
index 0000000..344ba6a
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the libsigrokflow project.
+ *
+ * Copyright (C) 2018 Martin Ling <martin-sigrok@earth.li>
+ * Copyright (C) 2018 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <libsigrokflow/libsigrokflow.hpp>
+
+namespace Srf
+{
+
+static bool srf_initialized_ = false;
+
+void init()
+{
+       if (srf_initialized_)
+               throw runtime_error("libsigrokflow is already initialized");
+
+       if (!Gst::is_initialized())
+               throw runtime_error("Gst::init() has not run yet");
+
+#ifdef HAVE_LIBSIGROKCXX
+       Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
+                       "sigrok_legacy_capture_device",
+                       "Wrapper for capture devices using legacy libsigrok APIs",
+                       sigc::ptr_fun(&LegacyCaptureDevice::register_element),
+                       "0.01", "GPL", "sigrok", "libsigrokflow", "http://sigrok.org");
+       Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
+                       "sigrok_legacy_input",
+                       "Wrapper for inputs using legacy libsigrok APIs",
+                       sigc::ptr_fun(&LegacyInput::register_element),
+                       "0.01", "GPL", "sigrok", "libsigrokflow", "http://sigrok.org");
+       Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
+                       "sigrok_legacy_output",
+                       "Wrapper for outputs using legacy libsigrok APIs",
+                       sigc::ptr_fun(&LegacyOutput::register_element),
+                       "0.01", "GPL", "sigrok", "libsigrokflow", "http://sigrok.org");
+#endif
+#ifdef HAVE_LIBSIGROKDECODE
+       Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
+                       "sigrok_legacy_decoder",
+                       "Wrapper for protocol decoders using legacy libsigrokdecode APIs",
+                       sigc::ptr_fun(&LegacyDecoder::register_element),
+                       "0.01", "GPL", "sigrok", "libsigrokflow", "http://sigrok.org");
+#endif
+
+       srf_initialized_ = true;
+}
+
+void deinit()
+{
+       if (!srf_initialized_)
+               throw runtime_error("libsigrokflow is not initialized");
+
+       srf_initialized_ = false;
+}
+
+}
index b79e9352c1343264b75397562e28eb596d3817b4..1b1193f04915b5d6219cc5f2d0e901aa7b5ed078 100644 (file)
@@ -28,52 +28,6 @@ namespace Srf
 using namespace std;
 using namespace std::placeholders;
 
-static bool srf_initialized_ = false;
-
-void init()
-{
-       if (srf_initialized_)
-               throw runtime_error("libsigrokflow is already initialized");
-
-       if (!Gst::is_initialized())
-               throw runtime_error("Gst::init() has not run yet");
-
-#ifdef HAVE_LIBSIGROKCXX
-       Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
-                       "sigrok_legacy_capture_device",
-                       "Wrapper for capture devices using legacy libsigrok APIs",
-                       sigc::ptr_fun(&LegacyCaptureDevice::register_element),
-                       "0.01", "GPL", "sigrok", "libsigrokflow", "http://sigrok.org");
-       Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
-                       "sigrok_legacy_input",
-                       "Wrapper for inputs using legacy libsigrok APIs",
-                       sigc::ptr_fun(&LegacyInput::register_element),
-                       "0.01", "GPL", "sigrok", "libsigrokflow", "http://sigrok.org");
-       Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
-                       "sigrok_legacy_output",
-                       "Wrapper for outputs using legacy libsigrok APIs",
-                       sigc::ptr_fun(&LegacyOutput::register_element),
-                       "0.01", "GPL", "sigrok", "libsigrokflow", "http://sigrok.org");
-#endif
-#ifdef HAVE_LIBSIGROKDECODE
-       Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
-                       "sigrok_legacy_decoder",
-                       "Wrapper for protocol decoders using legacy libsigrokdecode APIs",
-                       sigc::ptr_fun(&LegacyDecoder::register_element),
-                       "0.01", "GPL", "sigrok", "libsigrokflow", "http://sigrok.org");
-#endif
-
-       srf_initialized_ = true;
-}
-
-void deinit()
-{
-       if (!srf_initialized_)
-               throw runtime_error("libsigrokflow is not initialized");
-
-       srf_initialized_ = false;
-}
-
 Sink::Sink(GstBaseSink *gobj) :
        Gst::BaseSink(gobj)
 {