24#include <interfaces/KeyValueInterface.h>
26#include <core/exceptions/software.h>
44KeyValueInterface::KeyValueInterface() : Interface()
46 data_size =
sizeof(KeyValueInterface_data_t);
47 data_ptr = malloc(data_size);
48 data = (KeyValueInterface_data_t *)data_ptr;
49 data_ts = (interface_data_ts_t *)data_ptr;
50 memset(data_ptr, 0, data_size);
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";
57 add_fieldinfo(IFT_STRING,
"key", 32, data->key);
58 add_fieldinfo(IFT_ENUM,
"value_type", 1, &data->value_type,
"ValueType", &enum_map_ValueType);
59 add_fieldinfo(IFT_STRING,
"value_string", 32, data->value_string);
60 add_fieldinfo(IFT_UINT32,
"value_uint", 1, &data->value_uint);
61 add_fieldinfo(IFT_INT32,
"value_int", 1, &data->value_int);
62 add_fieldinfo(IFT_BOOL,
"value_bool", 1, &data->value_bool);
63 add_fieldinfo(IFT_BYTE,
"value_byte", 1, &data->value_byte);
64 add_fieldinfo(IFT_FLOAT,
"value_float", 1, &data->value_float);
65 unsigned char tmp_hash[] = {0xf1, 0x89, 0x81, 0x4f, 0xb9, 0x6e, 0x5c, 0xc8, 0x78, 0x90, 0x1a, 0x10, 0xdb, 0xa9, 0xa0, 0x52};
70KeyValueInterface::~KeyValueInterface()
79KeyValueInterface::tostring_ValueType(
ValueType value)
const
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";
97KeyValueInterface::key()
const
107KeyValueInterface::maxlenof_key()
const
117KeyValueInterface::set_key(
const char * new_key)
119 set_field(data->key, new_key);
127KeyValueInterface::value_type()
const
137KeyValueInterface::maxlenof_value_type()
const
147KeyValueInterface::set_value_type(
const ValueType new_value_type)
149 set_field(data->value_type, new_value_type);
157KeyValueInterface::value_string()
const
159 return data->value_string;
167KeyValueInterface::maxlenof_value_string()
const
177KeyValueInterface::set_value_string(
const char * new_value_string)
179 set_field(data->value_string, new_value_string);
187KeyValueInterface::value_uint()
const
189 return data->value_uint;
197KeyValueInterface::maxlenof_value_uint()
const
207KeyValueInterface::set_value_uint(
const uint32_t new_value_uint)
209 set_field(data->value_uint, new_value_uint);
217KeyValueInterface::value_int()
const
219 return data->value_int;
227KeyValueInterface::maxlenof_value_int()
const
237KeyValueInterface::set_value_int(
const int32_t new_value_int)
239 set_field(data->value_int, new_value_int);
247KeyValueInterface::is_value_bool()
const
249 return data->value_bool;
257KeyValueInterface::maxlenof_value_bool()
const
267KeyValueInterface::set_value_bool(
const bool new_value_bool)
269 set_field(data->value_bool, new_value_bool);
277KeyValueInterface::value_byte()
const
279 return data->value_byte;
287KeyValueInterface::maxlenof_value_byte()
const
297KeyValueInterface::set_value_byte(
const uint8_t new_value_byte)
299 set_field(data->value_byte, new_value_byte);
307KeyValueInterface::value_float()
const
309 return data->value_float;
317KeyValueInterface::maxlenof_value_float()
const
327KeyValueInterface::set_value_float(
const float new_value_float)
329 set_field(data->value_float, new_value_float);
334KeyValueInterface::create_message(
const char *type)
const
337 "message type for this interface type.", type);
350 type(), other->
type());
352 memcpy(data, oi->data,
sizeof(KeyValueInterface_data_t));
356KeyValueInterface::enum_tostring(
const char *enumtype,
int val)
const
358 if (strcmp(enumtype,
"ValueType") == 0) {
359 return tostring_ValueType((
ValueType)val);
370KeyValueInterface::message_valid(
const Message *message)
const
Base class for all Fawkes BlackBoard interfaces.
const char * type() const
Get type of interface.
KeyValueInterface Fawkes BlackBoard Interface.
ValueType
Indicator of current o.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Fawkes library namespace.