24 #ifndef _INTERFACE_MESSAGE_H_
25 #define _INTERFACE_MESSAGE_H_
27 #include <core/exceptions/software.h>
28 #include <core/utils/refcount.h>
29 #include <interface/change_field.h>
30 #include <interface/field_iterator.h>
31 #include <interface/types.h>
32 #include <utils/uuid.h>
34 #define INTERFACE_MESSAGE_TYPE_SIZE_ 64
40 class InterfaceFieldIterator;
55 unsigned int id()
const;
56 void set_id(
unsigned int message_id);
67 const char *
type()
const;
77 unsigned int hops()
const;
89 template <
class MessageType>
97 template <
class MessageType>
101 unsigned int message_id_;
104 Time * time_enqueued_;
106 unsigned int recipient_interface_mem_serial;
107 unsigned int sender_interface_instance_serial;
110 char *_sender_thread_name;
118 unsigned int num_fields_;
121 void set_interface(
Interface *iface,
bool proxy =
false);
128 const char * enumtype = 0,
135 template <
class FieldT,
class DataT>
136 void set_field(FieldT &field, DataT &data);
143 template <
class FieldT,
class DataT>
144 void set_field(FieldT &field,
unsigned int index, DataT &data);
159 template <
class MessageType>
163 return (
dynamic_cast<MessageType *
>(
this) != 0);
166 template <
class MessageType>
170 MessageType *m =
dynamic_cast<MessageType *
>(
this);
178 template <
class FieldT,
class DataT>
185 template <
class FieldT,
class DataT>
Interface field iterator.
Base class for all Fawkes BlackBoard interfaces.
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.
void set_field(FieldT &field, DataT &data)
Set a field.
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.
MessageType * as_type()
Cast message to given type if possible.
bool is_of_type()
Check if message has desired type.
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.
Reference counting base class.
A class for handling 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.
bool change_field(FieldT &field, const DataT &value)
Set a field and return whether it changed.
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.