Fawkes API Fawkes Development Version
KeyValueInterface.h
1
2/***************************************************************************
3 * KeyValueInterface.h - Fawkes BlackBoard Interface - KeyValueInterface
4 *
5 * Templated created: Thu Oct 12 10:49:19 2006
6 * Copyright 2015 Gesche Gierse
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _INTERFACES_KEYVALUEINTERFACE_H_
25#define _INTERFACES_KEYVALUEINTERFACE_H_
26
27#include <interface/interface.h>
28#include <interface/message.h>
29#include <interface/field_iterator.h>
30
31namespace fawkes {
32
34{
35 /// @cond INTERNALS
36 INTERFACE_MGMT_FRIENDS(KeyValueInterface)
37 /// @endcond
38 public:
39 /* constants */
40
41 /** Indicator of current o. */
42 typedef enum {
43 TypeStr /**< The value to be transported is of type string. */,
44 TypeInt /**< The value to be transported is of type integer. */,
45 TypeUint /**< The value to be transported is of type unsigned integer. */,
46 TypeBool /**< The value to be transported is of type boolean. */,
47 TypeByte /**< The value to be transported is of type byte. */,
48 TypeFloat /**< The value to be transported is of type float. */
50 const char * tostring_ValueType(ValueType value) const;
51
52 private:
53 /** Internal data storage, do NOT modify! */
54 typedef struct {
55 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
56 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
57 char key[32]; /**< The key entry */
58 int32_t value_type; /**< The type of the value entry. */
59 char value_string[32]; /**< Value with type string */
60 uint32_t value_uint; /**< Value with type uint32 */
61 int32_t value_int; /**< Value with type integer */
62 bool value_bool; /**< Value with type Bool */
63 uint8_t value_byte; /**< Value with type byte */
64 float value_float; /**< Value with type float */
65 } KeyValueInterface_data_t;
66
67 KeyValueInterface_data_t *data;
68
69 interface_enum_map_t enum_map_ValueType;
70 public:
71 /* messages */
72 virtual bool message_valid(const Message *message) const;
73 private:
74 KeyValueInterface();
75 ~KeyValueInterface();
76
77 public:
78 /* Methods */
79 char * key() const;
80 void set_key(const char * new_key);
81 size_t maxlenof_key() const;
82 ValueType value_type() const;
83 void set_value_type(const ValueType new_value_type);
84 size_t maxlenof_value_type() const;
85 char * value_string() const;
86 void set_value_string(const char * new_value_string);
87 size_t maxlenof_value_string() const;
88 uint32_t value_uint() const;
89 void set_value_uint(const uint32_t new_value_uint);
90 size_t maxlenof_value_uint() const;
91 int32_t value_int() const;
92 void set_value_int(const int32_t new_value_int);
93 size_t maxlenof_value_int() const;
94 bool is_value_bool() const;
95 void set_value_bool(const bool new_value_bool);
96 size_t maxlenof_value_bool() const;
97 uint8_t value_byte() const;
98 void set_value_byte(const uint8_t new_value_byte);
99 size_t maxlenof_value_byte() const;
100 float value_float() const;
101 void set_value_float(const float new_value_float);
102 size_t maxlenof_value_float() const;
103 virtual Message * create_message(const char *type) const;
104
105 virtual void copy_values(const Interface *other);
106 virtual const char * enum_tostring(const char *enumtype, int val) const;
107
108};
109
110} // end namespace fawkes
111
112#endif
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
const char * type() const
Get type of interface.
Definition: interface.cpp:652
Interface()
Constructor.
Definition: interface.cpp:239
KeyValueInterface Fawkes BlackBoard Interface.
int32_t value_int() const
Get value_int value.
void set_value_byte(const uint8_t new_value_byte)
Set value_byte value.
uint32_t value_uint() const
Get value_uint 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.
void set_value_uint(const uint32_t new_value_uint)
Set value_uint value.
const char * tostring_ValueType(ValueType value) const
Convert ValueType constant to string.
size_t maxlenof_value_string() const
Get maximum length of value_string value.
size_t maxlenof_value_byte() const
Get maximum length of value_byte value.
size_t maxlenof_value_bool() const
Get maximum length of value_bool value.
uint8_t value_byte() const
Get value_byte value.
void set_value_bool(const bool new_value_bool)
Set value_bool value.
void set_value_int(const int32_t new_value_int)
Set value_int value.
size_t maxlenof_value_type() const
Get maximum length of value_type value.
char * value_string() const
Get value_string value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
char * key() const
Get key value.
void set_key(const char *new_key)
Set key value.
ValueType
Indicator of current o.
@ TypeInt
The value to be transported is of type integer.
@ TypeByte
The value to be transported is of type byte.
@ TypeUint
The value to be transported is of type unsigned integer.
@ TypeBool
The value to be transported is of type boolean.
@ TypeStr
The value to be transported is of type string.
@ TypeFloat
The value to be transported is of type float.
float value_float() const
Get value_float value.
size_t maxlenof_value_uint() const
Get maximum length of value_uint value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
void set_value_type(const ValueType new_value_type)
Set value_type value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
virtual Message * create_message(const char *type) const
Create message based on type name.
void set_value_string(const char *new_value_string)
Set value_string value.
bool is_value_bool() const
Get value_bool value.
size_t maxlenof_key() const
Get maximum length of key value.
void set_value_float(const float new_value_float)
Set value_float value.
ValueType value_type() const
Get value_type value.
Fawkes library namespace.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:54