~ubuntu-branches/ubuntu/trusty/gnuradio/trusty

« back to all changes in this revision

Viewing changes to gnuradio-core/src/lib/runtime/gr_block.h

  • Committer: Bazaar Package Importer
  • Author(s): Kamal Mostafa
  • Date: 2010-03-13 07:46:01 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100313074601-zjsa893a87bozyh7
Tags: 3.2.2.dfsg-1ubuntu1
* Fix build for Ubuntu lucid (LP: #260406)
  - add binary package dep for libusrp0, libusrp2-0: adduser
  - debian/rules clean: remove pre-built Qt moc files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- c++ -*- */
2
2
/*
3
 
 * Copyright 2004 Free Software Foundation, Inc.
 
3
 * Copyright 2004,2007 Free Software Foundation, Inc.
4
4
 * 
5
5
 * This file is part of GNU Radio
6
6
 * 
23
23
#ifndef INCLUDED_GR_BLOCK_H
24
24
#define INCLUDED_GR_BLOCK_H
25
25
 
26
 
#include <gr_runtime.h>
27
 
#include <string>
 
26
#include <gr_basic_block.h>
28
27
 
29
28
/*!
30
 
 * \brief The abstract base class for all signal processing blocks.
31
 
 * \ingroup block
 
29
 * \brief The abstract base class for all 'terminal' processing blocks.
 
30
 * \ingroup base_blk
32
31
 *
 
32
 * A signal processing flow is constructed by creating a tree of 
 
33
 * hierarchical blocks, which at any level may also contain terminal nodes
 
34
 * that actually implement signal processing functions. This is the base
 
35
 * class for all such leaf nodes.
 
36
 
33
37
 * Blocks have a set of input streams and output streams.  The
34
38
 * input_signature and output_signature define the number of input
35
39
 * streams and output streams respectively, and the type of the data
49
53
 * It reads the input items and writes the output items.
50
54
 */
51
55
 
52
 
class gr_block {
 
56
class gr_block : public gr_basic_block {
53
57
 
54
58
 public:
55
59
  
56
60
  virtual ~gr_block ();
57
 
  
58
 
  std::string name () const { return d_name; }
59
 
  gr_io_signature_sptr input_signature () const  { return d_input_signature; }
60
 
  gr_io_signature_sptr output_signature () const { return d_output_signature; }
61
 
  long unique_id () const { return d_unique_id; }
62
61
 
63
62
  /*!
64
63
   * Assume block computes y_i = f(x_i, x_i-1, x_i-2, x_i-3...)
114
113
                            gr_vector_void_star &output_items) = 0;
115
114
 
116
115
  /*!
117
 
   * \brief Confirm that ninputs and noutputs is an acceptable combination.
118
 
   *
119
 
   * \param ninputs     number of input streams connected
120
 
   * \param noutputs    number of output streams connected
121
 
   *
122
 
   * \returns true if this is a valid configuration for this block.
123
 
   *
124
 
   * This function is called by the runtime system whenever the
125
 
   * topology changes.  Most classes do not need to override this.
126
 
   * This check is in addition to the constraints specified by the input
127
 
   * and output gr_io_signatures.
128
 
   */
129
 
  virtual bool check_topology (int ninputs, int noutputs);
130
 
 
131
 
  /*!
132
116
   * \brief Called to enable drivers, etc for i/o devices.
133
117
   *
134
118
   * This allows a block to enable an associated driver to begin
205
189
 
206
190
 private:
207
191
 
208
 
  std::string           d_name;
209
 
  gr_io_signature_sptr  d_input_signature;
210
 
  gr_io_signature_sptr  d_output_signature;
211
 
  int                   d_output_multiple;
212
 
  double                d_relative_rate;        // approx output_rate / input_rate
213
 
  gr_block_detail_sptr  d_detail;               // implementation details
214
 
  long                  d_unique_id;            // convenient for debugging
215
 
  unsigned              d_history;
216
 
  bool                  d_fixed_rate;
217
 
 
218
 
  
 
192
  int                   d_output_multiple;
 
193
  double                d_relative_rate;        // approx output_rate / input_rate
 
194
  gr_block_detail_sptr  d_detail;                   // implementation details
 
195
  unsigned              d_history;
 
196
  bool                  d_fixed_rate;
 
197
    
219
198
 protected:
220
199
 
221
200
  gr_block (const std::string &name,
222
 
            gr_io_signature_sptr input_signature,
223
 
            gr_io_signature_sptr output_signature);
224
 
 
225
 
  //! may only be called during constructor
226
 
  void set_input_signature (gr_io_signature_sptr iosig){
227
 
    d_input_signature = iosig;
228
 
  }
229
 
 
230
 
  //! may only be called during constructor
231
 
  void set_output_signature (gr_io_signature_sptr iosig){
232
 
    d_output_signature = iosig;
233
 
  }
 
201
            gr_io_signature_sptr input_signature,
 
202
            gr_io_signature_sptr output_signature);
234
203
 
235
204
  void set_fixed_rate(bool fixed_rate){ d_fixed_rate = fixed_rate; }
236
205
 
242
211
  void set_detail (gr_block_detail_sptr detail) { d_detail = detail; }
243
212
};
244
213
 
245
 
long gr_block_ncurrently_allocated ();
 
214
typedef std::vector<gr_block_sptr> gr_block_vector_t;
 
215
typedef std::vector<gr_block_sptr>::iterator gr_block_viter_t;
 
216
 
 
217
inline gr_block_sptr cast_to_block_sptr(gr_basic_block_sptr p)
 
218
{
 
219
  return boost::dynamic_pointer_cast<gr_block, gr_basic_block>(p);
 
220
}
 
221
 
 
222
 
 
223
std::ostream&
 
224
operator << (std::ostream& os, const gr_block *m);
246
225
 
247
226
#endif /* INCLUDED_GR_BLOCK_H */