Fawkes API
Fawkes Development Version
|
24 #include <interfaces/KeyValueInterface.h>
26 #include <core/exceptions/software.h>
44 KeyValueInterface::KeyValueInterface() : Interface()
46 data_size =
sizeof(KeyValueInterface_data_t);
48 data = (KeyValueInterface_data_t *)
data_ptr;
51 enum_map_ValueType[(int)TypeStr] =
"TypeStr";
52 enum_map_ValueType[(int)TypeInt] =
"TypeInt";
53 enum_map_ValueType[(int)TypeUint] =
"TypeUint";
54 enum_map_ValueType[(int)TypeBool] =
"TypeBool";
55 enum_map_ValueType[(int)TypeByte] =
"TypeByte";
56 enum_map_ValueType[(int)TypeFloat] =
"TypeFloat";
65 unsigned char tmp_hash[] = {0xf1, 0x89, 0x81, 0x4f, 0xb9, 0x6e, 0x5c, 0xc8, 0x78, 0x90, 0x1a, 0x10, 0xdb, 0xa9, 0xa0, 0x52};
70 KeyValueInterface::~KeyValueInterface()
82 case TypeStr:
return "TypeStr";
83 case TypeInt:
return "TypeInt";
84 case TypeUint:
return "TypeUint";
85 case TypeBool:
return "TypeBool";
86 case TypeByte:
return "TypeByte";
87 case TypeFloat:
return "TypeFloat";
88 default:
return "UNKNOWN";
159 return data->value_string;
189 return data->value_uint;
219 return data->value_int;
249 return data->value_bool;
279 return data->value_byte;
309 return data->value_float;
337 "message type for this interface type.",
type);
352 memcpy(data, oi->data,
sizeof(KeyValueInterface_data_t));
358 if (strcmp(enumtype,
"ValueType") == 0) {
359 return tostring_ValueType((
ValueType)val);
void set_value_byte(const uint8_t new_value_byte)
Set value_byte value.
void * data_ptr
Pointer to local memory storage.
size_t maxlenof_key() const
Get maximum length of key value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
void set_value_uint(const uint32_t new_value_uint)
Set value_uint value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
size_t maxlenof_value_type() const
Get maximum length of value_type value.
void * data_ptr
Pointer to memory that contains local data.
void set_value_type(const ValueType new_value_type)
Set value_type value.
@ IFT_ENUM
field with interface specific enum type
message_data_ts_t * data_ts
data timestamp aliasing pointer
size_t maxlenof_value_float() const
Get maximum length of value_float value.
int32_t value_int() const
Get value_int value.
@ IFT_UINT32
32 bit unsigned integer field
void set_value_float(const float new_value_float)
Set value_float value.
uint32_t value_uint() const
Get value_uint value.
const char * type() const
Get type of interface.
void set_value_bool(const bool new_value_bool)
Set value_bool value.
size_t maxlenof_value_bool() const
Get maximum length of value_bool value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
KeyValueInterface Fawkes BlackBoard Interface.
bool data_changed
Indicator if data has changed.
ValueType value_type() const
Get value_type value.
@ IFT_INT32
32 bit integer field
char * value_string() const
Get value_string value.
Fawkes library namespace.
void set_hash(unsigned char *ihash)
Set hash.
uint8_t value_byte() const
Get value_byte value.
unsigned int data_size
Size of memory needed to hold all data.
bool is_value_bool() const
Get value_bool value.
Base class for all Fawkes BlackBoard interfaces.
void set_key(const char *new_key)
Set key value.
ValueType
Indicator of current o.
size_t maxlenof_value_string() const
Get maximum length of value_string value.
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.
size_t maxlenof_value_byte() const
Get maximum length of value_byte value.
const char * tostring_ValueType(ValueType value) const
Convert ValueType constant to string.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
void set_value_string(const char *new_value_string)
Set value_string value.
float value_float() const
Get value_float value.
char * key() const
Get key value.
@ IFT_BYTE
byte field, alias for uint8
void set_value_int(const int32_t new_value_int)
Set value_int value.
size_t maxlenof_value_uint() const
Get maximum length of value_uint value.
size_t maxlenof_value_int() const
Get maximum length of value_int value.
bool change_field(FieldT &field, const DataT &value)
Set a field and return whether it changed.
virtual Message * create_message(const char *type) const
Create message based on type name.