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 <list>
32#include <stdint.h>
33
34namespace fawkes {
35class Interface;
36class Message;
37
39{
40 friend Interface;
41 friend Message;
42
43public:
48 InterfaceFieldIterator operator++(int inc); // postfix
49 InterfaceFieldIterator &operator+(unsigned int i);
50 InterfaceFieldIterator &operator+=(unsigned int i);
51 bool operator==(const InterfaceFieldIterator &fit) const;
52 bool operator!=(const InterfaceFieldIterator &fit) const;
53 const void * operator*() const;
55
57 const char * get_typename() const;
58 bool is_enum() const;
59 std::list<const char *> get_enum_valuenames() const;
60 const char * get_name() const;
61 const void * get_value() const;
62 const char * get_value_string(const char *array_sep = ", ");
63 size_t get_length() const;
64 bool get_bool(unsigned int index = 0) const;
65 int8_t get_int8(unsigned int index = 0) const;
66 uint8_t get_uint8(unsigned int index = 0) const;
67 int16_t get_int16(unsigned int index = 0) const;
68 uint16_t get_uint16(unsigned int index = 0) const;
69 int32_t get_int32(unsigned int index = 0) const;
70 uint32_t get_uint32(unsigned int index = 0) const;
71 int64_t get_int64(unsigned int index = 0) const;
72 uint64_t get_uint64(unsigned int index = 0) const;
73 float get_float(unsigned int index = 0) const;
74 double get_double(unsigned int index = 0) const;
75 uint8_t get_byte(unsigned int index = 0) const;
76 int32_t get_enum(unsigned int index = 0) const;
77 const char * get_enum_string(unsigned int index = 0) const;
78 bool * get_bools() const;
79 int8_t * get_int8s() const;
80 uint8_t * get_uint8s() const;
81 int16_t * get_int16s() const;
82 uint16_t * get_uint16s() const;
83 int32_t * get_int32s() const;
84 uint32_t * get_uint32s() const;
85 int64_t * get_int64s() const;
86 uint64_t * get_uint64s() const;
87 float * get_floats() const;
88 double * get_doubles() const;
89 uint8_t * get_bytes() const;
90 int32_t * get_enums() const;
91 const char * get_string() const;
92
93 void set_bool(bool b, unsigned int index = 0);
94 void set_int8(int8_t i, unsigned int index = 0);
95 void set_uint8(uint8_t i, unsigned int index = 0);
96 void set_int16(int16_t i, unsigned int index = 0);
97 void set_uint16(uint16_t i, unsigned int index = 0);
98 void set_int32(int32_t i, unsigned int index = 0);
99 void set_uint32(uint32_t i, unsigned int index = 0);
100 void set_int64(int64_t i, unsigned int index = 0);
101 void set_uint64(uint64_t i, unsigned int index = 0);
102 void set_float(float f, unsigned int index = 0);
103 void set_double(double f, unsigned int index = 0);
104 void set_byte(uint8_t b, unsigned int index = 0);
105 void set_enum(int32_t e, unsigned int index = 0);
106 void set_enum_string(const char *e, unsigned int index = 0);
107 void set_bools(bool *b);
108 void set_int8s(int8_t *i);
109 void set_uint8s(uint8_t *i);
110 void set_int16s(int16_t *i);
111 void set_uint16s(uint16_t *i);
112 void set_int32s(int32_t *i);
113 void set_uint32s(uint32_t *i);
114 void set_int64s(int64_t *i);
115 void set_uint64s(uint64_t *i);
116 void set_floats(float *f);
117 void set_doubles(double *f);
118 void set_bytes(uint8_t *b);
119 void set_string(const char *s);
120
121protected:
122 InterfaceFieldIterator(Interface *interface, const interface_fieldinfo_t *info_list);
123
124private:
125 const interface_fieldinfo_t *infol_;
126 char * value_string_;
127 Interface * interface_;
128};
129
130} // namespace fawkes
131
132#endif /* INTERFACE_FIELD_ITERATOR_H___ */
Interface field iterator.
const char * get_enum_string(unsigned int index=0) const
Get value of current enum field as string.
float get_float(unsigned int index=0) const
Get value of current field as float.
void set_uint32s(uint32_t *i)
Set value of current field as unsigned integer array.
int16_t get_int16(unsigned int index=0) const
Get value of current field as integer.
void set_int8s(int8_t *i)
Set value of current field as integer array.
void set_int64(int64_t i, unsigned int index=0)
Set value of current field as integer.
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 void * get_value() const
Get value of current field.
float * get_floats() const
Get value of current field as float array.
int32_t get_int32(unsigned int index=0) const
Get value of current field as integer.
void set_uint64s(uint64_t *i)
Set value of current field as unsigned integer array.
uint8_t * get_bytes() const
Get value of current field as byte array.
void set_doubles(double *f)
Set value of current field as double array.
void set_bools(bool *b)
Set value of current field as bool array.
InterfaceFieldIterator & operator=(const InterfaceFieldIterator &fit)
Make this instance point to the same segment as fi.
bool is_enum() const
Check if field is an enum.
void set_string(const char *s)
Set value of current field as string.
size_t get_length() const
Get length of current field.
int32_t * get_int32s() const
Get value of current field as integer array.
int64_t get_int64(unsigned int index=0) const
Get value of current field as integer.
void set_double(double f, unsigned int index=0)
Set value of current field as double.
void set_floats(float *f)
Set value of current field as float array.
std::list< const char * > get_enum_valuenames() const
Return the list of possible enum value names.
InterfaceFieldIterator & operator++()
Prefix increment.
uint64_t get_uint64(unsigned int index=0) const
Get value of current field as unsigned integer.
void set_int16(int16_t i, unsigned int index=0)
Set value of current field as integer.
int32_t get_enum(unsigned int index=0) const
Get value of current enum field as integer.
uint16_t get_uint16(unsigned int index=0) const
Get value of current field as unsigned integer.
double get_double(unsigned int index=0) const
Get value of current field as double.
int32_t * get_enums() const
Get value of current enum field as integer array.
void set_byte(uint8_t b, unsigned int index=0)
Set value of current field as byte.
int64_t * get_int64s() const
Get value of current field as integer array.
uint64_t * get_uint64s() const
Get value of current field as unsigned integer array.
const void * operator*() const
Get FieldHeader.
uint32_t get_uint32(unsigned int index=0) const
Get value of current field as unsigned integer.
void set_uint64(uint64_t i, unsigned int index=0)
Set value of current field as unsigned integer.
interface_fieldtype_t get_type() const
Get type of current field.
bool operator==(const InterfaceFieldIterator &fit) const
Check iterators for equality.
const char * get_name() const
Get name of current field.
uint8_t * get_uint8s() const
Get value of current field as unsigned integer array.
void set_int64s(int64_t *i)
Set value of current field as integer array.
void set_float(float f, unsigned int index=0)
Set value of current field as float.
void set_enum_string(const char *e, unsigned int index=0)
Set value of current field as enum (from an integer).
void set_int16s(int16_t *i)
Set value of current field as integer array.
bool operator!=(const InterfaceFieldIterator &fit) const
Check iterators for inequality.
void set_uint16(uint16_t i, unsigned int index=0)
Set value of current field as unsigned integer.
uint16_t * get_uint16s() const
Get value of current field as unsigned integer array.
void set_int32(int32_t i, unsigned int index=0)
Set value of current field as integer.
void set_uint8s(uint8_t *i)
Set value of current field as unsigned integer array.
const char * get_string() const
Get value of current field as string.
uint8_t get_byte(unsigned int index=0) const
Get value of current field as byte.
bool * get_bools() const
Get value of current field as bool array.
uint8_t get_uint8(unsigned int index=0) const
Get value of current field as unsigned integer.
bool get_bool(unsigned int index=0) const
Get value of current field as bool.
const char * get_value_string(const char *array_sep=", ")
Get value of current field as string.
void set_enum(int32_t e, unsigned int index=0)
Set value of current field as enum (from an integer).
void set_uint16s(uint16_t *i)
Set value of current field as unsigned integer array.
uint32_t * get_uint32s() const
Get value of current field as unsigned integer array.
double * get_doubles() const
Get value of current field as double array.
void set_bool(bool b, unsigned int index=0)
Set value of current field as bool.
void set_int8(int8_t i, unsigned int index=0)
Set value of current field as integer.
void set_uint8(uint8_t i, unsigned int index=0)
Set value of current field as unsigned integer.
void set_uint32(uint32_t i, unsigned int index=0)
Set value of current field as unsigned integer.
void set_int32s(int32_t *i)
Set value of current field as integer array.
InterfaceFieldIterator & operator+=(unsigned int i)
Advance by i steps.
int16_t * get_int16s() const
Get value of current field as integer array.
void set_bytes(uint8_t *b)
Set value of current field as byte array.
InterfaceFieldIterator & operator+(unsigned int i)
Advance by i steps.
const char * get_typename() const
Get type of current field as string.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
Fawkes library namespace.
interface_fieldtype_t
Interface field type.
Definition: types.h:36
Interface field info list.
Definition: types.h:58