Fawkes API  Fawkes Development Version
field_pointer.h
1 
2 /***************************************************************************
3  * field_pointer.h - BlackBoard Interface Field Pointer
4  *
5  * Created: Mon Oct 09 18:34:11 2006
6  * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
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 __INTERFACE_FIELD_POINTER_H_
25 #define __INTERFACE_FIELD_POINTER_H_
26 
27 #include <interface/interface.h>
28 
29 namespace fawkes {
30 
31 /** Direct pointer to an interface field.
32  * This class allows for keeping a pointer to an interface value which is
33  * valid for the whole lifetime of the interface.
34  * @author Tim Niemueller
35  */
36 template <typename FieldType>
38 {
39  public:
40  /** Constructor.
41  * @param type value type of the field
42  * @param name name of the field
43  * @param value pointer to the value of the field
44  */
45  InterfaceFieldPointer(Interface::interface_fieldtype_t type,
46  const char *name,
47  FieldType *value)
48  {
49  __type = type;
50  __name = name;
51  __value = value;
52  }
53 
54  /** Get the type of the field.
55  * @return type of the field
56  */
57  Interface::interface_fieldtype_t get_type() const
58  {
59  return __type;
60  }
61 
62  /** Get name of the field.
63  * @return name of the field.
64  */
65  const char * get_name() const
66  {
67  return __name;
68  }
69 
70  /** Get current value of the field.
71  * @return current vlaue of the field.
72  */
73  FieldType get_value() const
74  {
75  return *__value;
76  }
77 
78  /** Set value of the field.
79  * @param value new value to set for the field.
80  */
81  void set_value(FieldType value)
82  {
83  *__value = value;
84  }
85 
86  private:
87  Interface::interface_fieldtype_t __type;
88  const char *__name;
89  volatile FieldType *__value;
90 };
91 
92 } // end namespace fawkes
93 
94 #endif
InterfaceFieldPointer(Interface::interface_fieldtype_t type, const char *name, FieldType *value)
Constructor.
Definition: field_pointer.h:45
FieldType get_value() const
Get current value of the field.
Definition: field_pointer.h:73
Fawkes library namespace.
void set_value(FieldType value)
Set value of the field.
Definition: field_pointer.h:81
const char * get_name() const
Get name of the field.
Definition: field_pointer.h:65
Interface::interface_fieldtype_t get_type() const
Get the type of the field.
Definition: field_pointer.h:57
Direct pointer to an interface field.
Definition: field_pointer.h:37