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 
31 namespace 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. */
49  } ValueType;
50  const char * tostring_ValueType(ValueType value) const;
51 
52  private:
53  /** Internal data storage, do NOT modify! */
54  typedef struct __attribute__((packed)) {
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:
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
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.
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.
Definition: message.h:44
ValueType
Indicator of current o.
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.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
void set_value_type(const ValueType new_value_type)
Set value_type value.
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.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
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.
The value to be transported is of type string.
size_t maxlenof_value_int() const
Get maximum length of value_int value.
char * value_string() const
Get value_string value.
The value to be transported is of type integer.
virtual Message * create_message(const char *type) const
Create message based on type name.
The value to be transported is of type float.
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.
The value to be transported is of type unsigned integer.
size_t maxlenof_value_bool() const
Get maximum length of value_bool value.
void set_value_string(const char *new_value_string)
Set value_string value.
The value to be transported is of type boolean.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:53
The value to be transported is of type byte.
void set_value_int(const int32_t new_value_int)
Set value_int value.