GNU Radio Manual and C++ API Reference 3.7.14.0
The Free & Open Software Radio Ecosystem
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>
31#include <pmt/pmt.h>
32
33namespace gr {
34namespace 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 */
49static inline pmt::pmt_t
50send(msg_accepter_sptr accepter, const pmt::pmt_t& which_port, const pmt::pmt_t& msg)
51{
52 accepter->post(which_port, msg);
53 return msg;
54}
55
56/*!
57 * \brief send message to msg_accepter
58 *
59 * \param accepter is the target of the send.
60 * \param which_port A pmt symbol describing the port by name.
61 * \param msg is the message to send. It's usually a pmt tuple.
62 *
63 * Sending a message is an asynchronous operation. The \p send
64 * call will not wait for the message either to arrive at the
65 * destination or to be received.
66 *
67 * \returns msg
68 */
69static inline pmt::pmt_t
70send(msg_accepter* accepter, const pmt::pmt_t& which_port, const pmt::pmt_t& msg)
71{
72 accepter->post(which_port, msg);
73 return msg;
74}
75
76/*!
77 * \brief send message to msg_accepter
78 *
79 * \param accepter is the target of the send.
80 * \param which_port A pmt symbol describing the port by name.
81 * \param msg is the message to send. It's usually a pmt tuple.
82 *
83 * Sending a message is an asynchronous operation. The \p send
84 * call will not wait for the message either to arrive at the
85 * destination or to be received.
86 *
87 * \returns msg
88 */
89static inline pmt::pmt_t
90send(msg_accepter& accepter, const pmt::pmt_t& which_port, const pmt::pmt_t& msg)
91{
92 accepter.post(which_port, msg);
93 return msg;
94}
95
96/*!
97 * \brief send message to msg_accepter
98 *
99 * \param accepter is the target of the send.
100 * aprecond: pmt::is_msg_accepter(accepter)
101 * \param which_port A pmt symbol describing the port by name.
102 * \param msg is the message to send. It's usually a pmt tuple.
103 *
104 * Sending a message is an asynchronous operation. The \p send
105 * call will not wait for the message either to arrive at the
106 * destination or to be received.
107 *
108 * \returns msg
109 */
110static inline pmt::pmt_t
111send(pmt::pmt_t accepter, const pmt::pmt_t& which_port, const pmt::pmt_t& msg)
112{
113 return send(pmt::msg_accepter_ref(accepter), which_port, msg);
114}
115
116} /* namespace messages */
117} /* namespace gr */
118
119#endif /* INCLUDED_MSG_PASSING_H */
Virtual base class that accepts messages.
Definition: messages/msg_accepter.h:36
virtual void post(pmt::pmt_t which_port, pmt::pmt_t msg)=0
send msg to msg_accepter on port which_port
static purpose_t msg
Definition: source_logger.h:39
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
Include this header to use the message passing features.
Definition: basic_block.h:45
PMT_API boost::shared_ptr< gr::messages::msg_accepter > msg_accepter_ref(const pmt_t &obj)
Return underlying msg_accepter.
boost::intrusive_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting). See http://www.boost....
Definition: pmt.h:56