GNU Radio Manual and C++ API Reference 3.8.5.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
message.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2005,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_H
24#define INCLUDED_GR_MESSAGE_H
25
26#include <gnuradio/api.h>
27#include <gnuradio/types.h>
28#include <string>
29
30namespace gr {
31
32/*!
33 * \brief Message class.
34 *
35 * \ingroup misc
36 * The ideas and method names for adjustable message length were
37 * lifted from the click modular router "Packet" class.
38 */
40{
41public:
42 typedef boost::shared_ptr<message> sptr;
43
44private:
45 sptr d_next; // link field for msg queue
46 long d_type; // type of the message
47 double d_arg1; // optional arg1
48 double d_arg2; // optional arg2
49
50 unsigned char* d_buf_start; // start of allocated buffer
51 unsigned char* d_msg_start; // where the msg starts
52 unsigned char* d_msg_end; // one beyond end of msg
53 unsigned char* d_buf_end; // one beyond end of allocated buffer
54
55 message(long type, double arg1, double arg2, size_t length);
56
57 friend class msg_queue;
58
59 unsigned char* buf_data() const { return d_buf_start; }
60 size_t buf_len() const { return d_buf_end - d_buf_start; }
61
62public:
63 /*!
64 * \brief public constructor for message
65 */
66 static sptr make(long type = 0, double arg1 = 0, double arg2 = 0, size_t length = 0);
67
68 static sptr make_from_string(const std::string s,
69 long type = 0,
70 double arg1 = 0,
71 double arg2 = 0);
72
73
75
76 long type() const { return d_type; }
77 double arg1() const { return d_arg1; }
78 double arg2() const { return d_arg2; }
79
80 void set_type(long type) { d_type = type; }
81 void set_arg1(double arg1) { d_arg1 = arg1; }
82 void set_arg2(double arg2) { d_arg2 = arg2; }
83
84 unsigned char* msg() const { return d_msg_start; }
85 size_t length() const { return d_msg_end - d_msg_start; }
86 std::string to_string() const;
87};
88
90
91} /* namespace gr */
92
93#endif /* INCLUDED_GR_MESSAGE_H */
Message class.
Definition message.h:40
static sptr make_from_string(const std::string s, long type=0, double arg1=0, double arg2=0)
double arg1() const
Definition message.h:77
static sptr make(long type=0, double arg1=0, double arg2=0, size_t length=0)
public constructor for message
size_t length() const
Definition message.h:85
boost::shared_ptr< message > sptr
Definition message.h:42
long type() const
Definition message.h:76
void set_arg2(double arg2)
Definition message.h:82
double arg2() const
Definition message.h:78
std::string to_string() const
unsigned char * msg() const
Definition message.h:84
void set_arg1(double arg1)
Definition message.h:81
void set_type(long type)
Definition message.h:80
thread-safe message queue
Definition msg_queue.h:37
#define GR_RUNTIME_API
Definition gnuradio-runtime/include/gnuradio/api.h:30
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition basic_block.h:46
GR_RUNTIME_API long message_ncurrently_allocated()