Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Representations/RoboCup/GameControlData.h

Go to the documentation of this file.
00001 /**
00002 * @file GameControlData.h
00003 *
00004 * Declaration of class GameControlData
00005 *
00006 * @author Martin Lötzsch
00007 */ 
00008 
00009 #ifndef __GameControlData_h_
00010 #define __GameControlData_h_
00011 
00012 #include "RoboCupGameControlData.h"
00013 #include "Tools/Streams/InOut.h"
00014 #include "Tools/Player.h"
00015 
00016 /**
00017 * @class GlobalGameControlData
00018 *
00019 * Specifies the game state for two teams of four robots.
00020 * Different from the GameControlData sent from Sony's GameManager
00021 * (which is specific for one robot) this class contains the game state
00022 * for all robots.
00023 *
00024 * @author Martin Lötzsch
00025 */
00026 class GlobalGameControlData
00027 {
00028 public:
00029   /** Constructor */
00030   GlobalGameControlData();
00031   
00032   /** Which team does the kickoff */
00033   enum Kickoff { kickoffRedTeam, kickoffBlueTeam } kickoff;
00034   
00035   /** The game state */
00036   enum State { initial = ROBOCUP_STATE_INITIAL, 
00037     ready = ROBOCUP_STATE_READY, 
00038     set = ROBOCUP_STATE_SET,
00039     playing = ROBOCUP_STATE_PLAYING, 
00040     penalized = ROBOCUP_STATE_PENALIZED, 
00041     finished = ROBOCUP_STATE_FINISHED
00042   } state;
00043   
00044   /** The score of the red team */
00045   short redScore;
00046   
00047   /** The score of the blue team */
00048   short blueScore;
00049   
00050   /** Possible penalties */
00051   enum Penalties { 
00052     notPenalized = PENALTY_NONE,
00053     illegalDefender = PENALTY_ILLEGAL_DEFENDER,
00054     illegalDefanse = PENALTY_ILLEGAL_DEFENSE,
00055     obstruction = PENALTY_OBSTRUCTION,
00056     keeperCharge = PENALTY_KEEPER_CHARGE, 
00057     playerCharge = PENALTY_FIELD_PLAYER_CHARGE,
00058     ballHolding = PENALTY_BALL_HOLDING, 
00059     requestForPickup = PENALTY_REQ_FOR_PICKUP
00060   };
00061 
00062   /** The current penalty states of the red team */
00063   Penalties penaltiesRedTeam[4];
00064 
00065   /** The current penalty states of the blue team */
00066   Penalties penaltiesBlueTeam[4];
00067 };
00068 
00069 /**
00070 * Streaming operator that reads a GlobalGameControlData from a stream.
00071 * @param stream The stream from which is read.
00072 * @param globalGameControlData The GlobalGameControlData object.
00073 * @return The stream.
00074 */ 
00075 In& operator>>(In& stream,GlobalGameControlData& globalGameControlData);
00076 
00077 /**
00078 * Streaming operator that writes a GlobalGameControlData to a stream.
00079 * @param stream The stream to write on.
00080 * @param globalGameControlData The GlobalGameControlData object.
00081 * @return The stream.
00082 */ 
00083 Out& operator<<(Out& stream, const GlobalGameControlData& globalGameControlData);
00084 
00085 /** 
00086 * @class GameControlData
00087 *
00088 * Encapsulates the RoboCupGameControlData struct for the GT2003 project.
00089 *
00090 * @author Martin Loetzsch
00091 */
00092 class GameControlData
00093 {
00094 public:
00095 /**
00096 * Constructor.
00097   */
00098   GameControlData();
00099   
00100   /** an instance of RoboCupGameControlData */
00101   RoboCupGameControlData data;
00102   
00103   /** 
00104   * The timestamp when the last request was received.
00105   * Note that this value is set in the In streaming operator.
00106   */
00107   unsigned long timeStamp;
00108   
00109   /** returns the name of the state */
00110   static const char* getStateName(RState state)
00111   {
00112     switch (state)
00113     {
00114     case ROBOCUP_STATE_INITIAL: return "initial";
00115     case ROBOCUP_STATE_READY: return "ready";
00116     case ROBOCUP_STATE_SET: return "set";
00117     case ROBOCUP_STATE_PLAYING: return "playing";
00118     case ROBOCUP_STATE_PENALIZED: return "penalized";
00119     case ROBOCUP_STATE_FINISHED: return "finished";
00120     default: return "unknown state";
00121     }
00122   }
00123   
00124   /** returns the name for the variable kickoff */
00125   static const char* getKickoffName(RKickOff kickoff)
00126   {
00127     switch (kickoff)
00128     {
00129     case ROBOCUP_KICKOFF_OWN: return "own";
00130     case ROBOCUP_KICKOFF_OPPONENT: return "opponent";
00131     case ROBOCUP_KICKOFF_INVALID: return "invalid";
00132     default: return "unknown kickoff";
00133     }
00134   }
00135 
00136   /** returns the name of the team color */
00137   static const char* getTeamColorName(RTeamColor teamColor)
00138   {
00139     switch (teamColor)
00140     {
00141     case ROBOCUP_TEAMCOLOR_RED: return "red";
00142     case ROBOCUP_TEAMCOLOR_BLUE: return "blue";
00143     default: return "unknown color";
00144     }
00145   }
00146 
00147   /** returns the name of the current penalty */
00148   static const char* getPenaltyName(RPenalty penalty)
00149   {
00150     switch (penalty)
00151     {
00152     case PENALTY_NONE: return "no penalty";
00153     case PENALTY_ILLEGAL_DEFENDER: return "illegal defender";
00154     case PENALTY_ILLEGAL_DEFENSE: return "illegal defense";
00155     case PENALTY_OBSTRUCTION: return "obstruction";
00156     case PENALTY_KEEPER_CHARGE: return "keeper charge";
00157     case PENALTY_FIELD_PLAYER_CHARGE: return "field player charge";
00158     case PENALTY_BALL_HOLDING: return "ball holding";
00159     case PENALTY_REQ_FOR_PICKUP: return "request for pick-up";
00160     default: return "unknown penalty";
00161     }
00162   }
00163   
00164   /** 
00165   * Translates a GlobalGameControlData to GameControlData.
00166   * @param globalGameControlData The global game state
00167   * @param player This player
00168   */
00169   void translateFromGlobalGameControlData( const GlobalGameControlData& globalGameControlData, 
00170     Player& player);
00171   
00172   /** the == operator */
00173   bool operator == (const GameControlData& other);
00174   
00175   /** the != operator */
00176   bool operator != (const GameControlData& other)
00177   {
00178     return ! (*this == other);
00179   }
00180 };
00181 
00182 
00183 /**
00184 * Streaming operator that reads a GameControlData from a stream.
00185 * @param stream The stream from which is read.
00186 * @param gameControlData The GameControlData object.
00187 * @return The stream.
00188 */ 
00189 In& operator>>(In& stream,GameControlData& gameControlData);
00190 
00191 /**
00192 * Streaming operator that writes a GameControlData to a stream.
00193 * @param stream The stream to write on.
00194 * @param gameControlData The GameControlData object.
00195 * @return The stream.
00196 */ 
00197 Out& operator<<(Out& stream, const GameControlData& gameControlData);
00198 
00199 #endif //__GameControlData_h_
00200 
00201 /*
00202 * Change log :
00203 *
00204 * $Log: GameControlData.h,v $
00205 * Revision 1.1.1.1  2004/05/22 17:26:04  cvsadm
00206 * created new repository GT2004_WM
00207 *
00208 * Revision 1.3  2004/03/25 17:32:45  loetzsch
00209 * ranamed state final to finished
00210 *
00211 * Revision 1.2  2004/03/15 12:50:32  tim
00212 * Adaptions to new GameController
00213 *
00214 * Revision 1.1  2003/10/07 10:09:36  cvsadm
00215 * Created GT2004 (M.J.)
00216 *
00217 * Revision 1.1.1.1  2003/07/02 09:40:23  cvsadm
00218 * created new repository for the competitions in Padova from the 
00219 * tamara CVS (Tuesday 2:00 pm)
00220 *
00221 * removed unused solutions
00222 *
00223 * Revision 1.3  2003/03/24 15:45:39  loetzsch
00224 * added the new version of RoboCupGameControlData
00225 *
00226 * Revision 1.2  2003/03/05 11:10:05  loetzsch
00227 * added class GlobalGameControlData
00228 *
00229 * Revision 1.1  2002/09/10 15:26:40  cvsadm
00230 * Created new project GT2003 (M.L.)
00231 * - Cleaned up the /Src/DataTypes directory
00232 * - Removed Challenge Code
00233 * - Removed processing of incoming audio data
00234 * - Renamed AcousticMessage to SoundRequest
00235 *
00236 * Revision 1.3  2002/07/23 13:32:57  loetzsch
00237 * new streaming classes
00238 *
00239 * removed many #include statements
00240 *
00241 * Revision 1.2  2002/06/04 00:11:19  loetzsch
00242 * added == and != operator
00243 *
00244 * Revision 1.1.1.1  2002/05/10 12:40:13  cvsadm
00245 * Moved GT2002 Project from ute to tamara.
00246 *
00247 * Revision 1.2  2002/05/05 22:12:42  loetzsch
00248 * GameControlData can now be sent from the Game toolbar to BehaviorControl
00249 *
00250 * Revision 1.1  2002/05/05 18:52:01  loetzsch
00251 * added
00252 * - GameControlData,
00253 * - Receivers for GameControlData
00254 * - access by behavior to GameControlData
00255 *
00256 */
00257 

Generated on Thu Sep 23 19:57:36 2004 for GT2004 by doxygen 1.3.6