GNU Radio 3.5.3.2 C++ API
msg_passing.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2009 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License along
00018  * with this program; if not, write to the Free Software Foundation, Inc.,
00019  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00020  */
00021 #ifndef INCLUDED_GRUEL_MSG_PASSING_H
00022 #define INCLUDED_GRUEL_MSG_PASSING_H
00023 
00024 /*!
00025  * \brief Include this header to use the message passing features
00026  */
00027 
00028 #include <gruel/api.h>
00029 #include <gruel/pmt.h>
00030 #include <gruel/msg_accepter.h>
00031 
00032 
00033 namespace gruel {
00034 
00035   /*!
00036    * \brief send message to msg_accepter
00037    *
00038    * \param accepter is the target of the send.
00039    * \param msg is the message to send.  It's usually a pmt tuple.
00040    *
00041    * Sending a message is an asynchronous operation.  The \p send
00042    * call will not wait for the message either to arrive at the
00043    * destination or to be received.
00044    *
00045    * \returns msg
00046    */
00047   static inline pmt::pmt_t
00048   send(msg_accepter_sptr accepter, const pmt::pmt_t &msg)
00049   {
00050     accepter->post(msg);
00051     return msg;
00052   }
00053 
00054   /*!
00055    * \brief send message to msg_accepter
00056    *
00057    * \param accepter is the target of the send.
00058    * \param msg is the message to send.  It's usually a pmt tuple.
00059    *
00060    * Sending a message is an asynchronous operation.  The \p send
00061    * call will not wait for the message either to arrive at the
00062    * destination or to be received.
00063    *
00064    * \returns msg
00065    */
00066   static inline pmt::pmt_t
00067   send(msg_accepter *accepter, const pmt::pmt_t &msg)
00068   {
00069     accepter->post(msg);
00070     return msg;
00071   }
00072 
00073   /*!
00074    * \brief send message to msg_accepter
00075    *
00076    * \param accepter is the target of the send.
00077    * \param msg is the message to send.  It's usually a pmt tuple.
00078    *
00079    * Sending a message is an asynchronous operation.  The \p send
00080    * call will not wait for the message either to arrive at the
00081    * destination or to be received.
00082    *
00083    * \returns msg
00084    */
00085   static inline pmt::pmt_t
00086   send(msg_accepter &accepter, const pmt::pmt_t &msg)
00087   {
00088     accepter.post(msg);
00089     return msg;
00090   }
00091 
00092   /*!
00093    * \brief send message to msg_accepter
00094    *
00095    * \param accepter is the target of the send.  precond: pmt_is_msg_accepter(accepter)
00096    * \param msg is the message to send.  It's usually a pmt tuple.
00097    *
00098    * Sending a message is an asynchronous operation.  The \p send
00099    * call will not wait for the message either to arrive at the
00100    * destination or to be received.
00101    *
00102    * \returns msg
00103    */
00104   static inline pmt::pmt_t
00105   send(pmt::pmt_t accepter, const pmt::pmt_t &msg)
00106   {
00107     return send(pmt_msg_accepter_ref(accepter), msg);
00108   }
00109 
00110 } /* namespace gruel */
00111 
00112 #endif /* INCLUDED_GRUEL_MSG_PASSING_H */