00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef INCLUDED_MB_MESSAGE_H
00022 #define INCLUDED_MB_MESSAGE_H
00023
00024 #include <mblock/common.h>
00025 #include <iosfwd>
00026
00027 #define MB_MESSAGE_LOCAL_ALLOCATOR 0 // define to 0 or 1
00028
00029 class mb_message;
00030 typedef boost::shared_ptr<mb_message> mb_message_sptr;
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 mb_message_sptr
00041 mb_make_message(pmt_t signal,
00042 pmt_t data = PMT_NIL,
00043 pmt_t metadata = PMT_NIL,
00044 mb_pri_t priority = MB_PRI_DEFAULT);
00045
00046 class mb_message {
00047 mb_message_sptr d_next;
00048 pmt_t d_signal;
00049 pmt_t d_data;
00050 pmt_t d_metadata;
00051 mb_pri_t d_priority;
00052 pmt_t d_port_id;
00053
00054 friend class mb_msg_queue;
00055
00056 friend mb_message_sptr
00057 mb_make_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority);
00058
00059
00060 mb_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority);
00061
00062 public:
00063 ~mb_message();
00064
00065 pmt_t signal() const { return d_signal; }
00066 pmt_t data() const { return d_data; }
00067 pmt_t metadata() const { return d_metadata; }
00068 mb_pri_t priority() const { return d_priority; }
00069 pmt_t port_id() const { return d_port_id; }
00070
00071 void set_port_id(pmt_t port_id){ d_port_id = port_id; }
00072
00073 #if (MB_MESSAGE_LOCAL_ALLOCATOR)
00074 void *operator new(size_t);
00075 void operator delete(void *, size_t);
00076 #endif
00077 };
00078
00079 std::ostream& operator<<(std::ostream& os, const mb_message &msg);
00080
00081 inline
00082 std::ostream& operator<<(std::ostream& os, const mb_message_sptr msg)
00083 {
00084 os << *(msg.get());
00085 return os;
00086 }
00087
00088 #endif