Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_probe_density_b.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008 Free Software Foundation, Inc.
4  * 
5  * GNU Radio is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3, or (at your option)
8  * any later version.
9  * 
10  * GNU Radio is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with GNU Radio; see the file COPYING.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 #ifndef INCLUDED_GR_PROBE_DENSITY_B_H
21 #define INCLUDED_GR_PROBE_DENSITY_B_H
22
23 #include <gr_sync_block.h>
24
25 class gr_probe_density_b;
26
27 typedef boost::shared_ptr<gr_probe_density_b> gr_probe_density_b_sptr;
28
29 gr_probe_density_b_sptr gr_make_probe_density_b(double alpha);
30
31 /*!
32  * This block maintains a running average of the input stream and
33  * makes it available as an accessor function.  The input stream
34  * is type unsigned char.
35  *
36  * If you send this block a stream of unpacked bytes, it will tell
37  * you what the bit density is.
38  *
39  * \param alpha     Average filter constant
40  *
41  */
42
43 class gr_probe_density_b : public gr_sync_block
44 {
45 private:
46   friend gr_probe_density_b_sptr gr_make_probe_density_b(double alpha);
47
48   double d_alpha;
49   double d_beta;
50   double d_density;
51
52   gr_probe_density_b(double alpha);
53
54 public:
55   ~gr_probe_density_b();
56   
57   /*!
58    * \brief Returns the current density value
59    */
60   double density() const { return d_density; }
61
62   /*!
63    * \brief Set the average filter constant
64    */
65   void set_alpha(double alpha);
66
67   int work(int noutput_items,
68            gr_vector_const_void_star &input_items,
69            gr_vector_void_star &output_items);
70 };
71
72 #endif /* INCLUDED_GR_PROBE_DENSITY_B_H */