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";
119 strncpy(data->key, new_key,
sizeof(data->key));
150 data->value_type = new_value_type;
161 return data->value_string;
181 strncpy(data->value_string, new_value_string,
sizeof(data->value_string));
192 return data->value_uint;
212 data->value_uint = new_value_uint;
223 return data->value_int;
243 data->value_int = new_value_int;
254 return data->value_bool;
274 data->value_bool = new_value_bool;
285 return data->value_byte;
305 data->value_byte = new_value_byte;
316 return data->value_float;
336 data->value_float = new_value_float;
345 "message type for this interface type.", type);
360 memcpy(data, oi->data,
sizeof(KeyValueInterface_data_t));
366 if (strcmp(enumtype,
"ValueType") == 0) {
367 return tostring_ValueType((
ValueType)val);
uint32_t value_uint() const
Get value_uint value.
size_t maxlenof_value_string() const
Get maximum length of value_string value.
void set_value_bool(const bool new_value_bool)
Set value_bool value.
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.
void * data_ptr
Pointer to memory that contains local data.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
ValueType
Indicator of current o.
void set_hash(unsigned char *ihash)
Set hash.
size_t maxlenof_key() const
Get maximum length of key value.
void set_value_float(const float new_value_float)
Set value_float value.
int32_t value_int() const
Get value_int value.
Fawkes library namespace.
KeyValueInterface Fawkes BlackBoard Interface.
uint8_t value_byte() const
Get value_byte value.
size_t maxlenof_value_type() const
Get maximum length of value_type value.
byte field, alias for uint8
Base class for all Fawkes BlackBoard interfaces.
void set_value_type(const ValueType new_value_type)
Set value_type value.
message_data_ts_t * data_ts
data timestamp aliasing pointer
unsigned int data_size
Size of memory needed to hold all data.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
void set_value_uint(const uint32_t new_value_uint)
Set value_uint value.
bool data_changed
Indicator if data has changed.
const char * type() const
Get type of interface.
bool is_value_bool() const
Get value_bool value.
void set_key(const char *new_key)
Set key value.
void set_value_byte(const uint8_t new_value_byte)
Set value_byte value.
char * key() const
Get key value.
size_t maxlenof_value_float() const
Get maximum length of value_float value.
size_t maxlenof_value_int() const
Get maximum length of value_int value.
char * value_string() const
Get value_string value.
virtual Message * create_message(const char *type) const
Create message based on type name.
float value_float() const
Get value_float value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
ValueType value_type() const
Get value_type value.
size_t maxlenof_value_uint() const
Get maximum length of value_uint value.
size_t maxlenof_value_bool() const
Get maximum length of value_bool 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.
void set_value_string(const char *new_value_string)
Set value_string value.
const char * type() const
Get message type.
32 bit unsigned integer field
field with interface specific enum type
void set_value_int(const int32_t new_value_int)
Set value_int value.