GNU Radio 3.6.2 C++ API
gr_block_executor.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004,2008 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_BLOCK_EXECUTOR_H
24 #define INCLUDED_GR_BLOCK_EXECUTOR_H
25 
26 #include <gr_core_api.h>
27 #include <gr_runtime_types.h>
28 #include <fstream>
29 #include <gr_tags.h>
30 
31 //class gr_block_executor;
32 //typedef boost::shared_ptr<gr_block_executor> gr_block_executor_sptr;
33 
34 
35 /*!
36  * \brief Manage the execution of a single block.
37  * \ingroup internal
38  */
39 
41 protected:
42  gr_block_sptr d_block; // The block we're trying to run
43  std::ofstream *d_log;
44 
45  // These are allocated here so we don't have to on each iteration
46 
50  std::vector<bool> d_input_done;
52  std::vector<uint64_t> d_start_nitems_read; //stores where tag counts are before work
53  std::vector<gr_tag_t> d_returned_tags;
55 
56  public:
57  gr_block_executor(gr_block_sptr block, int max_noutput_items=100000);
59 
60  enum state {
61  READY, // We made progress; everything's cool.
62  READY_NO_OUTPUT, // We consumed some input, but produced no output.
63  BLKD_IN, // no progress; we're blocked waiting for input data.
64  BLKD_OUT, // no progress; we're blocked waiting for output buffer space.
65  DONE, // we're done; don't call me again.
66  };
67 
68  /*
69  * \brief Run one iteration.
70  */
71  state run_one_iteration();
72 };
73 
74 #endif /* INCLUDED_GR_BLOCK_EXECUTOR_H */