Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / runtime / gr_block_executor.h
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_runtime_types.h>
27 #include <fstream>
28
29 //class gr_block_executor;
30 //typedef boost::shared_ptr<gr_block_executor>  gr_block_executor_sptr;
31
32
33 /*!
34  * \brief Manage the execution of a single block.
35  * \ingroup internal
36  */
37
38 class gr_block_executor {
39 protected:
40   gr_block_sptr                 d_block;        // The block we're trying to run
41   std::ofstream                *d_log;
42
43   // These are allocated here so we don't have to on each iteration
44
45   gr_vector_int                 d_ninput_items_required;
46   gr_vector_int                 d_ninput_items;
47   gr_vector_const_void_star     d_input_items;
48   std::vector<bool>             d_input_done;
49   gr_vector_void_star           d_output_items;
50
51  public:
52   gr_block_executor(gr_block_sptr block);
53   ~gr_block_executor ();
54
55   enum state {
56     READY,            // We made progress; everything's cool.
57     READY_NO_OUTPUT,  // We consumed some input, but produced no output.
58     BLKD_IN,          // no progress; we're blocked waiting for input data.
59     BLKD_OUT,         // no progress; we're blocked waiting for output buffer space.
60     DONE,             // we're done; don't call me again.
61   };
62
63   /*
64    * \brief Run one iteration.
65    */
66   state run_one_iteration();
67 };
68
69 #endif /* INCLUDED_GR_BLOCK_EXECUTOR_H */