gr_message.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef INCLUDED_GR_MESSAGE_H
00023 #define INCLUDED_GR_MESSAGE_H
00024
00025 #include <gr_types.h>
00026 #include <string>
00027
00028 class gr_message;
00029 typedef boost::shared_ptr<gr_message> gr_message_sptr;
00030
00034 gr_message_sptr
00035 gr_make_message(long type = 0, double arg1 = 0, double arg2 = 0, size_t length = 0);
00036
00037 gr_message_sptr
00038 gr_make_message_from_string(const std::string s, long type = 0, double arg1 = 0, double arg2 = 0);
00039
00047 class gr_message {
00048 gr_message_sptr d_next;
00049 long d_type;
00050 double d_arg1;
00051 double d_arg2;
00052
00053 unsigned char *d_buf_start;
00054 unsigned char *d_msg_start;
00055 unsigned char *d_msg_end;
00056 unsigned char *d_buf_end;
00057
00058 gr_message (long type, double arg1, double arg2, size_t length);
00059
00060 friend gr_message_sptr
00061 gr_make_message (long type, double arg1, double arg2, size_t length);
00062
00063 friend gr_message_sptr
00064 gr_make_message_from_string (const std::string s, long type, double arg1, double arg2);
00065
00066 friend class gr_msg_queue;
00067
00068 unsigned char *buf_data() const { return d_buf_start; }
00069 size_t buf_len() const { return d_buf_end - d_buf_start; }
00070
00071 public:
00072 ~gr_message ();
00073
00074 long type() const { return d_type; }
00075 double arg1() const { return d_arg1; }
00076 double arg2() const { return d_arg2; }
00077
00078 void set_type(long type) { d_type = type; }
00079 void set_arg1(double arg1) { d_arg1 = arg1; }
00080 void set_arg2(double arg2) { d_arg2 = arg2; }
00081
00082 unsigned char *msg() const { return d_msg_start; }
00083 size_t length() const { return d_msg_end - d_msg_start; }
00084 std::string to_string() const;
00085
00086 };
00087
00088 long gr_message_ncurrently_allocated ();
00089
00090 #endif