00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __INTERFACES_GAMESTATEINTERFACE_H_
00025 #define __INTERFACES_GAMESTATEINTERFACE_H_
00026
00027 #include <interface/interface.h>
00028 #include <interface/message.h>
00029 #include <interface/field_iterator.h>
00030
00031 namespace fawkes {
00032
00033 class GameStateInterface : public Interface
00034 {
00035
00036 INTERFACE_MGMT_FRIENDS(GameStateInterface)
00037
00038 public:
00039
00040 static const uint32_t GS_FROZEN;
00041 static const uint32_t GS_PLAY;
00042 static const uint32_t GS_KICK_OFF;
00043 static const uint32_t GS_DROP_BALL;
00044 static const uint32_t GS_PENALTY;
00045 static const uint32_t GS_CORNER_KICK;
00046 static const uint32_t GS_THROW_IN;
00047 static const uint32_t GS_FREE_KICK;
00048 static const uint32_t GS_GOAL_KICK;
00049 static const uint32_t GS_HALF_TIME;
00050 static const uint32_t GS_SPL_INITIAL;
00051 static const uint32_t GS_SPL_READY;
00052 static const uint32_t GS_SPL_SET;
00053 static const uint32_t GS_SPL_PLAY;
00054 static const uint32_t GS_SPL_FINISHED;
00055
00056
00057
00058
00059
00060 typedef enum {
00061 TEAM_NONE ,
00062 TEAM_CYAN ,
00063 TEAM_MAGENTA ,
00064 TEAM_BOTH
00065 } if_gamestate_team_t;
00066 const char * tostring_if_gamestate_team_t(if_gamestate_team_t value) const;
00067
00068
00069
00070
00071
00072 typedef enum {
00073 GOAL_BLUE ,
00074 GOAL_YELLOW
00075 } if_gamestate_goalcolor_t;
00076 const char * tostring_if_gamestate_goalcolor_t(if_gamestate_goalcolor_t value) const;
00077
00078
00079
00080
00081
00082 typedef enum {
00083 HALF_FIRST ,
00084 HALF_SECOND
00085 } if_gamestate_half_t;
00086 const char * tostring_if_gamestate_half_t(if_gamestate_half_t value) const;
00087
00088
00089
00090
00091
00092 typedef enum {
00093 ROLE_GOALIE ,
00094 ROLE_DEFENDER ,
00095 ROLE_MID_LEFT ,
00096 ROLE_MID_RIGHT ,
00097 ROLE_ATTACKER
00098 } if_gamestate_role_t;
00099 const char * tostring_if_gamestate_role_t(if_gamestate_role_t value) const;
00100
00101 private:
00102 #pragma pack(push,4)
00103
00104 typedef struct {
00105 int64_t timestamp_sec;
00106 int64_t timestamp_usec;
00107 uint32_t game_state;
00108 if_gamestate_team_t state_team;
00109 if_gamestate_team_t our_team;
00110 if_gamestate_goalcolor_t our_goal_color;
00111 if_gamestate_half_t half;
00112 bool kickoff;
00113 if_gamestate_role_t role;
00114 uint32_t score_cyan;
00115 uint32_t score_magenta;
00116 } GameStateInterface_data_t;
00117 #pragma pack(pop)
00118
00119 GameStateInterface_data_t *data;
00120
00121 public:
00122
00123 class SetTeamColorMessage : public Message
00124 {
00125 private:
00126 #pragma pack(push,4)
00127
00128 typedef struct {
00129 int64_t timestamp_sec;
00130 int64_t timestamp_usec;
00131 if_gamestate_team_t our_team;
00132 } SetTeamColorMessage_data_t;
00133 #pragma pack(pop)
00134
00135 SetTeamColorMessage_data_t *data;
00136
00137 public:
00138 SetTeamColorMessage(const if_gamestate_team_t ini_our_team);
00139 SetTeamColorMessage();
00140 ~SetTeamColorMessage();
00141
00142 SetTeamColorMessage(const SetTeamColorMessage *m);
00143
00144 if_gamestate_team_t our_team() const;
00145 void set_our_team(const if_gamestate_team_t new_our_team);
00146 size_t maxlenof_our_team() const;
00147 virtual Message * clone() const;
00148 };
00149
00150 class SetKickoffMessage : public Message
00151 {
00152 private:
00153 #pragma pack(push,4)
00154
00155 typedef struct {
00156 int64_t timestamp_sec;
00157 int64_t timestamp_usec;
00158 bool kickoff;
00159 } SetKickoffMessage_data_t;
00160 #pragma pack(pop)
00161
00162 SetKickoffMessage_data_t *data;
00163
00164 public:
00165 SetKickoffMessage(const bool ini_kickoff);
00166 SetKickoffMessage();
00167 ~SetKickoffMessage();
00168
00169 SetKickoffMessage(const SetKickoffMessage *m);
00170
00171 bool is_kickoff() const;
00172 void set_kickoff(const bool new_kickoff);
00173 size_t maxlenof_kickoff() const;
00174 virtual Message * clone() const;
00175 };
00176
00177 class SetStateTeamMessage : public Message
00178 {
00179 private:
00180 #pragma pack(push,4)
00181
00182 typedef struct {
00183 int64_t timestamp_sec;
00184 int64_t timestamp_usec;
00185 if_gamestate_team_t state_team;
00186 } SetStateTeamMessage_data_t;
00187 #pragma pack(pop)
00188
00189 SetStateTeamMessage_data_t *data;
00190
00191 public:
00192 SetStateTeamMessage(const if_gamestate_team_t ini_state_team);
00193 SetStateTeamMessage();
00194 ~SetStateTeamMessage();
00195
00196 SetStateTeamMessage(const SetStateTeamMessage *m);
00197
00198 if_gamestate_team_t state_team() const;
00199 void set_state_team(const if_gamestate_team_t new_state_team);
00200 size_t maxlenof_state_team() const;
00201 virtual Message * clone() const;
00202 };
00203
00204 virtual bool message_valid(const Message *message) const;
00205 private:
00206 GameStateInterface();
00207 ~GameStateInterface();
00208
00209 public:
00210
00211 uint32_t game_state() const;
00212 void set_game_state(const uint32_t new_game_state);
00213 size_t maxlenof_game_state() const;
00214 if_gamestate_team_t state_team() const;
00215 void set_state_team(const if_gamestate_team_t new_state_team);
00216 size_t maxlenof_state_team() const;
00217 if_gamestate_team_t our_team() const;
00218 void set_our_team(const if_gamestate_team_t new_our_team);
00219 size_t maxlenof_our_team() const;
00220 if_gamestate_goalcolor_t our_goal_color() const;
00221 void set_our_goal_color(const if_gamestate_goalcolor_t new_our_goal_color);
00222 size_t maxlenof_our_goal_color() const;
00223 if_gamestate_half_t half() const;
00224 void set_half(const if_gamestate_half_t new_half);
00225 size_t maxlenof_half() const;
00226 bool is_kickoff() const;
00227 void set_kickoff(const bool new_kickoff);
00228 size_t maxlenof_kickoff() const;
00229 if_gamestate_role_t role() const;
00230 void set_role(const if_gamestate_role_t new_role);
00231 size_t maxlenof_role() const;
00232 uint32_t score_cyan() const;
00233 void set_score_cyan(const uint32_t new_score_cyan);
00234 size_t maxlenof_score_cyan() const;
00235 uint32_t score_magenta() const;
00236 void set_score_magenta(const uint32_t new_score_magenta);
00237 size_t maxlenof_score_magenta() const;
00238 virtual Message * create_message(const char *type) const;
00239
00240 virtual void copy_values(const Interface *other);
00241 virtual const char * enum_tostring(const char *enumtype, int val) const;
00242
00243 };
00244
00245 }
00246
00247 #endif