GNU Radio 3.6.3 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2005,2012 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 <gr_core_api.h> 00027 #include <gr_block.h> 00028 #include <gr_message.h> 00029 #include <gr_msg_queue.h> 00030 #include <gruel/thread.h> 00031 00032 class gr_message_debug; 00033 typedef boost::shared_ptr<gr_message_debug> gr_message_debug_sptr; 00034 00035 GR_CORE_API gr_message_debug_sptr gr_make_message_debug(); 00036 00037 /*! 00038 * \brief Print received messages to stdout 00039 * \ingroup sink_blk 00040 */ 00041 class GR_CORE_API gr_message_debug : public gr_block 00042 { 00043 private: 00044 friend GR_CORE_API gr_message_debug_sptr 00045 gr_make_message_debug(); 00046 00047 /*! 00048 * \brief Messages received in this port are printed to stdout. 00049 * 00050 * This port receives messages from the scheduler's message handling 00051 * mechanism and prints it to stdout. This message handler function 00052 * is only meant to be used by the scheduler to handle messages 00053 * posted to port 'print'. 00054 * 00055 * \param msg A pmt message passed from the scheduler's message handling. 00056 */ 00057 void print(pmt::pmt_t msg); 00058 void print_verbose(pmt::pmt_t msg); 00059 00060 /*! 00061 * \brief Messages received in this port are stored in a vector. 00062 * 00063 * This port receives messages from the scheduler's message handling 00064 * mechanism and stores it in a vector. Messages can be retrieved 00065 * later using the 'get_message' function. This message handler 00066 * function is only meant to be used by the scheduler to handle 00067 * messages posted to port 'store'. 00068 * 00069 * \param msg A pmt message passed from the scheduler's message handling. 00070 */ 00071 void store(pmt::pmt_t msg); 00072 00073 gruel::mutex d_mutex; 00074 std::vector<pmt::pmt_t> d_messages; 00075 00076 protected: 00077 gr_message_debug (); 00078 00079 public: 00080 ~gr_message_debug (); 00081 00082 /*! 00083 * \brief Reports the number of messages received by this block. 00084 */ 00085 int num_messages(); 00086 00087 /*! 00088 * \brief Get a message (as a PMT) from the message vector at index \p i. 00089 * 00090 * Messages passed to the 'store' port will be stored in a 00091 * vector. This function retrieves those messages by index. They are 00092 * index in order of when they were received (all messages are just 00093 * pushed onto the back of a vector). This is mostly useful in 00094 * debugging message passing graphs and in QA code. 00095 * 00096 * \param i The index in the vector for the message to retrieve. 00097 * 00098 * \return a message at index \p i as a pmt_t. 00099 */ 00100 pmt::pmt_t get_message(int i); 00101 }; 00102 00103 #endif /* INCLUDED_GR_MESSAGE_DEBUG_H */