Fawkes API
Fawkes Development Version
|
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;
74 time_enqueued_ =
new Time();
76 _transmit_via_iface = NULL;
77 sender_interface_instance_serial = 0;
78 recipient_interface_mem_serial = 0;
81 if (sender_name !=
"") {
82 _sender_thread_name = strdup(sender_name.c_str());
84 _sender_thread_name = strdup(
"Unknown");
96 num_fields_ = mesg.num_fields_;
100 _sender_id = mesg.sender_id();
101 _sender_thread_name = strdup(mesg.sender_thread_name());
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_;
137 _sender_id = mesg->sender_id();
138 _sender_thread_name = strdup(mesg->sender_thread_name());
139 _type = strdup(mesg->_type);
140 _transmit_via_iface = NULL;
141 sender_interface_instance_serial = 0;
142 recipient_interface_mem_serial = 0;
143 time_enqueued_ =
new Time(mesg->time_enqueued_);
144 fieldinfo_list_ = NULL;
154 *info_dest = new_info;
156 info_dest = &((*info_dest)->next);
157 info_src = info_src->
next;
164 free(_sender_thread_name);
166 delete time_enqueued_;
170 fieldinfo_list_ = fieldinfo_list_->
next;
172 infol = fieldinfo_list_;
200 message_id_ = message_id;
216 time_enqueued_->
stamp();
217 long sec = 0, usec = 0;
244 return time_enqueued_;
253 return recipient_interface_mem_serial;
309 return _sender_thread_name;
328 _transmit_via_iface = iface;
329 _sender_id = iface->
serial();
330 recipient_interface_mem_serial = iface->
mem_serial();
339 return _transmit_via_iface;
404 const char * enumtype,
412 newinfo->
name = name;
414 newinfo->
value = value;
416 newinfo->
next = NULL;
420 fieldinfo_list_ = newinfo;
423 while (infol->
next != NULL) {
426 infol->
next = newinfo;
bool enqueued() const
Check is message has been enqueued.
void set_time(const timeval *tv)
Sets the time.
interface_fieldinfo_t * next
next field, NULL if last
const void * datachunk() const
Get pointer to data.
interface_fieldtype_t
Interface field type.
InterfaceFieldIterator fields_end()
Invalid iterator.
void set_id(unsigned int message_id)
Set message ID.
void mark_enqueued()
Mark message as being enqueued.
message_data_ts_t * data_ts
data timestamp aliasing pointer
const char * sender_thread_name() const
Get sender of message.
const Time * time_enqueued() const
Get time when message was enqueued.
Message(const char *type)
Constructor.
Interface * interface() const
Get transmitting interface.
unsigned int sender_id() const
Get ID of sender.
unsigned int mem_serial() const
Get memory serial of interface.
static std::string current_thread_name()
Get the name of the current thread.
Timestamp data, must be present and first entries for each interface data structs!...
InterfaceFieldIterator fields()
Get iterator over all fields of this interface instance.
const char * enumtype
text representation of enum type
Interface field info list.
const interface_enum_map_t * enum_map
Map of possible enum values.
void set_hops(unsigned int hops)
Set number of hops.
unsigned int datasize() const
Get size of data.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
const char * type() const
Get message type.
unsigned int num_fields() const
Get the number of fields in the message.
const char * name
Name of this field.
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.
virtual ~Message()
Destructor.
size_t length
Length of field (array, string)
Message & operator=(const Message &m)
Assign this message to given message.
unsigned short serial() const
Get instance serial of interface.
void set_from_chunk(const void *chunk)
Set from raw data chunk.
unsigned int hops() const
Get number of hops.
int64_t timestamp_usec
additional time microseconds
virtual Message * clone() const
Clone this message.
unsigned int id() const
Get message ID.
Time & stamp()
Set this time to the current time.
void get_timestamp(long &sec, long &usec) const
interface_fieldtype_t type
type of this field
unsigned int recipient() const
Get recipient memory serial.
int64_t timestamp_sec
time in seconds since Unix epoch
void * value
Current value of this field.