message.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2006,2007,2008 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_MB_MESSAGE_H
00022 #define INCLUDED_MB_MESSAGE_H
00023 
00024 #include <mblock/common.h>
00025 #include <iosfwd>
00026 
00027 #define MB_MESSAGE_LOCAL_ALLOCATOR 0    // define to 0 or 1
00028 
00029 class mb_message;
00030 typedef boost::shared_ptr<mb_message> mb_message_sptr;
00031 
00032 /*!
00033  * \brief construct a message and return boost::shared_ptr
00034  *
00035  * \param signal        identifier of the message
00036  * \param data          the data to be operated on
00037  * \param metadata      information about the data
00038  * \param priority      urgency
00039  */
00040 mb_message_sptr
00041 mb_make_message(pmt_t signal,
00042                 pmt_t data = PMT_NIL,
00043                 pmt_t metadata = PMT_NIL,
00044                 mb_pri_t priority = MB_PRI_DEFAULT);
00045 
00046 class mb_message {
00047   mb_message_sptr d_next;               // link field for msg queue
00048   pmt_t           d_signal;
00049   pmt_t           d_data;
00050   pmt_t           d_metadata;
00051   mb_pri_t        d_priority;
00052   pmt_t           d_port_id;            // name of port msg was rcvd on (symbol)
00053 
00054   friend class mb_msg_queue;
00055 
00056   friend mb_message_sptr
00057   mb_make_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority);
00058 
00059   // private constructor
00060   mb_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority);
00061 
00062 public:
00063   ~mb_message();
00064 
00065   pmt_t signal() const { return d_signal; }
00066   pmt_t data() const { return d_data; }
00067   pmt_t metadata() const { return d_metadata; }
00068   mb_pri_t priority() const { return d_priority; }
00069   pmt_t port_id() const { return d_port_id; }
00070 
00071   void set_port_id(pmt_t port_id){ d_port_id = port_id; }
00072 
00073 #if (MB_MESSAGE_LOCAL_ALLOCATOR)
00074   void *operator new(size_t);
00075   void operator delete(void *, size_t);
00076 #endif
00077 };
00078 
00079 std::ostream& operator<<(std::ostream& os, const mb_message &msg);
00080 
00081 inline
00082 std::ostream& operator<<(std::ostream& os, const mb_message_sptr msg)
00083 {
00084   os << *(msg.get());
00085   return os;
00086 }
00087 
00088 #endif /* INCLUDED_MB_MESSAGE_H */

Generated on Wed Jul 29 06:24:26 2009 for GNU Radio 3.2.2 C++ API by  doxygen 1.5.9