gr_basic_block.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2006 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_BASIC_BLOCK_H
00024 #define INCLUDED_GR_BASIC_BLOCK_H
00025 
00026 #include <gr_runtime_types.h>
00027 #include <boost/enable_shared_from_this.hpp>
00028 #include <string>
00029 
00041 class gr_basic_block : public boost::enable_shared_from_this<gr_basic_block>
00042 {
00043 protected:
00044     friend class gr_flowgraph;
00045     friend class gr_flat_flowgraph; // TODO: will be redundant
00046 
00047     enum vcolor { WHITE, GREY, BLACK };
00048 
00049     std::string          d_name;
00050     gr_io_signature_sptr d_input_signature;
00051     gr_io_signature_sptr d_output_signature;
00052     long                 d_unique_id;
00053     vcolor               d_color;
00054 
00056     gr_basic_block(const std::string &name,
00057                    gr_io_signature_sptr input_signature,
00058                    gr_io_signature_sptr output_signature);
00059 
00061     void set_input_signature(gr_io_signature_sptr iosig) {
00062         d_input_signature = iosig;
00063     }
00064     
00066     void set_output_signature(gr_io_signature_sptr iosig) {
00067         d_output_signature = iosig;
00068     }
00069 
00073     void set_color(vcolor color) { d_color = color; }
00074     vcolor color() const { return d_color; }
00075 
00076 public:
00077     virtual ~gr_basic_block();
00078     long unique_id() const { return d_unique_id; }
00079     std::string name() const { return d_name; }
00080     gr_io_signature_sptr input_signature() const  { return d_input_signature; }
00081     gr_io_signature_sptr output_signature() const { return d_output_signature; }
00082     gr_basic_block_sptr basic_block(); // Needed for Python type coercion
00083 
00097     virtual bool check_topology(int ninputs, int noutputs) { return true; }
00098 };
00099 
00100 typedef std::vector<gr_basic_block_sptr> gr_basic_block_vector_t;
00101 typedef std::vector<gr_basic_block_sptr>::iterator gr_basic_block_viter_t;
00102 
00103 long gr_basic_block_ncurrently_allocated();
00104 
00105 inline std::ostream &operator << (std::ostream &os, gr_basic_block_sptr basic_block)
00106 {
00107     os << basic_block->name() << "(" << basic_block->unique_id() << ")";
00108     return os;
00109 }
00110 
00111 #endif /* INCLUDED_GR_BASIC_BLOCK_H */

Generated on Mon Oct 6 23:20:06 2008 for GNU Radio 3.1.2 by  doxygen 1.5.7.1