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 typedef long unsigned int uint32;
    00013
    00014 #include "RoboCupGameControlData.h"
    00015 #include "Tools/Streams/InOut.h"
    00016 #include "Tools/Player.h"
    00017
    00018 /**
    00019 * @class GameControlData
    00020 *
    00021 * Encapsulates the RoboCupGameControlData struct for the GT2005 project.
    00022 *
    00023 * @author Michael Wachter
    00024 */
    00025 class GameControlData
    00026 {
    00027 public:
    00028   enum State
    00029   {
    00030     initial = STATE_INITIAL,
    00031     ready = STATE_READY,
    00032     set = STATE_SET,
    00033     playing = STATE_PLAYING,
    00034     finished = STATE_FINISHED
    00035   };
    00036
    00037   enum Penalties
    00038   {
    00039     notPenalized = PENALTY_NONE,
    00040     illegalDefender = PENALTY_ILLEGAL_DEFENDER,
    00041     illegalDefense = PENALTY_ILLEGAL_DEFENSE,
    00042     obstruction = PENALTY_OBSTRUCTION,
    00043     goaliePushing = PENALTY_GOALIE_PUSHING,
    00044     playerPushing = PENALTY_PLAYER_PUSHING,
    00045     ballHolding = PENALTY_BALL_HOLDING,
    00046     requestForPickup = PENALTY_REQ_FOR_PICKUP,  //WARNING ! PICKUP was spelled PICUP in original RoboCupGameControlData.h
    00047     leaving = PENALTY_LEAVING,
    00048     damage = PENALTY_DAMAGE,
    00049     numOfPenalties
    00050   };
    00051
    00052   enum KickoffTeam
    00053   {
    00054     undefinedTeam,
    00055     ownTeam,
    00056     opponentTeam
    00057   };
    00058
    00059   /**
    00060    * Constuctor
    00061    */
    00062   GameControlData();
    00063
    00064   /** returns the name of the state */
    00065   static const char* getStateName(State state);
    00066
    00067   /** returns the name for the variable kickoff */
    00068   static const char* getKickoffTeamName(KickoffTeam kickoffTeam);
    00069
    00070   /** returns the name of the current penalty */
    00071   static const char* getPenaltyName(Penalties penalty);
    00072
    00073   /** returns the penalty of the player */
    00074   Penalties getPenalty(Player player = getPlayer()) const;
    00075
    00076   /** returns the number (0,1) of the data.teams -array the robot belongs to. */
    00077   unsigned int getOwnTeamNumber(Player player = getPlayer()) const;
    00078
    00079   /** returns a reference to the teamInfo of the team of the Player */
    00080   const TeamInfo& getOwnTeam(Player player = getPlayer()) const;
    00081   TeamInfo& getOwnTeam(Player player = getPlayer());
    00082
    00083    /** returns the number (0,1) of the data.teams -array of the robots opponents. */
    00084   unsigned int getOpponentTeamNumber(Player player = getPlayer()) const;
    00085
    00086   /** returns the robot-info for a player **/
    00087   const RobotInfo& getRobot(Player player = getPlayer()) const;
    00088   RobotInfo& getRobot(Player player = getPlayer());
    00089
    00090   /** returns a reference to the teamInfo of the team of the robots opponents */
    00091   const TeamInfo& getOpponentTeam(Player player = getPlayer()) const;
    00092   TeamInfo& getOpponentTeam(Player Player = getPlayer());
    00093
    00094   /** returns the Kickoff-Team as own/opponent */
    00095   KickoffTeam getKickoffTeam(Player player = getPlayer()) const;
    00096
    00097   /** returns the Team by the GameControlerTeamNumber) */
    00098   const TeamInfo& getTeamByNumber(int number) const;
    00099   TeamInfo& getTeamByNumber(int number);
    00100
    00101   const TeamInfo& getTeamByColor(int color) const;
    00102   TeamInfo& getTeamByColor(int color);
    00103
    00104   /** the == operator */
    00105   bool operator == (const GameControlData& other);
    00106
    00107   /** the != operator */
    00108   bool operator != (const GameControlData& other)
    00109   {
    00110     return ! (*this == other);
    00111   }
    00112
    00113   /**
    00114    * The data send by the game-controller
    00115    */
    00116   mutable RoboCupGameControlData data;
    00117
    00118   mutable bool switchOff;
    00119
    00120   /**
    00121   * The timestamp when the last request was received.
    00122   * Note that this value is set in the In streaming operator.
    00123   */
    00124   unsigned long timeStamp;
    00125 };
    00126
    00127
    00128 /**
    00129 * Streaming operator that reads a GameControlData from a stream.
    00130 * @param stream The stream from which is read.
    00131 * @param gameControlData The GameControlData object.
    00132 * @return The stream.
    00133 */
    00134 In& operator>>(In& stream,GameControlData& gameControlData);
    00135
    00136 /**
    00137 * Streaming operator that writes a GameControlData to a stream.
    00138 * @param stream The stream to write on.
    00139 * @param gameControlData The GameControlData object.
    00140 * @return The stream.
    00141 */
    00142 Out& operator<<(Out& stream, const GameControlData& gameControlData);
    00143
    00144 #endif //__GameControlData_h_
    00145