24 #include <core/exceptions/software.h>
25 #include <core/threading/mutex.h>
26 #include <core/threading/thread.h>
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <utils/time/time.h>
64 fieldinfo_list_ = NULL;
73 time_enqueued_ =
new Time();
75 _transmit_via_iface = NULL;
76 sender_interface_instance_serial = 0;
77 recipient_interface_mem_serial = 0;
80 if (sender_name !=
"") {
81 _sender_thread_name = strdup(sender_name.c_str());
83 _sender_thread_name = strdup(
"Unknown");
95 num_fields_ = mesg.num_fields_;
102 _type = strdup(mesg._type);
103 time_enqueued_ =
new Time(mesg.time_enqueued_);
104 fieldinfo_list_ = NULL;
106 _transmit_via_iface = NULL;
107 sender_interface_instance_serial = 0;
108 recipient_interface_mem_serial = 0;
118 *info_dest = new_info;
120 info_dest = &((*info_dest)->next);
121 info_src = info_src->
next;
133 num_fields_ = mesg->num_fields_;
140 _type = strdup(mesg->_type);
141 _transmit_via_iface = NULL;
142 sender_interface_instance_serial = 0;
143 recipient_interface_mem_serial = 0;
144 time_enqueued_ =
new Time(mesg->time_enqueued_);
145 fieldinfo_list_ = NULL;
155 *info_dest = new_info;
157 info_dest = &((*info_dest)->next);
158 info_src = info_src->
next;
165 free(_sender_thread_name);
167 delete time_enqueued_;
171 fieldinfo_list_ = fieldinfo_list_->
next;
173 infol = fieldinfo_list_;
201 message_id_ = message_id;
236 time_enqueued_->
stamp();
237 long sec = 0, usec = 0;
264 return time_enqueued_;
273 return recipient_interface_mem_serial;
329 return _sender_thread_name;
358 Message::set_interface(
Interface *iface,
bool proxy)
360 _transmit_via_iface = iface;
361 _sender_id = iface->
serial();
363 _source_id = iface->
serial();
365 recipient_interface_mem_serial = iface->
mem_serial();
374 return _transmit_via_iface;
439 const char * enumtype,
447 newinfo->
name = name;
449 newinfo->
value = value;
451 newinfo->
next = NULL;
455 fieldinfo_list_ = newinfo;
458 while (infol->
next != NULL) {
461 infol->
next = newinfo;
Interface field iterator.
Base class for all Fawkes BlackBoard interfaces.
unsigned int mem_serial() const
Get memory serial of interface.
Uuid serial() const
Get instance serial of interface.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
InterfaceFieldIterator fields()
Get iterator over all fields of this interface instance.
unsigned int recipient() const
Get recipient memory serial.
virtual ~Message()
Destructor.
const char * type() const
Get message type.
const void * datachunk() const
Get pointer to data.
void mark_enqueued()
Mark message as being enqueued.
unsigned int datasize() const
Get size of data.
Message(const char *type)
Constructor.
bool enqueued() const
Check is message has been enqueued.
Uuid source_id() const
Get ID of the original source of the message.
Interface * interface() const
Get transmitting interface.
void set_source_id(const Uuid &id)
Set source ID.
void set_from_chunk(const void *chunk)
Set from raw data chunk.
void set_id(unsigned int message_id)
Set message ID.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the info list.
void * data_ptr
Pointer to memory that contains local data.
message_data_ts_t * data_ts
data timestamp aliasing pointer
const Time * time_enqueued() const
Get time when message was enqueued.
unsigned int num_fields() const
Get the number of fields in the message.
Uuid sender_id() const
Get ID of the immediate sender, not necessarily the creator of the message.
void set_hops(unsigned int hops)
Set number of hops.
Message & operator=(const Message &m)
Assign this message to given message.
virtual Message * clone() const
Clone this message.
InterfaceFieldIterator fields_end()
Invalid iterator.
const char * sender_thread_name() const
Get sender of message.
unsigned int id() const
Get message ID.
unsigned int hops() const
Get number of hops.
void set_sender_id(const Uuid &id)
Set sender ID.
unsigned int data_size
Size of memory needed to hold all data.
static std::string current_thread_name()
Get the name of the current thread.
A class for handling time.
void get_timestamp(long &sec, long &usec) const
Get time stamp.
Time & stamp()
Set this time to the current time.
void set_time(const timeval *tv)
Sets the time.
A convenience class for universally unique identifiers (UUIDs).
Fawkes library namespace.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
interface_fieldtype_t
Interface field type.
Timestamp data, must be present and first entries for each interface data structs!...
int64_t timestamp_sec
time in seconds since Unix epoch
int64_t timestamp_usec
additional time microseconds
Interface field info list.
const char * enumtype
text representation of enum type
void * value
Current value of this field.
size_t length
Length of field (array, string)
const char * name
Name of this field.
interface_fieldtype_t type
type of this field
const interface_enum_map_t * enum_map
Map of possible enum values.
interface_fieldinfo_t * next
next field, NULL if last