Imported Upstream version 3.2.2
[debian/gnuradio] / mblock / src / include / mblock / common.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006,2007,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_COMMON_H
22 #define INCLUDED_MB_COMMON_H
23
24 #include <pmt.h>
25 #include <vector>
26 #include <stdexcept>
27 #include <boost/utility.hpp>
28 #include <boost/enable_shared_from_this.hpp>
29 #include <boost/weak_ptr.hpp>
30
31 /*
32  * The priority type and valid range
33  */
34 typedef unsigned int    mb_pri_t;
35 static const mb_pri_t   MB_PRI_BEST    = 0;
36 static const mb_pri_t   MB_PRI_DEFAULT = 4; 
37 static const mb_pri_t   MB_PRI_WORST   = 7;
38 static const mb_pri_t   MB_NPRI = MB_PRI_WORST + 1;       // number of valid priorities 
39
40 /*!
41  * \brief return true iff priority a is better than priority b
42  */
43 inline static bool
44 mb_pri_better(mb_pri_t a, mb_pri_t b)
45 {
46   return a < b;
47 }
48
49 /*!
50  * \brief return true iff priority a is worse than priority b
51  */
52 inline static bool
53 mb_pri_worse(mb_pri_t a, mb_pri_t b)
54 {
55   return a > b;
56 }
57
58 /*!
59  * \brief ensure that pri is valid
60  */
61 inline static mb_pri_t
62 mb_pri_clamp(mb_pri_t p)
63 {
64   return p < MB_NPRI ? p : MB_NPRI - 1;
65 }
66
67 class mb_runtime;
68 typedef boost::shared_ptr<mb_runtime> mb_runtime_sptr;
69
70 //class mb_runtime_impl;
71 //typedef boost::shared_ptr<mb_runtime_impl> mb_runtime_impl_sptr;
72
73 class mb_mblock;
74 typedef boost::shared_ptr<mb_mblock> mb_mblock_sptr;
75
76 class mb_mblock_impl;
77 typedef boost::shared_ptr<mb_mblock_impl> mb_mblock_impl_sptr;
78
79 class mb_port;
80 typedef boost::shared_ptr<mb_port> mb_port_sptr;
81
82 //class mb_port_detail;
83 //typedef boost::shared_ptr<mb_port_detail> mb_port_detail_sptr;
84
85 class mb_msg_accepter;
86 typedef boost::shared_ptr<mb_msg_accepter> mb_msg_accepter_sptr;
87
88 class mb_message;
89 typedef boost::shared_ptr<mb_message> mb_message_sptr;
90
91 class mb_msg_queue;
92 typedef boost::shared_ptr<mb_msg_queue> mb_msg_queue_sptr;
93
94 #endif /* INCLUDED_MB_COMMON_H */