GNU Radio 3.6.4.2 C++ API
gr_sync_block.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012-2013 Free Software Foundation, Inc.
00003  *
00004  * This file is part of GNU Radio
00005  *
00006  * GNU Radio is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 3, or (at your option)
00009  * any later version.
00010  *
00011  * GNU Radio is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with GNU Radio; see the file COPYING.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street,
00019  * Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #ifndef INCLUDED_GNURADIO_GR_SYNC_BLOCK_H
00023 #define INCLUDED_GNURADIO_GR_SYNC_BLOCK_H
00024 
00025 #include <gr_block.h>
00026 
00027 struct GR_CORE_API gr_sync_block : public gr_block
00028 {
00029     gr_sync_block(void);
00030 
00031     gr_sync_block(
00032         const std::string &name,
00033         gr_io_signature_sptr input_signature,
00034         gr_io_signature_sptr output_signature
00035     );
00036 
00037     virtual ~gr_sync_block(void);
00038 
00039     //! implements work -> calls work
00040     int general_work(
00041         int noutput_items,
00042         gr_vector_int &ninput_items,
00043         gr_vector_const_void_star &input_items,
00044         gr_vector_void_star &output_items
00045     );
00046 
00047    /*!
00048     * \brief just like gr_block::general_work, only this arranges to call consume_each for you
00049     *
00050     * The user must override work to define the signal processing code
00051     */
00052     virtual int work(
00053         int noutput_items,
00054         gr_vector_const_void_star &input_items,
00055         gr_vector_void_star &output_items
00056     );
00057 
00058 };
00059 
00060 GRAS_FORCE_INLINE int gr_sync_block::general_work(
00061     int noutput_items,
00062     gr_vector_int &ninput_items,
00063     gr_vector_const_void_star &input_items,
00064     gr_vector_void_star &output_items
00065 ){
00066     const int work_ret = this->work(noutput_items, input_items, output_items);
00067     if (work_ret > 0)
00068     {
00069         this->consume_each((decimation()*size_t(work_ret))/interpolation());
00070     }
00071     return work_ret;
00072 }
00073 
00074 #endif /*INCLUDED_GNURADIO_GR_SYNC_BLOCK_H*/