GNU Radio 3.5.1 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2007,2008 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 details. 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_TOP_BLOCK_IMPL_H 00024 #define INCLUDED_GR_TOP_BLOCK_IMPL_H 00025 00026 #include <gr_core_api.h> 00027 #include <gr_scheduler.h> 00028 #include <gruel/thread.h> 00029 00030 /*! 00031 *\brief Abstract implementation details of gr_top_block 00032 * \ingroup internal 00033 * 00034 * The actual implementation of gr_top_block. Separate class allows 00035 * decoupling of changes from dependent classes. 00036 * 00037 */ 00038 class GR_CORE_API gr_top_block_impl 00039 { 00040 public: 00041 gr_top_block_impl(gr_top_block *owner); 00042 ~gr_top_block_impl(); 00043 00044 // Create and start scheduler threads 00045 void start(int max_noutput_items=100000); 00046 00047 // Signal scheduler threads to stop 00048 void stop(); 00049 00050 // Wait for scheduler threads to exit 00051 void wait(); 00052 00053 // Lock the top block to allow reconfiguration 00054 void lock(); 00055 00056 // Unlock the top block at end of reconfiguration 00057 void unlock(); 00058 00059 // Dump the flowgraph to stdout 00060 void dump(); 00061 00062 // Get the number of max noutput_items in the flowgraph 00063 int max_noutput_items(); 00064 00065 // Set the maximum number of noutput_items in the flowgraph 00066 void set_max_noutput_items(int nmax); 00067 00068 protected: 00069 00070 enum tb_state { IDLE, RUNNING }; 00071 00072 gr_top_block *d_owner; 00073 gr_flat_flowgraph_sptr d_ffg; 00074 gr_scheduler_sptr d_scheduler; 00075 00076 gruel::mutex d_mutex; // protects d_state and d_lock_count 00077 tb_state d_state; 00078 int d_lock_count; 00079 int d_max_noutput_items; 00080 00081 private: 00082 void restart(); 00083 }; 00084 00085 #endif /* INCLUDED_GR_TOP_BLOCK_IMPL_H */