GNU Radio 3.2.2 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2004 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 each output stream. 00078 */ 00079 void produce_each (int how_many_items); 00080 00081 00082 gr_tpb_detail d_tpb; // used by thread-per-block scheduler 00083 00084 // ---------------------------------------------------------------------------- 00085 00086 private: 00087 unsigned int d_ninputs; 00088 unsigned int d_noutputs; 00089 std::vector<gr_buffer_reader_sptr> d_input; 00090 std::vector<gr_buffer_sptr> d_output; 00091 bool d_done; 00092 00093 00094 gr_block_detail (unsigned int ninputs, unsigned int noutputs); 00095 00096 friend class gr_tpb_detail; 00097 00098 friend gr_block_detail_sptr 00099 gr_make_block_detail (unsigned int ninputs, unsigned int noutputs); 00100 }; 00101 00102 gr_block_detail_sptr 00103 gr_make_block_detail (unsigned int ninputs, unsigned int noutputs); 00104 00105 long 00106 gr_block_detail_ncurrently_allocated (); 00107 00108 #endif /* INCLUDED_GR_BLOCK_DETAIL_H */