GNU Radio 3.7.3 C++ API
block.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004,2007,2009,2010,2013 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_GR_RUNTIME_BLOCK_H
24 #define INCLUDED_GR_RUNTIME_BLOCK_H
25 
26 #include <gnuradio/api.h>
27 #include <gnuradio/basic_block.h>
28 #include <gnuradio/tags.h>
29 #include <gnuradio/logger.h>
30 
31 namespace gr {
32 
33  /*!
34  * \brief The abstract base class for all 'terminal' processing blocks.
35  * \ingroup base_blk
36  *
37  * A signal processing flow is constructed by creating a tree of
38  * hierarchical blocks, which at any level may also contain terminal
39  * nodes that actually implement signal processing functions. This
40  * is the base class for all such leaf nodes.
41  *
42  * Blocks have a set of input streams and output streams. The
43  * input_signature and output_signature define the number of input
44  * streams and output streams respectively, and the type of the data
45  * items in each stream.
46  *
47  * Although blocks may consume data on each input stream at a
48  * different rate, all outputs streams must produce data at the same
49  * rate. That rate may be different from any of the input rates.
50  *
51  * User derived blocks override two methods, forecast and
52  * general_work, to implement their signal processing
53  * behavior. forecast is called by the system scheduler to determine
54  * how many items are required on each input stream in order to
55  * produce a given number of output items.
56  *
57  * general_work is called to perform the signal processing in the
58  * block. It reads the input items and writes the output items.
59  */
61  {
62  public:
63 
64  //! Magic return values from general_work
65  enum {
66  WORK_CALLED_PRODUCE = -2,
67  WORK_DONE = -1
68  };
69 
71  TPP_DONT = 0,
74  };
75 
76  virtual ~block();
77 
78  /*!
79  * Assume block computes y_i = f(x_i, x_i-1, x_i-2, x_i-3...)
80  * History is the number of x_i's that are examined to produce one y_i.
81  * This comes in handy for FIR filters, where we use history to
82  * ensure that our input contains the appropriate "history" for the
83  * filter. History should be equal to the number of filter taps.
84  */
85  unsigned history() const;
86  void set_history(unsigned history);
87 
88  /*!
89  * Declares the block's delay in samples. Since the delay of
90  * blocks like filters is derived from the taps and not the block
91  * itself, we cannot automatically calculate this value and so
92  * leave it as a user-defined property. It defaults to 0 is not
93  * set.
94  *
95  * This does not actively set the delay; it just tells the
96  * scheduler what the delay is.
97  *
98  * This delay is mostly used to adjust the placement of the tags
99  * and is not currently used for any signal processing. When a tag
100  * is passed through a block with internal delay, its location
101  * should be moved based on the delay of the block. This interface
102  * allows us to tell the scheduler this value.
103  *
104  * \param which The buffer on which to set the delay.
105  * \param delay The sample delay of the data stream.
106  */
107  void declare_sample_delay(int which, unsigned delay);
108 
109  /*!
110  * Convenience wrapper to gr::block::declare_delay(int which, unsigned delay)
111  * to set all ports to the same delay.
112  */
113  void declare_sample_delay(unsigned delay);
114 
115  /*!
116  * Gets the delay of the block. Since the delay of blocks like
117  * filters is derived from the taps and not the block itself, we
118  * cannot automatically calculate this value and so leave it as a
119  * user-defined property. It defaults to 0 is not set.
120  *
121  * \param which Which port from which to get the sample delay.
122  */
123  unsigned sample_delay(int which) const;
124 
125  /*!
126  * \brief Return true if this block has a fixed input to output rate.
127  *
128  * If true, then fixed_rate_in_to_out and fixed_rate_out_to_in may be called.
129  */
130  bool fixed_rate() const { return d_fixed_rate; }
131 
132  // ----------------------------------------------------------------
133  // override these to define your behavior
134  // ----------------------------------------------------------------
135 
136  /*!
137  * \brief Estimate input requirements given output request
138  *
139  * \param noutput_items number of output items to produce
140  * \param ninput_items_required number of input items required on each input stream
141  *
142  * Given a request to product \p noutput_items, estimate the
143  * number of data items required on each input stream. The
144  * estimate doesn't have to be exact, but should be close.
145  */
146  virtual void forecast(int noutput_items,
147  gr_vector_int &ninput_items_required);
148 
149  /*!
150  * \brief compute output items from input items
151  *
152  * \param noutput_items number of output items to write on each output stream
153  * \param ninput_items number of input items available on each input stream
154  * \param input_items vector of pointers to the input items, one entry per input stream
155  * \param output_items vector of pointers to the output items, one entry per output stream
156  *
157  * \returns number of items actually written to each output stream, or -1 on EOF.
158  * It is OK to return a value less than noutput_items. -1 <= return value <= noutput_items
159  *
160  * general_work must call consume or consume_each to indicate how
161  * many items were consumed on each input stream.
162  */
163  virtual int general_work(int noutput_items,
164  gr_vector_int &ninput_items,
165  gr_vector_const_void_star &input_items,
166  gr_vector_void_star &output_items);
167 
168  /*!
169  * \brief Called to enable drivers, etc for i/o devices.
170  *
171  * This allows a block to enable an associated driver to begin
172  * transfering data just before we start to execute the scheduler.
173  * The end result is that this reduces latency in the pipeline
174  * when dealing with audio devices, usrps, etc.
175  */
176  virtual bool start();
177 
178  /*!
179  * \brief Called to disable drivers, etc for i/o devices.
180  */
181  virtual bool stop();
182 
183  // ----------------------------------------------------------------
184 
185  /*!
186  * \brief Constrain the noutput_items argument passed to forecast and general_work
187  *
188  * set_output_multiple causes the scheduler to ensure that the
189  * noutput_items argument passed to forecast and general_work will
190  * be an integer multiple of \param multiple The default value of
191  * output multiple is 1.
192  */
193  void set_output_multiple(int multiple);
194  int output_multiple() const { return d_output_multiple; }
195  bool output_multiple_set() const { return d_output_multiple_set; }
196 
197  /*!
198  * \brief Constrains buffers to work on a set item alignment (for SIMD)
199  *
200  * set_alignment_multiple causes the scheduler to ensure that the
201  * noutput_items argument passed to forecast and general_work will
202  * be an integer multiple of \param multiple The default value is
203  * 1.
204  *
205  * This control is similar to the output_multiple setting, except
206  * that if the number of items passed to the block is less than
207  * the output_multiple, this value is ignored and the block can
208  * produce like normal. The d_unaligned value is set to the number
209  * of items the block is off by. In the next call to general_work,
210  * the noutput_items is set to d_unaligned or less until
211  * d_unaligned==0. The buffers are now aligned again and the
212  * aligned calls can be performed again.
213  */
214  void set_alignment(int multiple);
215  int alignment() const { return d_output_multiple; }
216 
217  void set_unaligned(int na);
218  int unaligned() const { return d_unaligned; }
219  void set_is_unaligned(bool u);
220  bool is_unaligned() const { return d_is_unaligned; }
221 
222  /*!
223  * \brief Tell the scheduler \p how_many_items of input stream \p
224  * which_input were consumed.
225  */
226  void consume(int which_input, int how_many_items);
227 
228  /*!
229  * \brief Tell the scheduler \p how_many_items were consumed on
230  * each input stream.
231  */
232  void consume_each(int how_many_items);
233 
234  /*!
235  * \brief Tell the scheduler \p how_many_items were produced on
236  * output stream \p which_output.
237  *
238  * If the block's general_work method calls produce, \p
239  * general_work must return WORK_CALLED_PRODUCE.
240  */
241  void produce(int which_output, int how_many_items);
242 
243  /*!
244  * \brief Set the approximate output rate / input rate
245  *
246  * Provide a hint to the buffer allocator and scheduler.
247  * The default relative_rate is 1.0
248  *
249  * decimators have relative_rates < 1.0
250  * interpolators have relative_rates > 1.0
251  */
252  void set_relative_rate(double relative_rate);
253 
254  /*!
255  * \brief return the approximate output rate / input rate
256  */
257  double relative_rate() const { return d_relative_rate; }
258 
259  /*
260  * The following two methods provide special case info to the
261  * scheduler in the event that a block has a fixed input to output
262  * ratio. sync_block, sync_decimator and
263  * sync_interpolator override these. If you're fixed rate,
264  * subclass one of those.
265  */
266  /*!
267  * \brief Given ninput samples, return number of output samples that will be produced.
268  * N.B. this is only defined if fixed_rate returns true.
269  * Generally speaking, you don't need to override this.
270  */
271  virtual int fixed_rate_ninput_to_noutput(int ninput);
272 
273  /*!
274  * \brief Given noutput samples, return number of input samples required to produce noutput.
275  * N.B. this is only defined if fixed_rate returns true.
276  * Generally speaking, you don't need to override this.
277  */
278  virtual int fixed_rate_noutput_to_ninput(int noutput);
279 
280  /*!
281  * \brief Return the number of items read on input stream which_input
282  */
283  uint64_t nitems_read(unsigned int which_input);
284 
285  /*!
286  * \brief Return the number of items written on output stream which_output
287  */
288  uint64_t nitems_written(unsigned int which_output);
289 
290  /*!
291  * \brief Asks for the policy used by the scheduler to moved tags downstream.
292  */
293  tag_propagation_policy_t tag_propagation_policy();
294 
295  /*!
296  * \brief Set the policy by the scheduler to determine how tags are moved downstream.
297  */
298  void set_tag_propagation_policy(tag_propagation_policy_t p);
299 
300  /*!
301  * \brief Return the minimum number of output items this block can
302  * produce during a call to work.
303  *
304  * Should be 0 for most blocks. Useful if we're dealing with
305  * packets and the block produces one packet per call to work.
306  */
307  int min_noutput_items() const { return d_min_noutput_items; }
308 
309  /*!
310  * \brief Set the minimum number of output items this block can
311  * produce during a call to work.
312  *
313  * \param m the minimum noutput_items this block can produce.
314  */
315  void set_min_noutput_items(int m) { d_min_noutput_items = m; }
316 
317  /*!
318  * \brief Return the maximum number of output items this block will
319  * handle during a call to work.
320  */
321  int max_noutput_items();
322 
323  /*!
324  * \brief Set the maximum number of output items this block will
325  * handle during a call to work.
326  *
327  * \param m the maximum noutput_items this block will handle.
328  */
329  void set_max_noutput_items(int m);
330 
331  /*!
332  * \brief Clear the switch for using the max_noutput_items value of this block.
333  *
334  * When is_set_max_noutput_items() returns 'true', the scheduler
335  * will use the value returned by max_noutput_items() to limit the
336  * size of the number of items possible for this block's work
337  * function. If is_set_max_notput_items() returns 'false', then
338  * the scheduler ignores the internal value and uses the value set
339  * globally in the top_block.
340  *
341  * Use this value to clear the 'is_set' flag so the scheduler will
342  * ignore this. Use the set_max_noutput_items(m) call to both set
343  * a new value for max_noutput_items and to reenable its use in
344  * the scheduler.
345  */
346  void unset_max_noutput_items();
347 
348  /*!
349  * \brief Ask the block if the flag is or is not set to use the
350  * internal value of max_noutput_items during a call to work.
351  */
352  bool is_set_max_noutput_items();
353 
354  /*
355  * Used to expand the vectors that hold the min/max buffer sizes.
356  *
357  * Specifically, when -1 is used, the vectors are just initialized
358  * with 1 value; this is used by the flat_flowgraph to expand when
359  * required to add a new value for new ports on these blocks.
360  */
361  void expand_minmax_buffer(int port);
362 
363  /*!
364  * \brief Returns max buffer size on output port \p i.
365  */
366  long max_output_buffer(size_t i);
367 
368  /*!
369  * \brief Sets max buffer size on all output ports.
370  */
371  void set_max_output_buffer(long max_output_buffer);
372 
373  /*!
374  * \brief Sets max buffer size on output port \p port.
375  */
376  void set_max_output_buffer(int port, long max_output_buffer);
377 
378  /*!
379  * \brief Returns min buffer size on output port \p i.
380  */
381  long min_output_buffer(size_t i);
382 
383  /*!
384  * \brief Sets min buffer size on all output ports.
385  */
386  void set_min_output_buffer(long min_output_buffer);
387 
388  /*!
389  * \brief Sets min buffer size on output port \p port.
390  */
391  void set_min_output_buffer(int port, long min_output_buffer);
392 
393  // --------------- Performance counter functions -------------
394 
395  /*!
396  * \brief Gets instantaneous noutput_items performance counter.
397  */
398  float pc_noutput_items();
399 
400  /*!
401  * \brief Gets average noutput_items performance counter.
402  */
403  float pc_noutput_items_avg();
404 
405  /*!
406  * \brief Gets variance of noutput_items performance counter.
407  */
408  float pc_noutput_items_var();
409 
410  /*!
411  * \brief Gets instantaneous num items produced performance counter.
412  */
413  float pc_nproduced();
414 
415  /*!
416  * \brief Gets average num items produced performance counter.
417  */
418  float pc_nproduced_avg();
419 
420  /*!
421  * \brief Gets variance of num items produced performance counter.
422  */
423  float pc_nproduced_var();
424 
425  /*!
426  * \brief Gets instantaneous fullness of \p which input buffer.
427  */
428  float pc_input_buffers_full(int which);
429 
430  /*!
431  * \brief Gets average fullness of \p which input buffer.
432  */
433  float pc_input_buffers_full_avg(int which);
434 
435  /*!
436  * \brief Gets variance of fullness of \p which input buffer.
437  */
438  float pc_input_buffers_full_var(int which);
439 
440  /*!
441  * \brief Gets instantaneous fullness of all input buffers.
442  */
443  std::vector<float> pc_input_buffers_full();
444 
445  /*!
446  * \brief Gets average fullness of all input buffers.
447  */
448  std::vector<float> pc_input_buffers_full_avg();
449 
450  /*!
451  * \brief Gets variance of fullness of all input buffers.
452  */
453  std::vector<float> pc_input_buffers_full_var();
454 
455  /*!
456  * \brief Gets instantaneous fullness of \p which input buffer.
457  */
458  float pc_output_buffers_full(int which);
459 
460  /*!
461  * \brief Gets average fullness of \p which input buffer.
462  */
463  float pc_output_buffers_full_avg(int which);
464 
465  /*!
466  * \brief Gets variance of fullness of \p which input buffer.
467  */
468  float pc_output_buffers_full_var(int which);
469 
470  /*!
471  * \brief Gets instantaneous fullness of all output buffers.
472  */
473  std::vector<float> pc_output_buffers_full();
474 
475  /*!
476  * \brief Gets average fullness of all output buffers.
477  */
478  std::vector<float> pc_output_buffers_full_avg();
479 
480  /*!
481  * \brief Gets variance of fullness of all output buffers.
482  */
483  std::vector<float> pc_output_buffers_full_var();
484 
485  /*!
486  * \brief Gets instantaneous clock cycles spent in work.
487  */
488  float pc_work_time();
489 
490  /*!
491  * \brief Gets average clock cycles spent in work.
492  */
493  float pc_work_time_avg();
494 
495  /*!
496  * \brief Gets average clock cycles spent in work.
497  */
498  float pc_work_time_var();
499 
500  /*!
501  * \brief Gets total clock cycles spent in work.
502  */
503  float pc_work_time_total();
504 
505  /*!
506  * \brief Resets the performance counters
507  */
508  void reset_perf_counters();
509 
510  /*!
511  * \brief Sets up export of perf. counters to ControlPort. Only
512  * called by the scheduler.
513  */
514  void setup_pc_rpc();
515 
516  /*!
517  * \brief Checks if this block is already exporting perf. counters
518  * to ControlPort.
519  */
520  bool is_pc_rpc_set() { return d_pc_rpc_set; }
521 
522  /*!
523  * \brief If the block calls this in its constructor, it's
524  * perf. counters will not be exported.
525  */
526  void no_pc_rpc() { d_pc_rpc_set = true; }
527 
528 
529  // ----------------------------------------------------------------------------
530  // Functions to handle thread affinity
531 
532  /*!
533  * \brief Set the thread's affinity to processor core \p n.
534  *
535  * \param mask a vector of ints of the core numbers available to this block.
536  */
537  void set_processor_affinity(const std::vector<int> &mask);
538 
539  /*!
540  * \brief Remove processor affinity to a specific core.
541  */
542  void unset_processor_affinity();
543 
544  /*!
545  * \brief Get the current processor affinity.
546  */
547  std::vector<int> processor_affinity() { return d_affinity; }
548 
549  /*!
550  * \brief Get the current thread priority in use
551  */
552  int active_thread_priority();
553 
554  /*!
555  * \brief Get the current thread priority stored
556  */
557  int thread_priority();
558 
559  /*!
560  * \brief Set the current thread priority
561  */
562  int set_thread_priority(int priority);
563 
564  bool update_rate() const;
565 
566  // ----------------------------------------------------------------------------
567 
568  private:
569  int d_output_multiple;
570  bool d_output_multiple_set;
571  int d_unaligned;
572  bool d_is_unaligned;
573  double d_relative_rate; // approx output_rate / input_rate
574  block_detail_sptr d_detail; // implementation details
575  unsigned d_history;
576  unsigned d_attr_delay; // the block's sample delay
577  bool d_fixed_rate;
578  bool d_max_noutput_items_set; // if d_max_noutput_items is valid
579  int d_max_noutput_items; // value of max_noutput_items for this block
580  int d_min_noutput_items;
581  tag_propagation_policy_t d_tag_propagation_policy; // policy for moving tags downstream
582  std::vector<int> d_affinity; // thread affinity proc. mask
583  int d_priority; // thread priority level
584  bool d_pc_rpc_set;
585  bool d_update_rate; // should sched update rel rate?
586 
587  protected:
588  block(void) {} // allows pure virtual interface sub-classes
589  block(const std::string &name,
590  gr::io_signature::sptr input_signature,
591  gr::io_signature::sptr output_signature);
592 
593  void set_fixed_rate(bool fixed_rate) { d_fixed_rate = fixed_rate; }
594 
595  /*!
596  * \brief Adds a new tag onto the given output buffer.
597  *
598  * \param which_output an integer of which output stream to attach the tag
599  * \param abs_offset a uint64 number of the absolute item number
600  * assicated with the tag. Can get from nitems_written.
601  * \param key the tag key as a PMT symbol
602  * \param value any PMT holding any value for the given key
603  * \param srcid optional source ID specifier; defaults to PMT_F
604  */
605  inline void add_item_tag(unsigned int which_output,
606  uint64_t abs_offset,
607  const pmt::pmt_t &key,
608  const pmt::pmt_t &value,
609  const pmt::pmt_t &srcid=pmt::PMT_F)
610  {
611  tag_t tag;
612  tag.offset = abs_offset;
613  tag.key = key;
614  tag.value = value;
615  tag.srcid = srcid;
616  this->add_item_tag(which_output, tag);
617  }
618 
619  /*!
620  * \brief Adds a new tag onto the given output buffer.
621  *
622  * \param which_output an integer of which output stream to attach the tag
623  * \param tag the tag object to add
624  */
625  void add_item_tag(unsigned int which_output, const tag_t &tag);
626 
627  /*!
628  * \brief Removes a tag from the given input buffer.
629  *
630  * \param which_input an integer of which input stream to remove the tag from
631  * \param abs_offset a uint64 number of the absolute item number
632  * assicated with the tag. Can get from nitems_written.
633  * \param key the tag key as a PMT symbol
634  * \param value any PMT holding any value for the given key
635  * \param srcid optional source ID specifier; defaults to PMT_F
636  *
637  * If no such tag is found, does nothing.
638  */
639  inline void remove_item_tag(unsigned int which_input,
640  uint64_t abs_offset,
641  const pmt::pmt_t &key,
642  const pmt::pmt_t &value,
643  const pmt::pmt_t &srcid=pmt::PMT_F)
644  {
645  tag_t tag;
646  tag.offset = abs_offset;
647  tag.key = key;
648  tag.value = value;
649  tag.srcid = srcid;
650  this->remove_item_tag(which_input, tag);
651  }
652 
653  /*!
654  * \brief Removes a tag from the given input buffer.
655  *
656  * If no such tag is found, does nothing.
657  *
658  * \param which_input an integer of which input stream to remove the tag from
659  * \param tag the tag object to remove
660  */
661  void remove_item_tag(unsigned int which_input, const tag_t &tag);
662 
663  /*!
664  * \brief Given a [start,end), returns a vector of all tags in the range.
665  *
666  * Range of counts is from start to end-1.
667  *
668  * Tags are tuples of:
669  * (item count, source id, key, value)
670  *
671  * \param v a vector reference to return tags into
672  * \param which_input an integer of which input stream to pull from
673  * \param abs_start a uint64 count of the start of the range of interest
674  * \param abs_end a uint64 count of the end of the range of interest
675  */
676  void get_tags_in_range(std::vector<tag_t> &v,
677  unsigned int which_input,
678  uint64_t abs_start,
679  uint64_t abs_end);
680 
681  /*!
682  * \brief Given a [start,end), returns a vector of all tags in the
683  * range with a given key.
684  *
685  * Range of counts is from start to end-1.
686  *
687  * Tags are tuples of:
688  * (item count, source id, key, value)
689  *
690  * \param v a vector reference to return tags into
691  * \param which_input an integer of which input stream to pull from
692  * \param abs_start a uint64 count of the start of the range of interest
693  * \param abs_end a uint64 count of the end of the range of interest
694  * \param key a PMT symbol key to filter only tags of this key
695  */
696  void get_tags_in_range(std::vector<tag_t> &v,
697  unsigned int which_input,
698  uint64_t abs_start,
699  uint64_t abs_end,
700  const pmt::pmt_t &key);
701 
702  /*!
703  * \brief Gets all tags within the relative window of the current call to work.
704  *
705  * \details
706  *
707  * This opperates much like get_tags_in_range but allows us to
708  * work within the current window of items. Item range is
709  * therefore within the possible range of 0 to
710  * ninput_items[whic_input].
711  *
712  * Range of items counts from \p rel_start to \p rel_end-1 within
713  * current window.
714  *
715  * Tags are tuples of:
716  * (item count, source id, key, value)
717  *
718  * \param v a vector reference to return tags into
719  * \param which_input an integer of which input stream to pull from
720  * \param rel_start a uint64 count of the start of the range of interest
721  * \param rel_end a uint64 count of the end of the range of interest
722  */
723  void get_tags_in_window(std::vector<tag_t> &v,
724  unsigned int which_input,
725  uint64_t rel_start,
726  uint64_t rel_end);
727 
728  /*!
729  * \brief Operates like gr::block::get_tags_in_window with the
730  * ability to only return tags with the specified \p key.
731  *
732  * \details
733  *
734  * \param v a vector reference to return tags into
735  * \param which_input an integer of which input stream to pull from
736  * \param rel_start a uint64 count of the start of the range of interest
737  * \param rel_end a uint64 count of the end of the range of interest
738  * \param key a PMT symbol key to filter only tags of this key
739  */
740  void get_tags_in_window(std::vector<tag_t> &v,
741  unsigned int which_input,
742  uint64_t rel_start,
743  uint64_t rel_end,
744  const pmt::pmt_t &key);
745 
746  void enable_update_rate(bool en);
747 
748  std::vector<long> d_max_output_buffer;
749  std::vector<long> d_min_output_buffer;
750 
751  /*! Used by block's setters and work functions to make
752  * setting/resetting of parameters thread-safe.
753  *
754  * Used by calling gr::thread::scoped_lock l(d_setlock);
755  */
757 
758  /*! Used by blocks to access the logger system.
759  */
762 
763  // These are really only for internal use, but leaving them public avoids
764  // having to work up an ever-varying list of friend GR_RUNTIME_APIs
765 
766  public:
767  block_detail_sptr detail() const { return d_detail; }
768  void set_detail(block_detail_sptr detail) { d_detail = detail; }
769  };
770 
771  typedef std::vector<block_sptr> block_vector_t;
772  typedef std::vector<block_sptr>::iterator block_viter_t;
773 
774  inline block_sptr cast_to_block_sptr(basic_block_sptr p)
775  {
776  return boost::dynamic_pointer_cast<block, basic_block>(p);
777  }
778 
779  std::ostream&
780  operator << (std::ostream& os, const block *m);
781 
782 } /* namespace gr */
783 
784 #endif /* INCLUDED_GR_RUNTIME_BLOCK_H */
std::string logger_ptr
Definition: logger.h:65
pmt::pmt_t value
the value of tag (as a PMT)
Definition: tags.h:40
Definition: tags.h:31
uint64_t offset
the item tag occurred at (as a uint64_t)
Definition: tags.h:34
gr::logger_ptr d_debug_logger
Definition: block.h:761
std::vector< int > processor_affinity()
Get the current processor affinity.
Definition: block.h:547
std::vector< block_sptr > block_vector_t
Definition: block.h:771
block_detail_sptr detail() const
Definition: block.h:767
void set_fixed_rate(bool fixed_rate)
Definition: block.h:593
void add_item_tag(unsigned int which_output, uint64_t abs_offset, const pmt::pmt_t &key, const pmt::pmt_t &value, const pmt::pmt_t &srcid=pmt::PMT_F)
Adds a new tag onto the given output buffer.
Definition: block.h:605
bool output_multiple_set() const
Definition: block.h:195
gr::thread::mutex d_setlock
Definition: block.h:756
gr::logger_ptr d_logger
Definition: block.h:760
std::vector< const void * > gr_vector_const_void_star
Definition: gnuradio-runtime/include/gnuradio/types.h:38
int unaligned() const
Definition: block.h:218
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
int min_noutput_items() const
Return the minimum number of output items this block can produce during a call to work...
Definition: block.h:307
GR_RUNTIME_API int set_thread_priority(gr_thread_t thread, int priority)
get current thread priority for a given thread ID
std::vector< long > d_min_output_buffer
Definition: block.h:749
std::vector< void * > gr_vector_void_star
Definition: gnuradio-runtime/include/gnuradio/types.h:37
Definition: block_gateway.h:46
std::vector< int > gr_vector_int
Definition: gnuradio-runtime/include/gnuradio/types.h:33
std::vector< block_sptr >::iterator block_viter_t
Definition: block.h:772
std::vector< long > d_max_output_buffer
Definition: block.h:748
The abstract base class for all signal processing blocks.Basic blocks are the bare abstraction of an ...
Definition: basic_block.h:58
unsigned __int64 uint64_t
Definition: stdint.h:90
bool fixed_rate() const
Return true if this block has a fixed input to output rate.
Definition: block.h:130
block(void)
Definition: block.h:588
void set_min_noutput_items(int m)
Set the minimum number of output items this block can produce during a call to work.
Definition: block.h:315
GR_RUNTIME_API int thread_priority(gr_thread_t thread)
get current thread priority for a given thread ID
tag_propagation_policy_t
Definition: block.h:70
PMT_API const pmt_t PMT_F
bool is_pc_rpc_set()
Checks if this block is already exporting perf. counters to ControlPort.
Definition: block.h:520
pmt::pmt_t key
the key of tag (as a PMT symbol)
Definition: tags.h:37
Definition: block_gateway.h:45
std::ostream & operator<<(std::ostream &os, basic_block_sptr basic_block)
Definition: basic_block.h:367
VOLK_API $kern pname $kern name
A function pointer to the dispatcher implementation.
bool is_unaligned() const
Definition: block.h:220
boost::mutex mutex
Definition: thread.h:46
Definition: block_gateway.h:47
double relative_rate() const
return the approximate output rate / input rate
Definition: block.h:257
pmt::pmt_t srcid
the source ID of tag (as a PMT)
Definition: tags.h:43
boost::intrusive_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting). See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
Definition: pmt.h:56
The abstract base class for all 'terminal' processing blocks.A signal processing flow is constructed ...
Definition: block.h:60
tag_propagation_policy_t
Definition: block_gateway.h:44
void set_detail(block_detail_sptr detail)
Definition: block.h:768
int alignment() const
Definition: block.h:215
void no_pc_rpc()
If the block calls this in its constructor, it's perf. counters will not be exported.
Definition: block.h:526
void remove_item_tag(unsigned int which_input, uint64_t abs_offset, const pmt::pmt_t &key, const pmt::pmt_t &value, const pmt::pmt_t &srcid=pmt::PMT_F)
Removes a tag from the given input buffer.
Definition: block.h:639
int output_multiple() const
Definition: block.h:194