GNU Radio 3.3.0 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2007,2008,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 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_H 00024 #define INCLUDED_GR_TOP_BLOCK_H 00025 00026 #include <gr_hier_block2.h> 00027 00028 class gr_top_block_impl; 00029 00030 gr_top_block_sptr gr_make_top_block(const std::string &name); 00031 00032 /*! 00033 *\brief Top-level hierarchical block representing a flowgraph 00034 * \ingroup container_blk 00035 * 00036 */ 00037 class gr_top_block : public gr_hier_block2 00038 { 00039 private: 00040 friend gr_top_block_sptr gr_make_top_block(const std::string &name); 00041 00042 gr_top_block_impl *d_impl; 00043 00044 protected: 00045 gr_top_block(const std::string &name); 00046 00047 public: 00048 ~gr_top_block(); 00049 00050 /*! 00051 * \brief The simple interface to running a flowgraph. 00052 * 00053 * Calls start() then wait(). Used to run a flowgraph that will stop 00054 * on its own, or when another thread will call stop(). 00055 */ 00056 void run(); 00057 00058 /*! 00059 * Start the contained flowgraph. Creates one or more threads to 00060 * execute the flow graph. Returns to the caller once the threads 00061 * are created. Calling start() on a top_block that is already 00062 * started IS an error. 00063 */ 00064 void start(); 00065 00066 /*! 00067 * Stop the running flowgraph. Notifies each thread created by the 00068 * scheduler to shutdown, then returns to caller. Calling stop() on 00069 * a top_block that is already stopped IS NOT an error. 00070 */ 00071 void stop(); 00072 00073 /*! 00074 * Wait for a flowgraph to complete. Flowgraphs complete when 00075 * either (1) all blocks indicate that they are done (typically only 00076 * when using gr.file_source, or gr.head, or (2) after stop() has been 00077 * called to request shutdown. Calling wait on a top_block that is 00078 * not running IS NOT an error (wait returns w/o blocking). 00079 */ 00080 void wait(); 00081 00082 /*! 00083 * Lock a flowgraph in preparation for reconfiguration. When an equal 00084 * number of calls to lock() and unlock() have occurred, the flowgraph 00085 * will be reconfigured. 00086 * 00087 * N.B. lock() and unlock() may not be called from a flowgraph thread 00088 * (E.g., gr_block::work method) or deadlock will occur when 00089 * reconfiguration happens. 00090 */ 00091 virtual void lock(); 00092 00093 /*! 00094 * Unlock a flowgraph in preparation for reconfiguration. When an equal 00095 * number of calls to lock() and unlock() have occurred, the flowgraph 00096 * will be reconfigured. 00097 * 00098 * N.B. lock() and unlock() may not be called from a flowgraph thread 00099 * (E.g., gr_block::work method) or deadlock will occur when 00100 * reconfiguration happens. 00101 */ 00102 virtual void unlock(); 00103 00104 /*! 00105 * Displays flattened flowgraph edges and block connectivity 00106 */ 00107 void dump(); 00108 }; 00109 00110 #endif /* INCLUDED_GR_TOP_BLOCK_H */