X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gnuradio-core%2Fsrc%2Flib%2Fruntime%2Fgr_block.h;h=354695c0b70bb9de3d6b27a7d66310e6f58c54d7;hb=ea29b08aeb54227e6628f655ccfdb96fe4d8c378;hp=c6c769067de77b7ffe2cd1e7e259832626170ba5;hpb=09a1e803a9e6587c78d20cdf16891e5295874668;p=debian%2Fgnuradio diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index c6c76906..354695c0 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2007 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,13 +23,17 @@ #ifndef INCLUDED_GR_BLOCK_H #define INCLUDED_GR_BLOCK_H -#include -#include +#include /*! - * \brief The abstract base class for all signal processing blocks. - * \ingroup block + * \brief The abstract base class for all 'terminal' processing blocks. + * \ingroup base_blk * + * A signal processing flow is constructed by creating a tree of + * hierarchical blocks, which at any level may also contain terminal nodes + * that actually implement signal processing functions. This is the base + * class for all such leaf nodes. + * Blocks have a set of input streams and output streams. The * input_signature and output_signature define the number of input * streams and output streams respectively, and the type of the data @@ -49,16 +53,11 @@ * It reads the input items and writes the output items. */ -class gr_block { +class gr_block : public gr_basic_block { public: virtual ~gr_block (); - - std::string name () const { return d_name; } - gr_io_signature_sptr input_signature () const { return d_input_signature; } - gr_io_signature_sptr output_signature () const { return d_output_signature; } - long unique_id () const { return d_unique_id; } /*! * Assume block computes y_i = f(x_i, x_i-1, x_i-2, x_i-3...) @@ -113,21 +112,6 @@ class gr_block { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) = 0; - /*! - * \brief Confirm that ninputs and noutputs is an acceptable combination. - * - * \param ninputs number of input streams connected - * \param noutputs number of output streams connected - * - * \returns true if this is a valid configuration for this block. - * - * This function is called by the runtime system whenever the - * topology changes. Most classes do not need to override this. - * This check is in addition to the constraints specified by the input - * and output gr_io_signatures. - */ - virtual bool check_topology (int ninputs, int noutputs); - /*! * \brief Called to enable drivers, etc for i/o devices. * @@ -205,32 +189,17 @@ class gr_block { private: - std::string d_name; - gr_io_signature_sptr d_input_signature; - gr_io_signature_sptr d_output_signature; - int d_output_multiple; - double d_relative_rate; // approx output_rate / input_rate - gr_block_detail_sptr d_detail; // implementation details - long d_unique_id; // convenient for debugging - unsigned d_history; - bool d_fixed_rate; - - + int d_output_multiple; + double d_relative_rate; // approx output_rate / input_rate + gr_block_detail_sptr d_detail; // implementation details + unsigned d_history; + bool d_fixed_rate; + protected: gr_block (const std::string &name, - gr_io_signature_sptr input_signature, - gr_io_signature_sptr output_signature); - - //! may only be called during constructor - void set_input_signature (gr_io_signature_sptr iosig){ - d_input_signature = iosig; - } - - //! may only be called during constructor - void set_output_signature (gr_io_signature_sptr iosig){ - d_output_signature = iosig; - } + gr_io_signature_sptr input_signature, + gr_io_signature_sptr output_signature); void set_fixed_rate(bool fixed_rate){ d_fixed_rate = fixed_rate; } @@ -242,6 +211,16 @@ class gr_block { void set_detail (gr_block_detail_sptr detail) { d_detail = detail; } }; -long gr_block_ncurrently_allocated (); +typedef std::vector gr_block_vector_t; +typedef std::vector::iterator gr_block_viter_t; + +inline gr_block_sptr cast_to_block_sptr(gr_basic_block_sptr p) +{ + return boost::dynamic_pointer_cast(p); +} + + +std::ostream& +operator << (std::ostream& os, const gr_block *m); #endif /* INCLUDED_GR_BLOCK_H */