Fawkes API  Fawkes Development Version
field_iterator.h
1 
2 /***************************************************************************
3  * field_iterator.h - Iterate over field of an interface or a message
4  *
5  * Created: Fri Jul 16 17:12:30 2009
6  * Copyright 2006 Tim Niemueller [www.niemueller.de]
7  * 2009 Daniel Beck
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #ifndef __INTERFACE_FIELD_ITERATOR_H__
26 #define __INTERFACE_FIELD_ITERATOR_H__
27 
28 #include <interface/types.h>
29 
30 #define __STD_LIMIT_MACROS
31 #include <stdint.h>
32 
33 namespace fawkes {
34 class Interface;
35 class Message;
36 
38 {
39  friend class Interface;
40  friend class Message;
41 
42  public:
46  InterfaceFieldIterator & operator++ (); // prefix
47  InterfaceFieldIterator operator++ (int inc); // postfix
48  InterfaceFieldIterator & operator+ (unsigned int i);
49  InterfaceFieldIterator & operator+= (unsigned int i);
50  bool operator== (const InterfaceFieldIterator & fit) const;
51  bool operator!= (const InterfaceFieldIterator & fit) const;
52  const void * operator* () const;
54 
56  const char * get_typename() const;
57  bool is_enum() const;
58  const char * get_name() const;
59  const void * get_value() const;
60  const char * get_value_string(const char *array_sep = ", ");
61  size_t get_length() const;
62  bool get_bool(unsigned int index = 0) const;
63  int8_t get_int8(unsigned int index = 0) const;
64  uint8_t get_uint8(unsigned int index = 0) const;
65  int16_t get_int16(unsigned int index = 0) const;
66  uint16_t get_uint16(unsigned int index = 0) const;
67  int32_t get_int32(unsigned int index = 0) const;
68  uint32_t get_uint32(unsigned int index = 0) const;
69  int64_t get_int64(unsigned int index = 0) const;
70  uint64_t get_uint64(unsigned int index = 0) const;
71  float get_float(unsigned int index = 0) const;
72  double get_double(unsigned int index = 0) const;
73  uint8_t get_byte(unsigned int index = 0) const;
74  int32_t get_enum(unsigned int index = 0) const;
75  const char * get_enum_string(unsigned int index = 0) const;
76  bool * get_bools() const;
77  int8_t * get_int8s() const;
78  uint8_t * get_uint8s() const;
79  int16_t * get_int16s() const;
80  uint16_t * get_uint16s() const;
81  int32_t * get_int32s() const;
82  uint32_t * get_uint32s() const;
83  int64_t * get_int64s() const;
84  uint64_t * get_uint64s() const;
85  float * get_floats() const;
86  double * get_doubles() const;
87  uint8_t * get_bytes() const;
88  int32_t * get_enums() const;
89  const char * get_string() const;
90 
91  void set_bool(bool b, unsigned int index = 0);
92  void set_int8(int8_t i, unsigned int index = 0);
93  void set_uint8(uint8_t i, unsigned int index = 0);
94  void set_int16(int16_t i, unsigned int index = 0);
95  void set_uint16(uint16_t i, unsigned int index = 0);
96  void set_int32(int32_t i, unsigned int index = 0);
97  void set_uint32(uint32_t i, unsigned int index = 0);
98  void set_int64(int64_t i, unsigned int index = 0);
99  void set_uint64(uint64_t i, unsigned int index = 0);
100  void set_float(float f, unsigned int index = 0);
101  void set_double(double f, unsigned int index = 0);
102  void set_byte(uint8_t b, unsigned int index = 0);
103  void set_enum(int32_t e, unsigned int index = 0);
104  void set_enum_string(const char* e, unsigned int index = 0);
105  void set_bools(bool *b);
106  void set_int8s(int8_t *i);
107  void set_uint8s(uint8_t *i);
108  void set_int16s(int16_t *i);
109  void set_uint16s(uint16_t *i);
110  void set_int32s(int32_t *i);
111  void set_uint32s(uint32_t *i);
112  void set_int64s(int64_t *i);
113  void set_uint64s(uint64_t *i);
114  void set_floats(float *f);
115  void set_doubles(double *f);
116  void set_bytes(uint8_t* b);
117  void set_string(const char* s);
118 
119  protected:
121  const interface_fieldinfo_t *info_list);
122 
123  private:
124  const interface_fieldinfo_t *__infol;
125  char *__value_string;
126  Interface *__interface;
127 };
128 
129 }
130 
131 #endif /* __INTERFACE_FIELD_ITERATOR_H__ */
Interface field iterator.
void set_int64(int64_t i, unsigned int index=0)
Set value of current field as integer.
void set_int64s(int64_t *i)
Set value of current field as integer array.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
uint8_t * get_bytes() const
Get value of current field as byte array.
uint16_t get_uint16(unsigned int index=0) const
Get value of current field as unsigned integer.
void set_bytes(uint8_t *b)
Set value of current field as byte array.
int32_t * get_enums() const
Get value of current enum field as integer array.
void set_float(float f, unsigned int index=0)
Set value of current field as float.
void set_uint64s(uint64_t *i)
Set value of current field as unsigned integer array.
int32_t get_enum(unsigned int index=0) const
Get value of current enum field as integer.
const char * get_typename() const
Get type of current field as string.
double get_double(unsigned int index=0) const
Get value of current field as double.
void set_bool(bool b, unsigned int index=0)
Set value of current field as bool.
void set_bools(bool *b)
Set value of current field as bool array.
void set_int16(int16_t i, unsigned int index=0)
Set value of current field as integer.
InterfaceFieldIterator & operator=(const InterfaceFieldIterator &fit)
Make this instance point to the same segment as fi.
Interface field info list.
Definition: types.h:56
uint16_t * get_uint16s() const
Get value of current field as unsigned integer array.
Fawkes library namespace.
bool get_bool(unsigned int index=0) const
Get value of current field as bool.
InterfaceFieldIterator & operator+(unsigned int i)
Advance by i steps.
void set_uint16(uint16_t i, unsigned int index=0)
Set value of current field as unsigned integer.
float * get_floats() const
Get value of current field as float array.
void set_int8(int8_t i, unsigned int index=0)
Set value of current field as integer.
interface_fieldtype_t get_type() const
Get type of current field.
void set_uint8(uint8_t i, unsigned int index=0)
Set value of current field as unsigned integer.
const char * get_value_string(const char *array_sep=", ")
Get value of current field as string.
float get_float(unsigned int index=0) const
Get value of current field as float.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
uint8_t get_byte(unsigned int index=0) const
Get value of current field as byte.
void set_int32(int32_t i, unsigned int index=0)
Set value of current field as integer.
int16_t get_int16(unsigned int index=0) const
Get value of current field as integer.
bool operator==(const InterfaceFieldIterator &fit) const
Check iterators for equality.
void set_doubles(double *f)
Set value of current field as double array.
void set_double(double f, unsigned int index=0)
Set value of current field as double.
int64_t * get_int64s() const
Get value of current field as integer array.
uint8_t * get_uint8s() const
Get value of current field as unsigned integer array.
int8_t get_int8(unsigned int index=0) const
Get value of current field as integer.
int8_t * get_int8s() const
Get value of current field as integer array.
const char * get_name() const
Get name of current field.
void set_byte(uint8_t b, unsigned int index=0)
Set value of current field as byte.
const void * operator*() const
Get FieldHeader.
InterfaceFieldIterator & operator++()
Prefix increment.
uint8_t get_uint8(unsigned int index=0) const
Get value of current field as unsigned integer.
double * get_doubles() const
Get value of current field as double array.
InterfaceFieldIterator & operator+=(unsigned int i)
Advance by i steps.
void set_string(const char *s)
Set value of current field as string.
uint64_t get_uint64(unsigned int index=0) const
Get value of current field as unsigned integer.
void set_uint16s(uint16_t *i)
Set value of current field as unsigned integer array.
const char * get_enum_string(unsigned int index=0) const
Get value of current enum field as string.
const char * get_string() const
Get value of current field as string.
uint64_t * get_uint64s() const
Get value of current field as unsigned integer array.
void set_uint32(uint32_t i, unsigned int index=0)
Set value of current field as unsigned integer.
uint32_t get_uint32(unsigned int index=0) const
Get value of current field as unsigned integer.
bool * get_bools() const
Get value of current field as bool array.
size_t get_length() const
Get length of current field.
bool is_enum() const
Check if field is an enum.
void set_enum(int32_t e, unsigned int index=0)
Set value of current field as enum (from an integer).
uint32_t * get_uint32s() const
Get value of current field as unsigned integer array.
void set_int32s(int32_t *i)
Set value of current field as integer array.
void set_int8s(int8_t *i)
Set value of current field as integer array.
void set_enum_string(const char *e, unsigned int index=0)
Set value of current field as enum (from an integer).
int32_t * get_int32s() const
Get value of current field as integer array.
void set_floats(float *f)
Set value of current field as float array.
void set_uint8s(uint8_t *i)
Set value of current field as unsigned integer array.
void set_int16s(int16_t *i)
Set value of current field as integer array.
void set_uint64(uint64_t i, unsigned int index=0)
Set value of current field as unsigned integer.
bool operator!=(const InterfaceFieldIterator &fit) const
Check iterators for inequality.
void set_uint32s(uint32_t *i)
Set value of current field as unsigned integer array.
int32_t get_int32(unsigned int index=0) const
Get value of current field as integer.
int16_t * get_int16s() const
Get value of current field as integer array.
interface_fieldtype_t
Interface field type.
Definition: types.h:35
const void * get_value() const
Get value of current field.
int64_t get_int64(unsigned int index=0) const
Get value of current field as integer.