GNU Radio 3.3.0 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2004,2009 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more detail. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_GR_BLOCK_DETAIL_H 00024 #define INCLUDED_GR_BLOCK_DETAIL_H 00025 00026 #include <gr_runtime_types.h> 00027 #include <gr_tpb_detail.h> 00028 #include <stdexcept> 00029 00030 /*! 00031 * \brief Implementation details to support the signal processing abstraction 00032 * \ingroup internal 00033 * 00034 * This class contains implementation detail that should be "out of sight" 00035 * of almost all users of GNU Radio. This decoupling also means that 00036 * we can make changes to the guts without having to recompile everything. 00037 */ 00038 class gr_block_detail { 00039 public: 00040 ~gr_block_detail (); 00041 00042 int ninputs () const { return d_ninputs; } 00043 int noutputs () const { return d_noutputs; } 00044 bool sink_p () const { return d_noutputs == 0; } 00045 bool source_p () const { return d_ninputs == 0; } 00046 00047 void set_done (bool done); 00048 bool done () const { return d_done; } 00049 00050 void set_input (unsigned int which, gr_buffer_reader_sptr reader); 00051 gr_buffer_reader_sptr input (unsigned int which) 00052 { 00053 if (which >= d_ninputs) 00054 throw std::invalid_argument ("gr_block_detail::input"); 00055 return d_input[which]; 00056 } 00057 00058 void set_output (unsigned int which, gr_buffer_sptr buffer); 00059 gr_buffer_sptr output (unsigned int which) 00060 { 00061 if (which >= d_noutputs) 00062 throw std::invalid_argument ("gr_block_detail::output"); 00063 return d_output[which]; 00064 } 00065 00066 /*! 00067 * \brief Tell the scheduler \p how_many_items of input stream \p which_input were consumed. 00068 */ 00069 void consume (int which_input, int how_many_items); 00070 00071 /*! 00072 * \brief Tell the scheduler \p how_many_items were consumed on each input stream. 00073 */ 00074 void consume_each (int how_many_items); 00075 00076 /*! 00077 * \brief Tell the scheduler \p how_many_items were produced on output stream \p which_output. 00078 */ 00079 void produce (int which_output, int how_many_items); 00080 00081 /*! 00082 * \brief Tell the scheduler \p how_many_items were produced on each output stream. 00083 */ 00084 void produce_each (int how_many_items); 00085 00086 /*! 00087 * Accept msg, place in queue, arrange for thread to be awakened if it's not already. 00088 */ 00089 void _post(pmt::pmt_t msg); 00090 00091 gr_tpb_detail d_tpb; // used by thread-per-block scheduler 00092 int d_produce_or; 00093 00094 // ---------------------------------------------------------------------------- 00095 00096 private: 00097 unsigned int d_ninputs; 00098 unsigned int d_noutputs; 00099 std::vector<gr_buffer_reader_sptr> d_input; 00100 std::vector<gr_buffer_sptr> d_output; 00101 bool d_done; 00102 00103 00104 gr_block_detail (unsigned int ninputs, unsigned int noutputs); 00105 00106 friend class gr_tpb_detail; 00107 00108 friend gr_block_detail_sptr 00109 gr_make_block_detail (unsigned int ninputs, unsigned int noutputs); 00110 }; 00111 00112 gr_block_detail_sptr 00113 gr_make_block_detail (unsigned int ninputs, unsigned int noutputs); 00114 00115 long 00116 gr_block_detail_ncurrently_allocated (); 00117 00118 #endif /* INCLUDED_GR_BLOCK_DETAIL_H */