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