GNU Radio 3.7.3 C++ API
msg_passing.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009,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 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 
22 #ifndef INCLUDED_MSG_PASSING_H
23 #define INCLUDED_MSG_PASSING_H
24 
25 /*!
26  * \brief Include this header to use the message passing features
27  */
28 
29 #include <gnuradio/api.h>
30 #include <pmt/pmt.h>
32 
33 namespace gr {
34  namespace messages {
35 
36  /*!
37  * \brief send message to msg_accepter
38  *
39  * \param accepter is the target of the send.
40  * \param which_port A pmt symbol describing the port by name.
41  * \param msg is the message to send. It's usually a pmt tuple.
42  *
43  * Sending a message is an asynchronous operation. The \p send
44  * call will not wait for the message either to arrive at the
45  * destination or to be received.
46  *
47  * \returns msg
48  */
49  static inline pmt::pmt_t
50  send(msg_accepter_sptr accepter, const pmt::pmt_t &which_port,
51  const pmt::pmt_t &msg)
52  {
53  accepter->post(which_port, msg);
54  return msg;
55  }
56 
57  /*!
58  * \brief send message to msg_accepter
59  *
60  * \param accepter is the target of the send.
61  * \param which_port A pmt symbol describing the port by name.
62  * \param msg is the message to send. It's usually a pmt tuple.
63  *
64  * Sending a message is an asynchronous operation. The \p send
65  * call will not wait for the message either to arrive at the
66  * destination or to be received.
67  *
68  * \returns msg
69  */
70  static inline pmt::pmt_t
71  send(msg_accepter *accepter, const pmt::pmt_t &which_port,
72  const pmt::pmt_t &msg)
73  {
74  accepter->post(which_port, msg);
75  return msg;
76  }
77 
78  /*!
79  * \brief send message to msg_accepter
80  *
81  * \param accepter is the target of the send.
82  * \param which_port A pmt symbol describing the port by name.
83  * \param msg is the message to send. It's usually a pmt tuple.
84  *
85  * Sending a message is an asynchronous operation. The \p send
86  * call will not wait for the message either to arrive at the
87  * destination or to be received.
88  *
89  * \returns msg
90  */
91  static inline pmt::pmt_t
92  send(msg_accepter &accepter, const pmt::pmt_t &which_port,
93  const pmt::pmt_t &msg)
94  {
95  accepter.post(which_port, msg);
96  return msg;
97  }
98 
99  /*!
100  * \brief send message to msg_accepter
101  *
102  * \param accepter is the target of the send.
103  * aprecond: pmt::is_msg_accepter(accepter)
104  * \param which_port A pmt symbol describing the port by name.
105  * \param msg is the message to send. It's usually a pmt tuple.
106  *
107  * Sending a message is an asynchronous operation. The \p send
108  * call will not wait for the message either to arrive at the
109  * destination or to be received.
110  *
111  * \returns msg
112  */
113  static inline pmt::pmt_t
114  send(pmt::pmt_t accepter, const pmt::pmt_t &which_port,
115  const pmt::pmt_t &msg)
116  {
117  return send(pmt::msg_accepter_ref(accepter), which_port, msg);
118  }
119 
120  } /* namespace messages */
121 } /* namespace gr */
122 
123 #endif /* INCLUDED_MSG_PASSING_H */
virtual void post(pmt::pmt_t which_port, pmt::pmt_t msg)=0
send msg to msg_accepter on port which_port
shared_ptr documentation stub
Definition: shared_ptr_docstub.h:15
static pmt::pmt_t send(msg_accepter_sptr accepter, const pmt::pmt_t &which_port, const pmt::pmt_t &msg)
send message to msg_accepter
Definition: msg_passing.h:50
Virtual base class that accepts messages.
Definition: messages/msg_accepter.h:35
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
PMT_API boost::shared_ptr< gr::messages::msg_accepter > msg_accepter_ref(const pmt_t &obj)
Return underlying msg_accepter.