gr-baz Package
baz_native_callback.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2004,2013 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * GNU Radio 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, or (at your option)
10 * any later version.
11 *
12 * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23/*
24 * gr-baz by Balint Seeber (http://spench.net/contact)
25 * Information, documentation & samples: http://wiki.spench.net/wiki/gr-baz
26 */
27
28#ifndef INCLUDED_BAZ_NATIVE_CALLBACK_X_H
29#define INCLUDED_BAZ_NATIVE_CALLBACK_X_H
30
31#include <gnuradio/sync_block.h>
32
34
35/*
36 * We use boost::shared_ptr's instead of raw pointers for all access
37 * to gr::blocks (and many other data structures). The shared_ptr gets
38 * us transparent reference counting, which greatly simplifies storage
39 * management issues. This is especially helpful in our hybrid
40 * C++ / Python system.
41 *
42 * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
43 *
44 * As a convention, the _sptr suffix indicates a boost::shared_ptr
45 */
46typedef boost::shared_ptr<baz_native_callback_x> baz_native_callback_x_sptr;
47
49{
50public:
51 virtual void callback(float f, unsigned long samples_processed)=0; // FIXME: Item size
53};
54
55//typedef boost::shared_ptr<baz_native_callback_target> baz_native_callback_target_sptr;
56#define baz_native_callback_target_sptr gr::basic_block_sptr
57
58/*!
59 * \brief Return a shared_ptr to a new instance of baz_native_callback_x.
60 *
61 * To avoid accidental use of raw pointers, baz_native_callback_x's
62 * constructor is private. howto_make_square2_ff is the public
63 * interface for creating new instances.
64 */
65BAZ_API baz_native_callback_x_sptr baz_make_native_callback_x (int size, baz_native_callback_target_sptr target, bool threshold_enable=false, float threshold_level=0.0);
66
67/*!
68 * \brief square2 a stream of floats.
69 * \ingroup block
70 *
71 * This uses the preferred technique: subclassing gr::sync_block.
72 */
73class BAZ_API baz_native_callback_x : public gr::sync_block
74{
75private:
76 // The friend declaration allows howto_make_square2_ff to
77 // access the private constructor.
78
79 friend baz_native_callback_x_sptr baz_make_native_callback_x (int size, baz_native_callback_target_sptr target, bool threshold_enable, float threshold_level);
80
81 baz_native_callback_x (int size, baz_native_callback_target_sptr target, bool threshold_enable, float threshold_level); // private constructor
82
83 int d_size;
84 baz_native_callback_target_sptr d_target;
85 bool d_threshold_enable;
86 float d_threshold_level;
87
88 bool d_triggered;
89 unsigned long d_samples_processed;
90
91 public:
92 ~baz_native_callback_x (); // public destructor
93
94 void set_size(int size);
95 void set_target(baz_native_callback_target_sptr target);
96 void set_threshold_enable(bool enable);
97 void set_threshold_level(float threshold_level);
98
99 inline int size() const
100 { return d_size; }
101 // Target
102 inline bool threshold_enable() const
103 { return d_threshold_enable; }
104 inline float threshold_level() const
105 { return d_threshold_level; }
106
107 int work (int noutput_items,
108 gr_vector_const_void_star &input_items,
109 gr_vector_void_star &output_items);
110};
111
112#endif /* INCLUDED_BAZ_NATIVE_CALLBACK_X_H */
#define BAZ_API
Definition api.h:19
BAZ_API baz_native_callback_x_sptr baz_make_native_callback_x(int size, baz_native_callback_target_sptr target, bool threshold_enable=false, float threshold_level=0.0)
Return a shared_ptr to a new instance of baz_native_callback_x.
Definition baz_native_callback.h:49
virtual ~baz_native_callback_target()
Definition baz_native_callback.h:52
virtual void callback(float f, unsigned long samples_processed)=0
square2 a stream of floats.
Definition baz_native_callback.h:74
friend baz_native_callback_x_sptr baz_make_native_callback_x(int size, baz_native_callback_target_sptr target, bool threshold_enable, float threshold_level)
Return a shared_ptr to a new instance of baz_native_callback_x.
void set_threshold_level(float threshold_level)
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
float threshold_level() const
Definition baz_native_callback.h:104
void set_target(baz_native_callback_target_sptr target)
void set_threshold_enable(bool enable)
bool threshold_enable() const
Definition baz_native_callback.h:102
int size() const
Definition baz_native_callback.h:99
void set_size(int size)