GNU Radio 3.6.4.2 C++ API
gr_sync_block.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012-2013 Free Software Foundation, Inc.
3  *
4  * This file is part of GNU Radio
5  *
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * GNU Radio is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef INCLUDED_GNURADIO_GR_SYNC_BLOCK_H
23 #define INCLUDED_GNURADIO_GR_SYNC_BLOCK_H
24 
25 #include <gr_block.h>
26 
28 {
29  gr_sync_block(void);
30 
31  gr_sync_block(
32  const std::string &name,
33  gr_io_signature_sptr input_signature,
34  gr_io_signature_sptr output_signature
35  );
36 
37  virtual ~gr_sync_block(void);
38 
39  //! implements work -> calls work
40  int general_work(
41  int noutput_items,
42  gr_vector_int &ninput_items,
43  gr_vector_const_void_star &input_items,
44  gr_vector_void_star &output_items
45  );
46 
47  /*!
48  * \brief just like gr_block::general_work, only this arranges to call consume_each for you
49  *
50  * The user must override work to define the signal processing code
51  */
52  virtual int work(
53  int noutput_items,
54  gr_vector_const_void_star &input_items,
55  gr_vector_void_star &output_items
56  );
57 
58 };
59 
60 GRAS_FORCE_INLINE int gr_sync_block::general_work(
61  int noutput_items,
62  gr_vector_int &ninput_items,
63  gr_vector_const_void_star &input_items,
64  gr_vector_void_star &output_items
65 ){
66  const int work_ret = this->work(noutput_items, input_items, output_items);
67  if (work_ret > 0)
68  {
69  this->consume_each((decimation()*size_t(work_ret))/interpolation());
70  }
71  return work_ret;
72 }
73 
74 #endif /*INCLUDED_GNURADIO_GR_SYNC_BLOCK_H*/
size_t decimation(void) const
Definition: gr_block.h:424
Definition: gr_sync_block.h:27
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
implements work -> calls work
Definition: gr_sync_block.h:60
Definition: gr_block.h:37
void consume_each(const int how_many_items)
Call during work to consume items.
Definition: gr_block.h:391
#define GR_CORE_API
Definition: gr_core_api.h:30
size_t interpolation(void) const
Definition: gr_block.h:419
virtual int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
compute output items from input items
void work(const InputItems &, const OutputItems &)
implements work -> calls general work
VOLK_API $kern pname $kern name
A function pointer to the dispatcher implementation.
virtual int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
just like gr_block::general_work, only this arranges to call consume_each for you ...