gr-fosphor: Move to the _impl paradigm
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
parent
4f102ee334
commit
062040ae70
|
@ -25,46 +25,16 @@
|
|||
#include <gnuradio/fosphor/api.h>
|
||||
|
||||
#include <gnuradio/sync_block.h>
|
||||
#include <gnuradio/thread/thread.h>
|
||||
|
||||
struct fosphor;
|
||||
struct GLFWwindow;
|
||||
|
||||
namespace gr {
|
||||
namespace fosphor {
|
||||
|
||||
class fifo;
|
||||
|
||||
/*!
|
||||
* \brief Main fosphor sink for GL spectrum display
|
||||
* \brief Main fosphor sink for GL spectrum display (GLFW version)
|
||||
* \ingroup fosphor
|
||||
*/
|
||||
class GR_FOSPHOR_API glfw_sink_c : public gr::sync_block
|
||||
class GR_FOSPHOR_API glfw_sink_c : virtual public gr::sync_block
|
||||
{
|
||||
private:
|
||||
glfw_sink_c();
|
||||
|
||||
void worker();
|
||||
static void _worker(glfw_sink_c *obj);
|
||||
|
||||
void glfw_render(void);
|
||||
void glfw_cb_reshape(int w, int h);
|
||||
void glfw_cb_key(int key, int scancode, int action, int mods);
|
||||
|
||||
static void _glfw_cb_reshape(GLFWwindow *wnd, int w, int h);
|
||||
static void _glfw_cb_key(GLFWwindow *wnd, int key, int scancode, int action, int mods);
|
||||
|
||||
gr::thread::thread d_worker;
|
||||
bool d_active;
|
||||
|
||||
GLFWwindow *d_window;
|
||||
|
||||
fifo *d_fifo;
|
||||
struct fosphor *d_fosphor;
|
||||
int d_width, d_height;
|
||||
int d_db_ref, d_db_per_div_idx;
|
||||
static const int k_db_per_div[];
|
||||
|
||||
public:
|
||||
typedef boost::shared_ptr<glfw_sink_c> sptr;
|
||||
|
||||
|
@ -77,13 +47,6 @@ namespace gr {
|
|||
* creating new instances.
|
||||
*/
|
||||
static sptr make();
|
||||
|
||||
~glfw_sink_c();
|
||||
|
||||
int work (int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
|
||||
};
|
||||
|
||||
} // namespace fosphor
|
||||
|
|
|
@ -58,7 +58,7 @@ list(APPEND fosphor_sources
|
|||
fosphor/resource.c
|
||||
fosphor/resource_data.c
|
||||
fifo.cc
|
||||
glfw_sink_c.cc
|
||||
glfw_sink_c_impl.cc
|
||||
)
|
||||
|
||||
add_library(gnuradio-fosphor SHARED ${fosphor_sources})
|
||||
|
|
|
@ -29,11 +29,10 @@
|
|||
#include <gnuradio/io_signature.h>
|
||||
#include <gnuradio/thread/thread.h>
|
||||
|
||||
#include <gnuradio/fosphor/glfw_sink_c.h>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "fifo.h"
|
||||
#include "glfw_sink_c_impl.h"
|
||||
|
||||
extern "C" {
|
||||
#include "fosphor/fosphor.h"
|
||||
|
@ -46,12 +45,12 @@ namespace gr {
|
|||
glfw_sink_c::sptr
|
||||
glfw_sink_c::make()
|
||||
{
|
||||
return gnuradio::get_initial_sptr(new glfw_sink_c());
|
||||
return gnuradio::get_initial_sptr(new glfw_sink_c_impl());
|
||||
}
|
||||
|
||||
const int glfw_sink_c::k_db_per_div[] = {1, 2, 5, 10, 20};
|
||||
const int glfw_sink_c_impl::k_db_per_div[] = {1, 2, 5, 10, 20};
|
||||
|
||||
glfw_sink_c::glfw_sink_c()
|
||||
glfw_sink_c_impl::glfw_sink_c_impl()
|
||||
: gr::sync_block("glfw_sink_c",
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
||||
gr::io_signature::make(0, 0, 0)),
|
||||
|
@ -65,7 +64,7 @@ glfw_sink_c::glfw_sink_c()
|
|||
this->d_worker = gr::thread::thread(_worker, this);
|
||||
}
|
||||
|
||||
glfw_sink_c::~glfw_sink_c()
|
||||
glfw_sink_c_impl::~glfw_sink_c_impl()
|
||||
{
|
||||
this->d_active = false;
|
||||
this->d_worker.join();
|
||||
|
@ -74,7 +73,7 @@ glfw_sink_c::~glfw_sink_c()
|
|||
}
|
||||
|
||||
int
|
||||
glfw_sink_c::work(
|
||||
glfw_sink_c_impl::work(
|
||||
int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
|
@ -106,7 +105,7 @@ glfw_sink_c::work(
|
|||
}
|
||||
|
||||
|
||||
void glfw_sink_c::worker()
|
||||
void glfw_sink_c_impl::worker()
|
||||
{
|
||||
GLFWwindow *wnd;
|
||||
|
||||
|
@ -155,14 +154,14 @@ void glfw_sink_c::worker()
|
|||
glfwTerminate();
|
||||
}
|
||||
|
||||
void glfw_sink_c::_worker(glfw_sink_c *obj)
|
||||
void glfw_sink_c_impl::_worker(glfw_sink_c_impl *obj)
|
||||
{
|
||||
obj->worker();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glfw_sink_c::glfw_render(void)
|
||||
glfw_sink_c_impl::glfw_render(void)
|
||||
{
|
||||
/* Clear everything */
|
||||
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
|
@ -183,7 +182,7 @@ glfw_sink_c::glfw_render(void)
|
|||
}
|
||||
|
||||
void
|
||||
glfw_sink_c::glfw_cb_reshape(int w, int h)
|
||||
glfw_sink_c_impl::glfw_cb_reshape(int w, int h)
|
||||
{
|
||||
if (w < 0 || h < 0)
|
||||
glfwGetFramebufferSize(this->d_window, &w, &h);
|
||||
|
@ -202,7 +201,7 @@ glfw_sink_c::glfw_cb_reshape(int w, int h)
|
|||
}
|
||||
|
||||
void
|
||||
glfw_sink_c::glfw_cb_key(int key, int scancode, int action, int mods)
|
||||
glfw_sink_c_impl::glfw_cb_key(int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (action != GLFW_PRESS)
|
||||
return;
|
||||
|
@ -239,16 +238,16 @@ glfw_sink_c::glfw_cb_key(int key, int scancode, int action, int mods)
|
|||
}
|
||||
|
||||
void
|
||||
glfw_sink_c::_glfw_cb_reshape(GLFWwindow *wnd, int w, int h)
|
||||
glfw_sink_c_impl::_glfw_cb_reshape(GLFWwindow *wnd, int w, int h)
|
||||
{
|
||||
glfw_sink_c *sink = (glfw_sink_c *) glfwGetWindowUserPointer(wnd);
|
||||
glfw_sink_c_impl *sink = (glfw_sink_c_impl *) glfwGetWindowUserPointer(wnd);
|
||||
sink->glfw_cb_reshape(w, h);
|
||||
}
|
||||
|
||||
void
|
||||
glfw_sink_c::_glfw_cb_key(GLFWwindow *wnd, int key, int scancode, int action, int mods)
|
||||
glfw_sink_c_impl::_glfw_cb_key(GLFWwindow *wnd, int key, int scancode, int action, int mods)
|
||||
{
|
||||
glfw_sink_c *sink = (glfw_sink_c *) glfwGetWindowUserPointer(wnd);
|
||||
glfw_sink_c_impl *sink = (glfw_sink_c_impl *) glfwGetWindowUserPointer(wnd);
|
||||
sink->glfw_cb_key(key, scancode, action, mods);
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2013 Sylvain Munaut <tnt@246tNt.com>
|
||||
*
|
||||
* This 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This software 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INCLUDED_GR_FOSPHOR_GLFW_SINK_C_IMPL_H
|
||||
#define INCLUDED_GR_FOSPHOR_GLFW_SINK_C_IMPL_H
|
||||
|
||||
#include <gnuradio/thread/thread.h>
|
||||
|
||||
#include <gnuradio/fosphor/glfw_sink_c.h>
|
||||
|
||||
struct fosphor;
|
||||
struct GLFWwindow;
|
||||
|
||||
namespace gr {
|
||||
namespace fosphor {
|
||||
|
||||
class fifo;
|
||||
|
||||
/*!
|
||||
* \brief Main fosphor sink for GL spectrum display
|
||||
* \ingroup fosphor
|
||||
*/
|
||||
class glfw_sink_c_impl : public glfw_sink_c
|
||||
{
|
||||
private:
|
||||
void worker();
|
||||
static void _worker(glfw_sink_c_impl *obj);
|
||||
|
||||
void glfw_render(void);
|
||||
void glfw_cb_reshape(int w, int h);
|
||||
void glfw_cb_key(int key, int scancode, int action, int mods);
|
||||
|
||||
static void _glfw_cb_reshape(GLFWwindow *wnd, int w, int h);
|
||||
static void _glfw_cb_key(GLFWwindow *wnd, int key, int scancode, int action, int mods);
|
||||
|
||||
gr::thread::thread d_worker;
|
||||
bool d_active;
|
||||
|
||||
GLFWwindow *d_window;
|
||||
|
||||
fifo *d_fifo;
|
||||
struct fosphor *d_fosphor;
|
||||
int d_width, d_height;
|
||||
int d_db_ref, d_db_per_div_idx;
|
||||
static const int k_db_per_div[];
|
||||
|
||||
public:
|
||||
glfw_sink_c_impl();
|
||||
virtual ~glfw_sink_c_impl();
|
||||
|
||||
int work (int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
|
||||
};
|
||||
|
||||
} // namespace fosphor
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_GR_FOSPHOR_GLFW_SINK_C_IMPL_H */
|
||||
|
Loading…
Reference in New Issue