24 #include <interface/message.h> 25 #include <interface/interface.h> 27 #include <core/threading/thread.h> 28 #include <core/threading/mutex.h> 29 #include <core/exceptions/software.h> 30 #include <utils/time/time.h> 67 Message::Message(
const char *type)
69 __fieldinfo_list = NULL;
79 __time_enqueued =
new Time();
81 _transmit_via_iface = NULL;
82 sender_interface_instance_serial = 0;
83 recipient_interface_mem_serial = 0;
85 Thread *t = Thread::current_thread_noexc();
87 _sender_thread_name = strdup(t->
name());
89 _sender_thread_name = strdup(
"Unknown");
100 __hops = mesg.__hops;
102 __num_fields = mesg.__num_fields;
104 data_ptr = malloc(data_size);
107 _type = strdup(mesg._type);
108 __time_enqueued =
new Time(mesg.__time_enqueued);
110 _transmit_via_iface = NULL;
111 sender_interface_instance_serial = 0;
112 recipient_interface_mem_serial = 0;
114 memcpy(data_ptr, mesg.
data_ptr, data_size);
121 *info_dest = new_info;
123 info_dest = &((*info_dest)->next);
124 info_src = info_src->
next;
127 Thread *t = Thread::current_thread_noexc();
129 _sender_thread_name = strdup(t->
name());
131 _sender_thread_name = strdup(
"Unknown");
142 __hops = mesg->__hops;
144 __num_fields = mesg->__num_fields;
146 data_ptr = malloc(data_size);
149 _type = strdup(mesg->_type);
150 _transmit_via_iface = NULL;
151 sender_interface_instance_serial = 0;
152 recipient_interface_mem_serial = 0;
153 __time_enqueued =
new Time(mesg->__time_enqueued);
155 memcpy(data_ptr, mesg->
data_ptr, data_size);
162 *info_dest = new_info;
164 info_dest = &((*info_dest)->next);
165 info_src = info_src->
next;
168 Thread *t = Thread::current_thread_noexc();
170 _sender_thread_name = strdup(t->
name());
172 _sender_thread_name = strdup(
"Unknown");
180 free(_sender_thread_name);
182 delete __time_enqueued;
186 __fieldinfo_list = __fieldinfo_list->
next;
188 infol = __fieldinfo_list;
207 Message::hops()
const 217 Message::set_id(
unsigned int message_id)
219 __message_id = message_id;
227 Message::set_hops(
unsigned int hops)
235 Message::mark_enqueued()
237 __time_enqueued->stamp();
238 long sec = 0, usec = 0;
239 __time_enqueued->get_timestamp(sec, usec);
240 data_ts->timestamp_sec = sec;
241 data_ts->timestamp_usec = usec;
251 Message::enqueued()
const 265 Message::time_enqueued()
const 267 return __time_enqueued;
275 Message::recipient()
const 277 return recipient_interface_mem_serial;
285 Message::datachunk()
const 295 Message::datasize()
const 307 Message::set_from_chunk(
const void *chunk)
309 memcpy(data_ptr, chunk, data_size);
310 __time_enqueued->set_time(data_ts->timestamp_sec, data_ts->timestamp_usec);
323 memcpy(data_ptr, m.
data_ptr, data_size);
324 __time_enqueued->set_time(data_ts->timestamp_sec, data_ts->timestamp_usec);
335 Message::sender_thread_name()
const 337 return _sender_thread_name;
345 Message::sender_id()
const 358 _transmit_via_iface = iface;
359 _sender_id = iface->
serial();
360 recipient_interface_mem_serial = iface->
mem_serial();
368 Message::interface()
const 370 return _transmit_via_iface;
378 Message::type()
const 398 Message::fields_end()
408 Message::num_fields()
const 419 Message::clone()
const 437 size_t length,
void *value,
const char *enumtype,
443 newinfo->
type = type;
445 newinfo->
name = name;
447 newinfo->
value = value;
449 newinfo->
next = NULL;
451 if ( infol == NULL ) {
453 __fieldinfo_list = newinfo;
456 while ( infol->
next != NULL ) {
459 infol->
next = newinfo;
Interface field iterator.
void * data_ptr
Pointer to memory that contains local data.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Interface field info list.
Fawkes library namespace.
const char * name
Name of this field.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
interface_fieldinfo_t * next
next field, NULL if last
A class for handling time.
Thread class encapsulation of pthreads.
Base class for all Fawkes BlackBoard interfaces.
void * value
Current value of this field.
unsigned int data_size
Size of memory needed to hold all data.
unsigned int mem_serial() const
Get memory serial of interface.
const interface_enum_map_t * enum_map
Map of possible enum values.
unsigned short serial() const
Get instance serial of interface.
interface_fieldtype_t type
type of this field
const char * name() const
Get name of thread.
size_t length
Length of field (array, string)
const char * enumtype
text representation of enum type
interface_fieldtype_t
Interface field type.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.