1 /* -*- c++ -*- */
2 /*
3  * Copyright 2005,2012-2013 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_GR_MESSAGE_DEBUG_IMPL_H
24 #define INCLUDED_GR_MESSAGE_DEBUG_IMPL_H
25 
26 #include <gnuradio/block.h>
27 #include <gnuradio/blocks/message_debug.h>
28 #include <gnuradio/thread/thread.h>
29 #include <pmt/pmt.h>
30 
31 namespace gr {
32 namespace blocks {
33 
34 class message_debug_impl : public message_debug
35 {
36 private:
37     /*!
38      * \brief Messages received in this port are printed to stdout.
39      *
40      * This port receives messages from the scheduler's message
41      * handling mechanism and prints it to stdout. This message
42      * handler function is only meant to be used by the scheduler to
43      * handle messages posted to port 'print'.
44      *
45      * \param msg A pmt message passed from the scheduler's message handling.
46      */
47     void print(pmt::pmt_t msg);
48 
49     /*!
50      * \brief PDU formatted messages received in this port are printed to stdout.
51      *
52      * This port receives messages from the scheduler's message
53      * handling mechanism and prints it to stdout. This message
54      * handler function is only meant to be used by the scheduler to
55      * handle messages posted to port 'print'.
56      *
57      * \param pdu A PDU message passed from the scheduler's message handling.
58      */
59     void print_pdu(pmt::pmt_t pdu);
60 
61     /*!
62      * \brief Messages received in this port are stored in a vector.
63      *
64      * This port receives messages from the scheduler's message
65      * handling mechanism and stores it in a vector. Messages can be
66      * retrieved later using the 'get_message' function. This
67      * message handler function is only meant to be used by the
68      * scheduler to handle messages posted to port 'store'.
69      *
70      * \param msg A pmt message passed from the scheduler's message handling.
71      */
72     void store(pmt::pmt_t msg);
73 
74     gr::thread::mutex d_mutex;
75     std::vector<pmt::pmt_t> d_messages;
76 
77 public:
78     message_debug_impl();
79     ~message_debug_impl();
80 
81     int num_messages();
82     pmt::pmt_t get_message(int i);
83 };
84 
85 } /* namespace blocks */
86 } /* namespace gr */
87 
88 #endif /* INCLUDED_GR_MESSAGE_DEBUG_IMPL_H */
89