GNU Radio 3.6.5 C++ API

message_debug.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2005,2012-2013 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
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef INCLUDED_GR_MESSAGE_DEBUG_H
00024 #define INCLUDED_GR_MESSAGE_DEBUG_H
00025 
00026 #include <blocks/api.h>
00027 #include <gr_block.h>
00028 
00029 namespace gr {
00030   namespace blocks {
00031 
00032     /*!
00033      * \brief Debug block for the message passing system.
00034      * \ingroup message_tools_blk
00035      * \ingroup measurement_tools_blk
00036      * \ingroup debug_tools_blk
00037      *
00038      * \details
00039      * The message debug block is used to capture and print or store
00040      * messages as they are received. Any block that generates a
00041      * message may connect that message port to one or more of the
00042      * three message input ports of this debug block. The message
00043      * ports are:
00044      *
00045      * \li print: prints the message directly to standard out.
00046      * \li store: stores the message in an internal vector. May be
00047      *            access using the get_message function.
00048      * \li print_pdu: specifically designed to handle formatted PDUs
00049      *                (see pdu.h).
00050      */
00051     class BLOCKS_API message_debug : virtual public gr_block
00052     {
00053     public:
00054       // gr::blocks::message_debug::sptr
00055       typedef boost::shared_ptr<message_debug> sptr;
00056 
00057       /*! 
00058        * \brief Build the message debug block. It takes no parameters
00059        * and has three message ports: print, store, and
00060        * print_pdu.
00061        */
00062       static sptr make();
00063 
00064       /*! 
00065        * \brief Reports the number of messages received by this block.
00066        */
00067       virtual int num_messages() = 0;
00068 
00069       /*!
00070        * \brief Get a message (as a PMT) from the message vector at index \p i.
00071        *
00072        * Messages passed to the 'store' port will be stored in a
00073        * vector. This function retrieves those messages by index. They
00074        * are index in order of when they were received (all messages
00075        * are just pushed onto the back of a vector). This is mostly
00076        * useful in debugging message passing graphs and in QA code.
00077        *
00078        * \param i The index in the vector for the message to retrieve.
00079        *
00080        * \return a message at index \p i as a pmt_t.
00081        */
00082       virtual pmt::pmt_t get_message(int i) = 0;
00083     };
00084 
00085   } /* namespace blocks */
00086 } /* namespace gr */
00087 
00088 #endif /* INCLUDED_GR_MESSAGE_DEBUG_H */