Imported Upstream version 3.2.2
[debian/gnuradio] / mblock / src / include / mblock / runtime.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006,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 along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 #ifndef INCLUDED_MB_RUNTIME_H
22 #define INCLUDED_MB_RUNTIME_H
23
24 #include <mblock/common.h>
25 #include <gnuradio/omnithread.h>
26
27 /*!
28  * \brief Public constructor (factory) for mb_runtime objects.
29  */
30 mb_runtime_sptr mb_make_runtime();
31
32 /*!
33  * \brief Abstract runtime support for m-blocks
34  *
35  * There should generally be only a single instance of this class.
36  */
37 class mb_runtime : boost::noncopyable,
38                    public boost::enable_shared_from_this<mb_runtime>
39 {
40 protected:  
41   mb_mblock_sptr        d_top;
42
43 public:
44   mb_runtime(){}
45   virtual ~mb_runtime();
46
47   /*!
48    * \brief Construct and run the specified mblock hierarchy.
49    *
50    * This routine turns into the m-block scheduler, and
51    * blocks until the system is shutdown.
52    *
53    * \param instance_name name of the top-level mblock (conventionally "top")
54    * \param class_name The class of the top-level mblock to create.
55    * \param user_arg The argument to pass to the top-level mblock constructor
56    * \param result The value passed to shutdown_all.
57    *
58    * \returns true if the system ran successfully.
59    */
60   virtual bool run(const std::string &instance_name,
61                    const std::string &class_name,
62                    pmt_t user_arg,
63                    pmt_t *result = 0) = 0;
64
65   // QA only...
66   mb_mblock_sptr top() { return d_top; }
67 };
68
69 #endif /* INCLUDED_MB_RUNTIME_H */