GNU Radio Manual and C++ API Reference 3.10.5.1
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 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef INCLUDED_MSG_PASSING_H
12#define INCLUDED_MSG_PASSING_H
13
14/*!
15 * \brief Include this header to use the message passing features
16 */
17
18#include <gnuradio/api.h>
20#include <pmt/pmt.h>
21
22namespace gr {
23namespace messages {
24
25/*!
26 * \brief send message to msg_accepter
27 *
28 * \param accepter is the target of the send.
29 * \param which_port A pmt symbol describing the port by name.
30 * \param msg is the message to send. It's usually a pmt tuple.
31 *
32 * Sending a message is an asynchronous operation. The \p send
33 * call will not wait for the message either to arrive at the
34 * destination or to be received.
35 *
36 * \returns msg
37 */
38static inline pmt::pmt_t
39send(msg_accepter_sptr accepter, const pmt::pmt_t& which_port, const pmt::pmt_t& msg)
40{
41 accepter->post(which_port, msg);
42 return msg;
43}
44
45/*!
46 * \brief send message to msg_accepter
47 *
48 * \param accepter is the target of the send.
49 * \param which_port A pmt symbol describing the port by name.
50 * \param msg is the message to send. It's usually a pmt tuple.
51 *
52 * Sending a message is an asynchronous operation. The \p send
53 * call will not wait for the message either to arrive at the
54 * destination or to be received.
55 *
56 * \returns msg
57 */
58static inline pmt::pmt_t
59send(msg_accepter* accepter, const pmt::pmt_t& which_port, const pmt::pmt_t& msg)
60{
61 accepter->post(which_port, msg);
62 return msg;
63}
64
65/*!
66 * \brief send message to msg_accepter
67 *
68 * \param accepter is the target of the send.
69 * \param which_port A pmt symbol describing the port by name.
70 * \param msg is the message to send. It's usually a pmt tuple.
71 *
72 * Sending a message is an asynchronous operation. The \p send
73 * call will not wait for the message either to arrive at the
74 * destination or to be received.
75 *
76 * \returns msg
77 */
78static inline pmt::pmt_t
79send(msg_accepter& accepter, const pmt::pmt_t& which_port, const pmt::pmt_t& msg)
80{
81 accepter.post(which_port, msg);
82 return msg;
83}
84
85/*!
86 * \brief send message to msg_accepter
87 *
88 * \param accepter is the target of the send.
89 * aprecond: pmt::is_msg_accepter(accepter)
90 * \param which_port A pmt symbol describing the port by name.
91 * \param msg is the message to send. It's usually a pmt tuple.
92 *
93 * Sending a message is an asynchronous operation. The \p send
94 * call will not wait for the message either to arrive at the
95 * destination or to be received.
96 *
97 * \returns msg
98 */
99static inline pmt::pmt_t
100send(pmt::pmt_t accepter, const pmt::pmt_t& which_port, const pmt::pmt_t& msg)
101{
102 return send(pmt::msg_accepter_ref(accepter), which_port, msg);
103}
104
105} /* namespace messages */
106} /* namespace gr */
107
108#endif /* INCLUDED_MSG_PASSING_H */
Virtual base class that accepts messages.
Definition: messages/msg_accepter.h:25
virtual void post(pmt::pmt_t which_port, pmt::pmt_t msg)=0
send msg to msg_accepter on port which_port
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:39
GR_RUNTIME_API const pmt::pmt_t msg()
GNU Radio logging wrapper.
Definition: basic_block.h:29
PMT_API std::shared_ptr< gr::messages::msg_accepter > msg_accepter_ref(const pmt_t &obj)
Return underlying msg_accepter.
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition: pmt.h:83