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  const char * get_name() const;
58  const void * get_value() const;
59  const char * get_value_string();
60  size_t get_length() const;
61  bool get_bool(unsigned int index = 0) const;
62  int8_t get_int8(unsigned int index = 0) const;
63  uint8_t get_uint8(unsigned int index = 0) const;
64  int16_t get_int16(unsigned int index = 0) const;
65  uint16_t get_uint16(unsigned int index = 0) const;
66  int32_t get_int32(unsigned int index = 0) const;
67  uint32_t get_uint32(unsigned int index = 0) const;
68  int64_t get_int64(unsigned int index = 0) const;
69  uint64_t get_uint64(unsigned int index = 0) const;
70  float get_float(unsigned int index = 0) const;
71  double get_double(unsigned int index = 0) const;
72  uint8_t get_byte(unsigned int index = 0) const;
73  int32_t get_enum(unsigned int index = 0) const;
74  bool * get_bools() const;
75  int8_t * get_int8s() const;
76  uint8_t * get_uint8s() const;
77  int16_t * get_int16s() const;
78  uint16_t * get_uint16s() const;
79  int32_t * get_int32s() const;
80  uint32_t * get_uint32s() const;
81  int64_t * get_int64s() const;
82  uint64_t * get_uint64s() const;
83  float * get_floats() const;
84  double * get_doubles() const;
85  uint8_t * get_bytes() const;
86  int32_t * get_enums() const;
87  const char * get_string() const;
88 
89  void set_bool(bool b, unsigned int index = 0);
90  void set_int8(int8_t i, unsigned int index = 0);
91  void set_uint8(uint8_t i, unsigned int index = 0);
92  void set_int16(int16_t i, unsigned int index = 0);
93  void set_uint16(uint16_t i, unsigned int index = 0);
94  void set_int32(int32_t i, unsigned int index = 0);
95  void set_uint32(uint32_t i, unsigned int index = 0);
96  void set_int64(int64_t i, unsigned int index = 0);
97  void set_uint64(uint64_t i, unsigned int index = 0);
98  void set_float(float f, unsigned int index = 0);
99  void set_double(double f, unsigned int index = 0);
100  void set_byte(uint8_t b, unsigned int index = 0);
101  void set_bools(bool *b);
102  void set_int8s(int8_t *i);
103  void set_uint8s(uint8_t *i);
104  void set_int16s(int16_t *i);
105  void set_uint16s(uint16_t *i);
106  void set_int32s(int32_t *i);
107  void set_uint32s(uint32_t *i);
108  void set_int64s(int64_t *i);
109  void set_uint64s(uint64_t *i);
110  void set_floats(float *f);
111  void set_doubles(double *f);
112  void set_bytes(uint8_t* b);
113  void set_string(const char* s);
114 
115  protected:
116  InterfaceFieldIterator(const Interface *interface,
117  const interface_fieldinfo_t *info_list);
118 
119  private:
120  const interface_fieldinfo_t *__infol;
121  char *__value_string;
122  const Interface *__interface;
123 };
124 
125 }
126 
127 #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.
const char * get_value_string()
Get value of current field as string.
const char * get_string() const
Get value of current field as string.
int32_t * get_int32s() const
Get value of current field as integer array.
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:43
float get_float(unsigned int index=0) const
Get value of current field as float.
void set_bytes(uint8_t *b)
Set value of current field as byte 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.
bool operator==(const InterfaceFieldIterator &fit) const
Check iterators for equality.
int32_t * get_enums() const
Get value of current enum field as integer array.
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:51
Fawkes library namespace.
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.
const void * operator*() const
Get FieldHeader.
interface_fieldtype_t get_type() const
Get type of current field.
uint64_t get_uint64(unsigned int index=0) const
Get value of current field as unsigned integer.
void set_int8(int8_t i, unsigned int index=0)
Set value of current field as integer.
uint8_t * get_uint8s() const
Get value of current field as unsigned integer array.
void set_uint8(uint8_t i, unsigned int index=0)
Set value of current field as unsigned integer.
uint8_t get_uint8(unsigned int index=0) const
Get value of current field as unsigned integer.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
bool operator!=(const InterfaceFieldIterator &fit) const
Check iterators for inequality.
void set_int32(int32_t i, unsigned int index=0)
Set value of current field as integer.
double * get_doubles() const
Get value of current field as double array.
int16_t * get_int16s() const
Get value of current field as integer array.
uint32_t * get_uint32s() const
Get value of current field as unsigned integer array.
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.
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.
uint64_t * get_uint64s() const
Get value of current field as unsigned integer array.
bool * get_bools() const
Get value of current field as bool array.
void set_byte(uint8_t b, unsigned int index=0)
Set value of current field as byte.
InterfaceFieldIterator & operator++()
Prefix increment.
uint8_t get_byte(unsigned int index=0) const
Get value of current field as byte.
float * get_floats() const
Get value of current field as float array.
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_string(const char *s)
Set value of current field as string.
void set_uint16s(uint16_t *i)
Set 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.
double get_double(unsigned int index=0) const
Get value of current field as double.
const char * get_name() const
Get name of current field.
size_t get_length() const
Get length of current field.
void set_int32s(int32_t *i)
Set value of current field as integer array.
const void * get_value() const
Get value of current field.
uint16_t * get_uint16s() const
Get value of current field as unsigned integer array.
void set_int8s(int8_t *i)
Set 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.
const char * get_typename() const
Get type of current field as string.
int16_t get_int16(unsigned int index=0) const
Get value of current field as integer.
void set_uint32s(uint32_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.
interface_fieldtype_t
Interface field type.
Definition: types.h:33
uint32_t get_uint32(unsigned int index=0) const
Get value of current field as unsigned integer.
int32_t get_int32(unsigned int index=0) const
Get value of current field as integer.
int64_t get_int64(unsigned int index=0) const
Get value of current field as integer.
int64_t * get_int64s() const
Get value of current field as integer array.
uint16_t get_uint16(unsigned int index=0) const
Get value of current field as unsigned integer.
uint8_t * get_bytes() const
Get value of current field as byte array.