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";
119 strncpy(data->key, new_key,
sizeof(data->key)-1);
120 data->key[
sizeof(data->key)-1] = 0;
151 data->value_type = new_value_type;
162 return data->value_string;
182 strncpy(data->value_string, new_value_string,
sizeof(data->value_string)-1);
183 data->value_string[
sizeof(data->value_string)-1] = 0;
194 return data->value_uint;
214 data->value_uint = new_value_uint;
225 return data->value_int;
245 data->value_int = new_value_int;
256 return data->value_bool;
276 data->value_bool = new_value_bool;
287 return data->value_byte;
307 data->value_byte = new_value_byte;
318 return data->value_float;
338 data->value_float = new_value_float;
347 "message type for this interface type.",
type);
362 memcpy(data, oi->data,
sizeof(KeyValueInterface_data_t));
368 if (strcmp(enumtype,
"ValueType") == 0) {
369 return tostring_ValueType((ValueType)val);
void set_value_byte(const uint8_t new_value_byte)
Set value_byte value.
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.
size_t maxlenof_value_type() const
Get maximum length of value_type value.
void set_value_type(const ValueType new_value_type)
Set value_type value.
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.
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.
ValueType value_type() const
Get value_type value.
char * value_string() const
Get value_string value.
void set_hash(unsigned char *ihash)
Set hash.
uint8_t value_byte() const
Get value_byte value.
bool is_value_bool() const
Get value_bool value.
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
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.
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.
virtual Message * create_message(const char *type) const