Fawkes API  Fawkes Development Version
enums.cpp
1 
2 /***************************************************************************
3  * enums.cpp - World Info Transceiver Enums
4  *
5  * Created: Wed Apr 09 17:05:15 2008
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 #include "enums.h"
25 
26 #define CASE_STRING(x) \
27  case x: return #x
28 
29 namespace fawkes {
30 
31 /** Convert MSL gamestate to a string.
32  * @param gamestate game state to translate into a string
33  * @return string representation of the given state.
34  */
35 const char *
37 {
38  switch (gamestate) {
39  CASE_STRING(GS_FROZEN);
40  CASE_STRING(GS_PLAY);
41  CASE_STRING(GS_KICK_OFF);
42  CASE_STRING(GS_DROP_BALL);
43  CASE_STRING(GS_PENALTY);
44  CASE_STRING(GS_CORNER_KICK);
45  CASE_STRING(GS_THROW_IN);
46  CASE_STRING(GS_FREE_KICK);
47  CASE_STRING(GS_GOAL_KICK);
48  CASE_STRING(GS_HALF_TIME);
49  default: return "Unknown MSL Gamestate";
50  }
51 }
52 
53 /** Convert MSL gamestate to a string.
54  * @param gamestate game state to translate into a string
55  * @return string representation of the given state.
56  */
57 const char *
59 {
60  switch (gamestate) {
61  CASE_STRING(GS_SPL_INITIAL);
62  CASE_STRING(GS_SPL_READY);
63  CASE_STRING(GS_SPL_SET);
64  CASE_STRING(GS_SPL_PLAY);
65  CASE_STRING(GS_SPL_FINISHED);
66  default: return "Unknown SPL Gamestate";
67  }
68 }
69 
70 /** Convert gamestate team to a string.
71  * @param team game state team to translate into a string
72  * @return string representation of the given team.
73  */
74 const char *
76 {
77  switch (team) {
78  CASE_STRING(TEAM_CYAN);
79  CASE_STRING(TEAM_MAGENTA);
80  CASE_STRING(TEAM_NONE);
81  CASE_STRING(TEAM_BOTH);
82  default: return "Unknown Team";
83  }
84 }
85 
86 /** Convert goal color to a string.
87  * @param goal_color goal color
88  * @return string representation of the given goal color.
89  */
90 const char *
92 {
93  switch (goal_color) {
94  CASE_STRING(GOAL_BLUE);
95  CASE_STRING(GOAL_YELLOW);
96  default: return "Unknown Goal Color";
97  }
98 }
99 
100 /** Convert half time to a string.
101  * @param half half time
102  * @return string representation of the given half time.
103  */
104 const char *
106 {
107  switch (half) {
108  CASE_STRING(HALF_FIRST);
109  CASE_STRING(HALF_SECOND);
110  default: return "Unknown Half";
111  }
112 }
113 
114 /** Convert penalty to a string.
115  * @param penalty penalty to translate into a string
116  * @return string representation of the penalty
117  */
118 const char *
120 {
121  switch (penalty) {
122  CASE_STRING(PENALTY_NONE);
123  CASE_STRING(PENALTY_BALL_HOLDING);
124  CASE_STRING(PENALTY_GOALIE_PUSHING);
125  CASE_STRING(PENALTY_PLAYER_PUSHING);
126  CASE_STRING(PENALTY_ILLEGAL_DEFENDER);
127  CASE_STRING(PENALTY_ILLEGAL_DEFENSE);
128  CASE_STRING(PENALTY_OBSTRUCTION);
129  CASE_STRING(PENALTY_REQ_FOR_PICKUP);
130  CASE_STRING(PENALTY_LEAVING);
131  CASE_STRING(PENALTY_DAMAGE);
132  CASE_STRING(PENALTY_MANUAL);
133  default: return "Unknown Penalty";
134  }
135 }
136 
137 } // end namespace fawkes
Kick off.
Definition: enums.h:33
Robot was requested for pick up.
Definition: enums.h:81
Blue goal.
Definition: enums.h:62
Goal kick.
Definition: enums.h:39
Robot is an illegal defender.
Definition: enums.h:78
Robot has to leave.
Definition: enums.h:82
Manually penalized.
Definition: enums.h:84
Robot pushed a player.
Definition: enums.h:77
Robot pushed the goalie.
Definition: enums.h:76
Robot obstructs path way.
Definition: enums.h:80
Referee drops ball, both teams can wrestle for the ball.
Definition: enums.h:34
No team, not team-specific.
Definition: enums.h:54
Throw in.
Definition: enums.h:37
Fawkes library namespace.
worldinfo_penalty_t
Robot penalty code.
Definition: enums.h:73
Robot is damaged.
Definition: enums.h:83
Illegal defense.
Definition: enums.h:79
Yellow goal.
Definition: enums.h:63
Magenta team.
Definition: enums.h:56
Play, normal play.
Definition: enums.h:32
First half.
Definition: enums.h:68
worldinfo_gamestate_half_t
Game time half.
Definition: enums.h:67
const char * worldinfo_gamestate_team_tostring(worldinfo_gamestate_team_t team)
Convert gamestate team to a string.
Definition: enums.cpp:75
const char * worldinfo_msl_gamestate_tostring(worldinfo_msl_gamestate_t gamestate)
Convert MSL gamestate to a string.
Definition: enums.cpp:36
Both teams.
Definition: enums.h:57
Frozen, nothing moves.
Definition: enums.h:31
worldinfo_msl_gamestate_t
Game states for RoboCup MSL.
Definition: enums.h:30
Second half.
Definition: enums.h:69
Penalty kick.
Definition: enums.h:35
const char * worldinfo_gamestate_goalcolor_tostring(worldinfo_gamestate_goalcolor_t goal_color)
Convert goal color to a string.
Definition: enums.cpp:91
Half time.
Definition: enums.h:40
Corner kick.
Definition: enums.h:49
Cyan team.
Definition: enums.h:55
worldinfo_gamestate_team_t
Team.
Definition: enums.h:53
worldinfo_spl_gamestate_t
Game states for RoboCup SPL.
Definition: enums.h:44
No penalty.
Definition: enums.h:74
const char * worldinfo_spl_gamestate_tostring(worldinfo_spl_gamestate_t gamestate)
Convert MSL gamestate to a string.
Definition: enums.cpp:58
Wait for kick-off.
Definition: enums.h:47
const char * worldinfo_penalty_tostring(worldinfo_penalty_t penalty)
Convert penalty to a string.
Definition: enums.cpp:119
Move to kick-off positions.
Definition: enums.h:46
const char * worldinfo_gamestate_half_tostring(worldinfo_gamestate_half_t half)
Convert half time to a string.
Definition: enums.cpp:105
Free kick.
Definition: enums.h:38
Initial setup phase.
Definition: enums.h:45
Robot hold the ball.
Definition: enums.h:75
worldinfo_gamestate_goalcolor_t
Goal color.
Definition: enums.h:61
Corner kick.
Definition: enums.h:36