Fawkes API Fawkes Development Version
GameStateInterface.h
1
2/***************************************************************************
3 * GameStateInterface.h - Fawkes BlackBoard Interface - GameStateInterface
4 *
5 * Templated created: Thu Oct 12 10:49:19 2006
6 * Copyright 2008 Tim Niemueller
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_GAMESTATEINTERFACE_H_
25#define _INTERFACES_GAMESTATEINTERFACE_H_
26
27#include <interface/interface.h>
28#include <interface/message.h>
29#include <interface/field_iterator.h>
30
31namespace fawkes {
32
34{
35 /// @cond INTERNALS
36 INTERFACE_MGMT_FRIENDS(GameStateInterface)
37 /// @endcond
38 public:
39 /* constants */
40 static const uint32_t GS_FROZEN;
41 static const uint32_t GS_PLAY;
42 static const uint32_t GS_KICK_OFF;
43 static const uint32_t GS_DROP_BALL;
44 static const uint32_t GS_PENALTY;
45 static const uint32_t GS_CORNER_KICK;
46 static const uint32_t GS_THROW_IN;
47 static const uint32_t GS_FREE_KICK;
48 static const uint32_t GS_GOAL_KICK;
49 static const uint32_t GS_HALF_TIME;
50 static const uint32_t GS_SPL_INITIAL;
51 static const uint32_t GS_SPL_READY;
52 static const uint32_t GS_SPL_SET;
53 static const uint32_t GS_SPL_PLAY;
54 static const uint32_t GS_SPL_FINISHED;
55
56 /**
57 Enumeration defining the different teams. Keep in sync with
58 worldinfo_gamestate_team_t.
59 */
60 typedef enum {
61 TEAM_NONE /**< No team, not team-specific */,
62 TEAM_CYAN /**< Cyan team */,
63 TEAM_MAGENTA /**< Magenta team */,
64 TEAM_BOTH /**< Both teams */
66 const char * tostring_if_gamestate_team_t(if_gamestate_team_t value) const;
67
68 /**
69 Enumeration defining the different teams. Keep in sync with
70 worldinfo_gamestate_goalcolor_t.
71 */
72 typedef enum {
73 GOAL_BLUE /**< Blue goal */,
74 GOAL_YELLOW /**< Yellow goal */
77
78 /**
79 Enumeration defining the different teams. Keep in sync with
80 worldinfo_gamestate_half_t.
81 */
82 typedef enum {
83 HALF_FIRST /**< First half */,
84 HALF_SECOND /**< Second half */
86 const char * tostring_if_gamestate_half_t(if_gamestate_half_t value) const;
87
88 /**
89 Enumeration defining the different robot roles. Keep in sync with
90 worldinfo_gamestate_role_t.
91 */
92 typedef enum {
93 ROLE_GOALIE /**< Goalie */,
94 ROLE_DEFENDER /**< Defender */,
95 ROLE_MID_LEFT /**< Midfield left */,
96 ROLE_MID_RIGHT /**< Midfield right */,
97 ROLE_ATTACKER /**< Attacker */
99 const char * tostring_if_gamestate_role_t(if_gamestate_role_t value) const;
100
101 private:
102 /** Internal data storage, do NOT modify! */
103 typedef struct {
104 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
105 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
106 uint32_t game_state; /**< Current game state */
107 int32_t state_team; /**< Team referred to by game state */
108 int32_t our_team; /**< Our team color */
109 int32_t our_goal_color; /**< Our own goal color */
110 int32_t half; /**< Current game half */
111 bool kickoff; /**< Whether we have kickoff */
112 int32_t role; /**< Current role of this robot */
113 uint32_t score_cyan; /**< Score of team cyan */
114 uint32_t score_magenta; /**< Score of team magenta */
115 } GameStateInterface_data_t;
116
117 GameStateInterface_data_t *data;
118
119 interface_enum_map_t enum_map_if_gamestate_team_t;
120 interface_enum_map_t enum_map_if_gamestate_goalcolor_t;
121 interface_enum_map_t enum_map_if_gamestate_half_t;
122 interface_enum_map_t enum_map_if_gamestate_role_t;
123 public:
124 /* messages */
126 {
127 private:
128 /** Internal data storage, do NOT modify! */
129 typedef struct {
130 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
131 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
132 int32_t our_team; /**< Our team color */
133 } SetTeamColorMessage_data_t;
134
135 SetTeamColorMessage_data_t *data;
136
137 interface_enum_map_t enum_map_if_gamestate_team_t;
138 interface_enum_map_t enum_map_if_gamestate_goalcolor_t;
139 interface_enum_map_t enum_map_if_gamestate_half_t;
140 interface_enum_map_t enum_map_if_gamestate_role_t;
141 public:
142 SetTeamColorMessage(const if_gamestate_team_t ini_our_team);
145
146 explicit SetTeamColorMessage(const SetTeamColorMessage *m);
147 /* Methods */
149 void set_our_team(const if_gamestate_team_t new_our_team);
150 size_t maxlenof_our_team() const;
151 virtual Message * clone() const;
152 };
153
155 {
156 private:
157 /** Internal data storage, do NOT modify! */
158 typedef struct {
159 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
160 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
161 bool kickoff; /**< Whether we have kickoff */
162 } SetKickoffMessage_data_t;
163
164 SetKickoffMessage_data_t *data;
165
166 interface_enum_map_t enum_map_if_gamestate_team_t;
167 interface_enum_map_t enum_map_if_gamestate_goalcolor_t;
168 interface_enum_map_t enum_map_if_gamestate_half_t;
169 interface_enum_map_t enum_map_if_gamestate_role_t;
170 public:
171 SetKickoffMessage(const bool ini_kickoff);
174
175 explicit SetKickoffMessage(const SetKickoffMessage *m);
176 /* Methods */
177 bool is_kickoff() const;
178 void set_kickoff(const bool new_kickoff);
179 size_t maxlenof_kickoff() const;
180 virtual Message * clone() const;
181 };
182
184 {
185 private:
186 /** Internal data storage, do NOT modify! */
187 typedef struct {
188 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
189 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
190 int32_t state_team; /**< Team referred to by game state */
191 } SetStateTeamMessage_data_t;
192
193 SetStateTeamMessage_data_t *data;
194
195 interface_enum_map_t enum_map_if_gamestate_team_t;
196 interface_enum_map_t enum_map_if_gamestate_goalcolor_t;
197 interface_enum_map_t enum_map_if_gamestate_half_t;
198 interface_enum_map_t enum_map_if_gamestate_role_t;
199 public:
200 SetStateTeamMessage(const if_gamestate_team_t ini_state_team);
203
204 explicit SetStateTeamMessage(const SetStateTeamMessage *m);
205 /* Methods */
207 void set_state_team(const if_gamestate_team_t new_state_team);
208 size_t maxlenof_state_team() const;
209 virtual Message * clone() const;
210 };
211
212 virtual bool message_valid(const Message *message) const;
213 private:
216
217 public:
218 /* Methods */
219 uint32_t game_state() const;
220 void set_game_state(const uint32_t new_game_state);
221 size_t maxlenof_game_state() const;
223 void set_state_team(const if_gamestate_team_t new_state_team);
224 size_t maxlenof_state_team() const;
226 void set_our_team(const if_gamestate_team_t new_our_team);
227 size_t maxlenof_our_team() const;
229 void set_our_goal_color(const if_gamestate_goalcolor_t new_our_goal_color);
230 size_t maxlenof_our_goal_color() const;
232 void set_half(const if_gamestate_half_t new_half);
233 size_t maxlenof_half() const;
234 bool is_kickoff() const;
235 void set_kickoff(const bool new_kickoff);
236 size_t maxlenof_kickoff() const;
238 void set_role(const if_gamestate_role_t new_role);
239 size_t maxlenof_role() const;
240 uint32_t score_cyan() const;
241 void set_score_cyan(const uint32_t new_score_cyan);
242 size_t maxlenof_score_cyan() const;
243 uint32_t score_magenta() const;
244 void set_score_magenta(const uint32_t new_score_magenta);
245 size_t maxlenof_score_magenta() const;
246 virtual Message * create_message(const char *type) const;
247
248 virtual void copy_values(const Interface *other);
249 virtual const char * enum_tostring(const char *enumtype, int val) const;
250
251};
252
253} // end namespace fawkes
254
255#endif
SetKickoffMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
size_t maxlenof_kickoff() const
Get maximum length of kickoff value.
void set_kickoff(const bool new_kickoff)
Set kickoff value.
SetStateTeamMessage Fawkes BlackBoard Interface Message.
void set_state_team(const if_gamestate_team_t new_state_team)
Set state_team value.
size_t maxlenof_state_team() const
Get maximum length of state_team value.
if_gamestate_team_t state_team() const
Get state_team value.
virtual Message * clone() const
Clone this message.
SetTeamColorMessage Fawkes BlackBoard Interface Message.
if_gamestate_team_t our_team() const
Get our_team value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_our_team() const
Get maximum length of our_team value.
void set_our_team(const if_gamestate_team_t new_our_team)
Set our_team value.
GameStateInterface Fawkes BlackBoard Interface.
const char * tostring_if_gamestate_goalcolor_t(if_gamestate_goalcolor_t value) const
Convert if_gamestate_goalcolor_t constant to string.
if_gamestate_team_t
Enumeration defining the different teams.
@ TEAM_NONE
No team, not team-specific.
static const uint32_t GS_SPL_FINISHED
GS_SPL_FINISHED constant.
size_t maxlenof_kickoff() const
Get maximum length of kickoff value.
void set_score_magenta(const uint32_t new_score_magenta)
Set score_magenta value.
const char * tostring_if_gamestate_half_t(if_gamestate_half_t value) const
Convert if_gamestate_half_t constant to string.
static const uint32_t GS_FREE_KICK
GS_FREE_KICK constant.
size_t maxlenof_score_magenta() const
Get maximum length of score_magenta value.
static const uint32_t GS_SPL_READY
GS_SPL_READY constant.
if_gamestate_goalcolor_t
Enumeration defining the different teams.
const char * tostring_if_gamestate_team_t(if_gamestate_team_t value) const
Convert if_gamestate_team_t constant to string.
void set_half(const if_gamestate_half_t new_half)
Set half value.
size_t maxlenof_role() const
Get maximum length of role value.
void set_role(const if_gamestate_role_t new_role)
Set role value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
void set_our_goal_color(const if_gamestate_goalcolor_t new_our_goal_color)
Set our_goal_color value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
static const uint32_t GS_CORNER_KICK
GS_CORNER_KICK constant.
size_t maxlenof_our_team() const
Get maximum length of our_team value.
virtual Message * create_message(const char *type) const
Create message based on type name.
if_gamestate_team_t our_team() const
Get our_team value.
const char * tostring_if_gamestate_role_t(if_gamestate_role_t value) const
Convert if_gamestate_role_t constant to string.
if_gamestate_half_t
Enumeration defining the different teams.
uint32_t game_state() const
Get game_state value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
uint32_t score_cyan() const
Get score_cyan value.
void set_game_state(const uint32_t new_game_state)
Set game_state value.
static const uint32_t GS_THROW_IN
GS_THROW_IN constant.
size_t maxlenof_our_goal_color() const
Get maximum length of our_goal_color value.
static const uint32_t GS_HALF_TIME
GS_HALF_TIME constant.
void set_kickoff(const bool new_kickoff)
Set kickoff value.
static const uint32_t GS_FROZEN
GS_FROZEN constant.
void set_state_team(const if_gamestate_team_t new_state_team)
Set state_team value.
size_t maxlenof_game_state() const
Get maximum length of game_state value.
if_gamestate_team_t state_team() const
Get state_team value.
void set_score_cyan(const uint32_t new_score_cyan)
Set score_cyan value.
bool is_kickoff() const
Get kickoff value.
static const uint32_t GS_KICK_OFF
GS_KICK_OFF constant.
if_gamestate_half_t half() const
Get half value.
static const uint32_t GS_DROP_BALL
GS_DROP_BALL constant.
uint32_t score_magenta() const
Get score_magenta value.
if_gamestate_goalcolor_t our_goal_color() const
Get our_goal_color value.
size_t maxlenof_half() const
Get maximum length of half value.
static const uint32_t GS_SPL_INITIAL
GS_SPL_INITIAL constant.
static const uint32_t GS_SPL_SET
GS_SPL_SET constant.
size_t maxlenof_state_team() const
Get maximum length of state_team value.
void set_our_team(const if_gamestate_team_t new_our_team)
Set our_team value.
size_t maxlenof_score_cyan() const
Get maximum length of score_cyan value.
static const uint32_t GS_GOAL_KICK
GS_GOAL_KICK constant.
static const uint32_t GS_SPL_PLAY
GS_SPL_PLAY constant.
if_gamestate_role_t
Enumeration defining the different robot roles.
if_gamestate_role_t role() const
Get role value.
static const uint32_t GS_PLAY
GS_PLAY constant.
static const uint32_t GS_PENALTY
GS_PENALTY constant.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
const char * type() const
Get type of interface.
Definition: interface.cpp:652
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
Fawkes library namespace.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:54