GNU Radio Manual and C++ API Reference  3.7.6.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  * This function should be called at the end of work() or general_work(), after all processing is finished.
226  */
227  void consume(int which_input, int how_many_items);
228 
229  /*!
230  * \brief Tell the scheduler \p how_many_items were consumed on
231  * each input stream.
232  */
233  void consume_each(int how_many_items);
234 
235  /*!
236  * \brief Tell the scheduler \p how_many_items were produced on
237  * output stream \p which_output.
238  *
239  * If the block's general_work method calls produce, \p
240  * general_work must return WORK_CALLED_PRODUCE.
241  */
242  void produce(int which_output, int how_many_items);
243 
244  /*!
245  * \brief Set the approximate output rate / input rate
246  *
247  * Provide a hint to the buffer allocator and scheduler.
248  * The default relative_rate is 1.0
249  *
250  * decimators have relative_rates < 1.0
251  * interpolators have relative_rates > 1.0
252  */
253  void set_relative_rate(double relative_rate);
254 
255  /*!
256  * \brief return the approximate output rate / input rate
257  */
258  double relative_rate() const { return d_relative_rate; }
259 
260  /*
261  * The following two methods provide special case info to the
262  * scheduler in the event that a block has a fixed input to output
263  * ratio. sync_block, sync_decimator and
264  * sync_interpolator override these. If you're fixed rate,
265  * subclass one of those.
266  */
267  /*!
268  * \brief Given ninput samples, return number of output samples that will be produced.
269  * N.B. this is only defined if fixed_rate returns true.
270  * Generally speaking, you don't need to override this.
271  */
272  virtual int fixed_rate_ninput_to_noutput(int ninput);
273 
274  /*!
275  * \brief Given noutput samples, return number of input samples required to produce noutput.
276  * N.B. this is only defined if fixed_rate returns true.
277  * Generally speaking, you don't need to override this.
278  */
279  virtual int fixed_rate_noutput_to_ninput(int noutput);
280 
281  /*!
282  * \brief Return the number of items read on input stream which_input
283  */
284  uint64_t nitems_read(unsigned int which_input);
285 
286  /*!
287  * \brief Return the number of items written on output stream which_output
288  */
289  uint64_t nitems_written(unsigned int which_output);
290 
291  /*!
292  * \brief Asks for the policy used by the scheduler to moved tags downstream.
293  */
294  tag_propagation_policy_t tag_propagation_policy();
295 
296  /*!
297  * \brief Set the policy by the scheduler to determine how tags are moved downstream.
298  */
299  void set_tag_propagation_policy(tag_propagation_policy_t p);
300 
301  /*!
302  * \brief Return the minimum number of output items this block can
303  * produce during a call to work.
304  *
305  * Should be 0 for most blocks. Useful if we're dealing with
306  * packets and the block produces one packet per call to work.
307  */
308  int min_noutput_items() const { return d_min_noutput_items; }
309 
310  /*!
311  * \brief Set the minimum number of output items this block can
312  * produce during a call to work.
313  *
314  * \param m the minimum noutput_items this block can produce.
315  */
316  void set_min_noutput_items(int m) { d_min_noutput_items = m; }
317 
318  /*!
319  * \brief Return the maximum number of output items this block will
320  * handle during a call to work.
321  */
322  int max_noutput_items();
323 
324  /*!
325  * \brief Set the maximum number of output items this block will
326  * handle during a call to work.
327  *
328  * \param m the maximum noutput_items this block will handle.
329  */
330  void set_max_noutput_items(int m);
331 
332  /*!
333  * \brief Clear the switch for using the max_noutput_items value of this block.
334  *
335  * When is_set_max_noutput_items() returns 'true', the scheduler
336  * will use the value returned by max_noutput_items() to limit the
337  * size of the number of items possible for this block's work
338  * function. If is_set_max_notput_items() returns 'false', then
339  * the scheduler ignores the internal value and uses the value set
340  * globally in the top_block.
341  *
342  * Use this value to clear the 'is_set' flag so the scheduler will
343  * ignore this. Use the set_max_noutput_items(m) call to both set
344  * a new value for max_noutput_items and to reenable its use in
345  * the scheduler.
346  */
347  void unset_max_noutput_items();
348 
349  /*!
350  * \brief Ask the block if the flag is or is not set to use the
351  * internal value of max_noutput_items during a call to work.
352  */
353  bool is_set_max_noutput_items();
354 
355  /*
356  * Used to expand the vectors that hold the min/max buffer sizes.
357  *
358  * Specifically, when -1 is used, the vectors are just initialized
359  * with 1 value; this is used by the flat_flowgraph to expand when
360  * required to add a new value for new ports on these blocks.
361  */
362  void expand_minmax_buffer(int port);
363 
364  /*!
365  * \brief Returns max buffer size on output port \p i.
366  */
367  long max_output_buffer(size_t i);
368 
369  /*!
370  * \brief Sets max buffer size on all output ports.
371  */
372  void set_max_output_buffer(long max_output_buffer);
373 
374  /*!
375  * \brief Sets max buffer size on output port \p port.
376  */
377  void set_max_output_buffer(int port, long max_output_buffer);
378 
379  /*!
380  * \brief Returns min buffer size on output port \p i.
381  */
382  long min_output_buffer(size_t i);
383 
384  /*!
385  * \brief Sets min buffer size on all output ports.
386  */
387  void set_min_output_buffer(long min_output_buffer);
388 
389  /*!
390  * \brief Sets min buffer size on output port \p port.
391  */
392  void set_min_output_buffer(int port, long min_output_buffer);
393 
394  // --------------- Performance counter functions -------------
395 
396  /*!
397  * \brief Gets instantaneous noutput_items performance counter.
398  */
399  float pc_noutput_items();
400 
401  /*!
402  * \brief Gets average noutput_items performance counter.
403  */
404  float pc_noutput_items_avg();
405 
406  /*!
407  * \brief Gets variance of noutput_items performance counter.
408  */
409  float pc_noutput_items_var();
410 
411  /*!
412  * \brief Gets instantaneous num items produced performance counter.
413  */
414  float pc_nproduced();
415 
416  /*!
417  * \brief Gets average num items produced performance counter.
418  */
419  float pc_nproduced_avg();
420 
421  /*!
422  * \brief Gets variance of num items produced performance counter.
423  */
424  float pc_nproduced_var();
425 
426  /*!
427  * \brief Gets instantaneous fullness of \p which input buffer.
428  */
429  float pc_input_buffers_full(int which);
430 
431  /*!
432  * \brief Gets average fullness of \p which input buffer.
433  */
434  float pc_input_buffers_full_avg(int which);
435 
436  /*!
437  * \brief Gets variance of fullness of \p which input buffer.
438  */
439  float pc_input_buffers_full_var(int which);
440 
441  /*!
442  * \brief Gets instantaneous fullness of all input buffers.
443  */
444  std::vector<float> pc_input_buffers_full();
445 
446  /*!
447  * \brief Gets average fullness of all input buffers.
448  */
449  std::vector<float> pc_input_buffers_full_avg();
450 
451  /*!
452  * \brief Gets variance of fullness of all input buffers.
453  */
454  std::vector<float> pc_input_buffers_full_var();
455 
456  /*!
457  * \brief Gets instantaneous fullness of \p which input buffer.
458  */
459  float pc_output_buffers_full(int which);
460 
461  /*!
462  * \brief Gets average fullness of \p which input buffer.
463  */
464  float pc_output_buffers_full_avg(int which);
465 
466  /*!
467  * \brief Gets variance of fullness of \p which input buffer.
468  */
469  float pc_output_buffers_full_var(int which);
470 
471  /*!
472  * \brief Gets instantaneous fullness of all output buffers.
473  */
474  std::vector<float> pc_output_buffers_full();
475 
476  /*!
477  * \brief Gets average fullness of all output buffers.
478  */
479  std::vector<float> pc_output_buffers_full_avg();
480 
481  /*!
482  * \brief Gets variance of fullness of all output buffers.
483  */
484  std::vector<float> pc_output_buffers_full_var();
485 
486  /*!
487  * \brief Gets instantaneous clock cycles spent in work.
488  */
489  float pc_work_time();
490 
491  /*!
492  * \brief Gets average clock cycles spent in work.
493  */
494  float pc_work_time_avg();
495 
496  /*!
497  * \brief Gets average clock cycles spent in work.
498  */
499  float pc_work_time_var();
500 
501  /*!
502  * \brief Gets total clock cycles spent in work.
503  */
504  float pc_work_time_total();
505 
506  /*!
507  * \brief Gets average throughput.
508  */
509  float pc_throughput_avg();
510 
511  /*!
512  * \brief Resets the performance counters
513  */
514  void reset_perf_counters();
515 
516  /*!
517  * \brief Sets up export of perf. counters to ControlPort. Only
518  * called by the scheduler.
519  */
520  void setup_pc_rpc();
521 
522  /*!
523  * \brief Checks if this block is already exporting perf. counters
524  * to ControlPort.
525  */
526  bool is_pc_rpc_set() { return d_pc_rpc_set; }
527 
528  /*!
529  * \brief If the block calls this in its constructor, it's
530  * perf. counters will not be exported.
531  */
532  void no_pc_rpc() { d_pc_rpc_set = true; }
533 
534 
535  // ----------------------------------------------------------------------------
536  // Functions to handle thread affinity
537 
538  /*!
539  * \brief Set the thread's affinity to processor core \p n.
540  *
541  * \param mask a vector of ints of the core numbers available to this block.
542  */
543  void set_processor_affinity(const std::vector<int> &mask);
544 
545  /*!
546  * \brief Remove processor affinity to a specific core.
547  */
548  void unset_processor_affinity();
549 
550  /*!
551  * \brief Get the current processor affinity.
552  */
553  std::vector<int> processor_affinity() { return d_affinity; }
554 
555  /*!
556  * \brief Get the current thread priority in use
557  */
558  int active_thread_priority();
559 
560  /*!
561  * \brief Get the current thread priority stored
562  */
563  int thread_priority();
564 
565  /*!
566  * \brief Set the current thread priority
567  */
568  int set_thread_priority(int priority);
569 
570  bool update_rate() const;
571 
572  // ----------------------------------------------------------------------------
573 
574  /*!
575  * \brief the system message handler
576  */
577  void system_handler(pmt::pmt_t msg);
578 
579  /*!
580  * \brief returns true when execution has completed due to a message connection
581  */
582  bool finished();
583 
584  private:
585  int d_output_multiple;
586  bool d_output_multiple_set;
587  int d_unaligned;
588  bool d_is_unaligned;
589  double d_relative_rate; // approx output_rate / input_rate
590  block_detail_sptr d_detail; // implementation details
591  unsigned d_history;
592  unsigned d_attr_delay; // the block's sample delay
593  bool d_fixed_rate;
594  bool d_max_noutput_items_set; // if d_max_noutput_items is valid
595  int d_max_noutput_items; // value of max_noutput_items for this block
596  int d_min_noutput_items;
597  tag_propagation_policy_t d_tag_propagation_policy; // policy for moving tags downstream
598  std::vector<int> d_affinity; // thread affinity proc. mask
599  int d_priority; // thread priority level
600  bool d_pc_rpc_set;
601  bool d_update_rate; // should sched update rel rate?
602  bool d_finished; // true if msg ports think we are finished
603 
604  protected:
605  block(void) {} // allows pure virtual interface sub-classes
606  block(const std::string &name,
607  gr::io_signature::sptr input_signature,
608  gr::io_signature::sptr output_signature);
609 
610  void set_fixed_rate(bool fixed_rate) { d_fixed_rate = fixed_rate; }
611 
612  /*!
613  * \brief Adds a new tag onto the given output buffer.
614  *
615  * \param which_output an integer of which output stream to attach the tag
616  * \param abs_offset a uint64 number of the absolute item number
617  * assicated with the tag. Can get from nitems_written.
618  * \param key the tag key as a PMT symbol
619  * \param value any PMT holding any value for the given key
620  * \param srcid optional source ID specifier; defaults to PMT_F
621  */
622  inline void add_item_tag(unsigned int which_output,
623  uint64_t abs_offset,
624  const pmt::pmt_t &key,
625  const pmt::pmt_t &value,
626  const pmt::pmt_t &srcid=pmt::PMT_F)
627  {
628  tag_t tag;
629  tag.offset = abs_offset;
630  tag.key = key;
631  tag.value = value;
632  tag.srcid = srcid;
633  this->add_item_tag(which_output, tag);
634  }
635 
636  /*!
637  * \brief Adds a new tag onto the given output buffer.
638  *
639  * \param which_output an integer of which output stream to attach the tag
640  * \param tag the tag object to add
641  */
642  void add_item_tag(unsigned int which_output, const tag_t &tag);
643 
644  /*!
645  * \brief DEPRECATED. Will be removed in 3.8.
646  *
647  * \param which_input an integer of which input stream to remove the tag from
648  * \param abs_offset a uint64 number of the absolute item number
649  * assicated with the tag. Can get from nitems_written.
650  * \param key the tag key as a PMT symbol
651  * \param value any PMT holding any value for the given key
652  * \param srcid optional source ID specifier; defaults to PMT_F
653  *
654  * If no such tag is found, does nothing.
655  */
656  inline void remove_item_tag(unsigned int which_input,
657  uint64_t abs_offset,
658  const pmt::pmt_t &key,
659  const pmt::pmt_t &value,
660  const pmt::pmt_t &srcid=pmt::PMT_F)
661  {
662  tag_t tag;
663  tag.offset = abs_offset;
664  tag.key = key;
665  tag.value = value;
666  tag.srcid = srcid;
667  this->remove_item_tag(which_input, tag);
668  }
669 
670  /*!
671  * \brief DEPRECATED. Will be removed in 3.8.
672  *
673  * \param which_input an integer of which input stream to remove the tag from
674  * \param tag the tag object to remove
675  */
676  void remove_item_tag(unsigned int which_input, const tag_t &tag);
677 
678  /*!
679  * \brief Given a [start,end), returns a vector of all tags in the range.
680  *
681  * Range of counts is from start to end-1.
682  *
683  * Tags are tuples of:
684  * (item count, source id, key, value)
685  *
686  * \param v a vector reference to return tags into
687  * \param which_input an integer of which input stream to pull from
688  * \param abs_start a uint64 count of the start of the range of interest
689  * \param abs_end a uint64 count of the end of the range of interest
690  */
691  void get_tags_in_range(std::vector<tag_t> &v,
692  unsigned int which_input,
693  uint64_t abs_start,
694  uint64_t abs_end);
695 
696  /*!
697  * \brief Given a [start,end), returns a vector of all tags in the
698  * range with a given key.
699  *
700  * Range of counts is from start to end-1.
701  *
702  * Tags are tuples of:
703  * (item count, source id, key, value)
704  *
705  * \param v a vector reference to return tags into
706  * \param which_input an integer of which input stream to pull from
707  * \param abs_start a uint64 count of the start of the range of interest
708  * \param abs_end a uint64 count of the end of the range of interest
709  * \param key a PMT symbol key to filter only tags of this key
710  */
711  void get_tags_in_range(std::vector<tag_t> &v,
712  unsigned int which_input,
713  uint64_t abs_start,
714  uint64_t abs_end,
715  const pmt::pmt_t &key);
716 
717  /*!
718  * \brief Gets all tags within the relative window of the current call to work.
719  *
720  * \details
721  *
722  * This opperates much like get_tags_in_range but allows us to
723  * work within the current window of items. Item range is
724  * therefore within the possible range of 0 to
725  * ninput_items[whic_input].
726  *
727  * Range of items counts from \p rel_start to \p rel_end-1 within
728  * current window.
729  *
730  * Tags are tuples of:
731  * (item count, source id, key, value)
732  *
733  * \param v a vector reference to return tags into
734  * \param which_input an integer of which input stream to pull from
735  * \param rel_start a uint64 count of the start of the range of interest
736  * \param rel_end a uint64 count of the end of the range of interest
737  */
738  void get_tags_in_window(std::vector<tag_t> &v,
739  unsigned int which_input,
740  uint64_t rel_start,
741  uint64_t rel_end);
742 
743  /*!
744  * \brief Operates like gr::block::get_tags_in_window with the
745  * ability to only return tags with the specified \p key.
746  *
747  * \details
748  *
749  * \param v a vector reference to return tags into
750  * \param which_input an integer of which input stream to pull from
751  * \param rel_start a uint64 count of the start of the range of interest
752  * \param rel_end a uint64 count of the end of the range of interest
753  * \param key a PMT symbol key to filter only tags of this key
754  */
755  void get_tags_in_window(std::vector<tag_t> &v,
756  unsigned int which_input,
757  uint64_t rel_start,
758  uint64_t rel_end,
759  const pmt::pmt_t &key);
760 
761  void enable_update_rate(bool en);
762 
763  std::vector<long> d_max_output_buffer;
764  std::vector<long> d_min_output_buffer;
765 
766  /*! Used by block's setters and work functions to make
767  * setting/resetting of parameters thread-safe.
768  *
769  * Used by calling gr::thread::scoped_lock l(d_setlock);
770  */
772 
773  /*! Used by blocks to access the logger system.
774  */
777 
778  // These are really only for internal use, but leaving them public avoids
779  // having to work up an ever-varying list of friend GR_RUNTIME_APIs
780 
781  public:
782  block_detail_sptr detail() const { return d_detail; }
783  void set_detail(block_detail_sptr detail) { d_detail = detail; }
784 
785  /*! \brief Tell msg neighbors we are finished
786  */
787  void notify_msg_neighbors();
788 
789  /*! \brief Make sure we dont think we are finished
790  */
791  void clear_finished(){ d_finished = false; }
792 
793  };
794 
795  typedef std::vector<block_sptr> block_vector_t;
796  typedef std::vector<block_sptr>::iterator block_viter_t;
797 
798  inline block_sptr cast_to_block_sptr(basic_block_sptr p)
799  {
800  return boost::dynamic_pointer_cast<block, basic_block>(p);
801  }
802 
803  std::ostream&
804  operator << (std::ostream& os, const block *m);
805 
806 } /* namespace gr */
807 
808 #endif /* INCLUDED_GR_RUNTIME_BLOCK_H */
boost::shared_ptr< io_signature > sptr
Definition: io_signature.h:45
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:776
std::vector< int > processor_affinity()
Get the current processor affinity.
Definition: block.h:553
std::vector< block_sptr > block_vector_t
Definition: block.h:795
block_detail_sptr detail() const
Definition: block.h:782
void set_fixed_rate(bool fixed_rate)
Definition: block.h:610
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:622
bool output_multiple_set() const
Definition: block.h:195
gr::thread::mutex d_setlock
Definition: block.h:771
gr::logger_ptr d_logger
Definition: block.h:775
std::vector< const void * > gr_vector_const_void_star
Definition: gnuradio-runtime/include/gnuradio/types.h:38
Definition: cc_common.h:45
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:308
void clear_finished()
Make sure we dont think we are finished.
Definition: block.h:791
GR_RUNTIME_API int set_thread_priority(gr_thread_t thread, int priority)
set current thread priority for a given thread ID
std::vector< long > d_min_output_buffer
Definition: block.h:764
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:796
std::vector< long > d_max_output_buffer
Definition: block.h:763
The abstract base class for all signal processing blocks.Basic blocks are the bare abstraction of an ...
Definition: basic_block.h:58
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:605
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:316
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:526
pmt::pmt_t key
the key of tag (as a PMT symbol)
Definition: tags.h:37
log4cpp::Category * logger_ptr
GR_LOG macrosThese macros wrap the standard LOG4CPP_LEVEL macros. The availablie macros are: LOG_DEBU...
Definition: logger.h:147
Definition: block_gateway.h:45
std::ostream & operator<<(std::ostream &os, basic_block_sptr basic_block)
Definition: basic_block.h:399
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:258
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:783
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:532
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)
DEPRECATED. Will be removed in 3.8.
Definition: block.h:656
int output_multiple() const
Definition: block.h:194