gr_top_block_impl.h

Go to the documentation of this file.
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_scheduler.h>
00027 #include <boost/thread.hpp>
00028 
00029 typedef boost::mutex                    gr_mutex;       // FIXME move these elsewhere
00030 typedef boost::lock_guard<boost::mutex> gr_lock_guard;
00031 
00032 /*!
00033  *\brief Abstract implementation details of gr_top_block
00034  * \ingroup internal
00035  *
00036  * The actual implementation of gr_top_block. Separate class allows
00037  * decoupling of changes from dependent classes.
00038  *
00039  */
00040 class gr_top_block_impl
00041 {
00042 public:
00043   gr_top_block_impl(gr_top_block *owner);
00044   ~gr_top_block_impl();
00045 
00046   // Create and start scheduler threads
00047   void start();
00048 
00049   // Signal scheduler threads to stop
00050   void stop();
00051 
00052   // Wait for scheduler threads to exit
00053   void wait();
00054 
00055   // Lock the top block to allow reconfiguration
00056   void lock();
00057 
00058   // Unlock the top block at end of reconfiguration
00059   void unlock();
00060 
00061   // Dump the flowgraph to stdout
00062   void dump();
00063   
00064 protected:
00065     
00066   enum tb_state { IDLE, RUNNING };
00067 
00068   gr_top_block                  *d_owner;
00069   gr_flat_flowgraph_sptr         d_ffg;
00070   gr_scheduler_sptr              d_scheduler;
00071 
00072   gr_mutex                       d_mutex;       // protects d_state and d_lock_count
00073   tb_state                       d_state;
00074   int                            d_lock_count;
00075   
00076 private:
00077   void restart();
00078 };
00079 
00080 #endif /* INCLUDED_GR_TOP_BLOCK_IMPL_H */

Generated on Wed Jul 29 06:31:39 2009 for GNU Radio 3.2.2 C++ API by  doxygen 1.5.9