00001 /** 00002 * @file Player.h 00003 * 00004 * Definition of class Player 00005 * 00006 * @author Martin Lötzsch 00007 */ 00008 #ifndef __Player_h_ 00009 #define __Player_h_ 00010 00011 #include <string.h> 00012 #include "Tools/Streams/InOut.h" 00013 00014 class Player; 00015 00016 /** 00017 * Returns a reference to a process wide player configuration. 00018 */ 00019 Player& getPlayer(); 00020 00021 /** 00022 * @class Player 00023 * 00024 * A class that represents the team color and player number of the robot. 00025 * 00026 * @author Martin Lötzsch 00027 */ 00028 class Player 00029 { 00030 public: 00031 /** Constructor. */ 00032 Player(); 00033 00034 /** Loads the data from player.cfg */ 00035 void load(); 00036 00037 /** possible team colors */ 00038 enum teamColor {red, blue, undefinedTeamColor}; 00039 00040 /** returns the name of a color */ 00041 static const char* getTeamColorName(teamColor color) 00042 { 00043 switch (color) 00044 { 00045 case red: return "red"; 00046 case blue: return "blue"; 00047 default: return "undefined"; 00048 } 00049 } 00050 00051 /** returns the team color */ 00052 teamColor getTeamColor() const { return theTeamColor; } 00053 00054 /** sets the team color */ 00055 void setTeamColor(teamColor t) { theTeamColor=t; } 00056 00057 /** returns the color for a given name */ 00058 static teamColor getTeamColorFromString(char* name) 00059 { 00060 if (strcmp(name,"red") == 0) return red; 00061 else if (strcmp(name,"blue") == 0) return blue; 00062 else return undefinedTeamColor; 00063 } 00064 00065 // #define FIVEDOGS 00066 /* -> Martin : Bitte vorläufig drinlassen. 00067 * Ich Überblicke es im Augenblick nicht was mehr als 4 TeamMessageSender / Receiver 00068 * für Auswirkungen in RobotControl haben. Wenn FIVEDOGS nicht gesetzt ist, werden nur 3 00069 * angelegt. 00070 * 00071 * Michael. 00072 */ 00073 00074 /** the possible player numbers */ 00075 enum playerNumber 00076 { 00077 one = 0, two, three, four, five, 00078 undefinedPlayerNumber, numOfPlayerNumbers = undefinedPlayerNumber 00079 }; 00080 00081 /** returns the name of a number */ 00082 static const char* getPlayerNumberName(playerNumber number) 00083 { 00084 switch (number) 00085 { 00086 case one: return "1"; 00087 case two: return "2"; 00088 case three: return "3"; 00089 case four: return "4"; 00090 case five: return "5"; 00091 00092 default: return "undefined"; 00093 } 00094 } 00095 00096 char* getTeamName() 00097 { 00098 return(theTeamName); 00099 } 00100 00101 /** returns the player number */ 00102 playerNumber getPlayerNumber() const { return thePlayerNumber; } 00103 00104 /** sets the player number */ 00105 void setPlayerNumber(playerNumber n) { thePlayerNumber=n; } 00106 00107 /** returns the number for a given name */ 00108 static playerNumber getPlayerNumberFromString(char* name) 00109 { 00110 if (strcmp(name,"1")==0) return one; 00111 else if (strcmp(name,"2")==0) return two; 00112 else if (strcmp(name,"3")==0) return three; 00113 else if (strcmp(name,"4")==0) return four; 00114 else if (strcmp(name,"5")==0) return five; 00115 00116 else return undefinedPlayerNumber; 00117 } 00118 00119 private: 00120 /** the team color of the player */ 00121 teamColor theTeamColor; 00122 00123 /** the number of the player */ 00124 playerNumber thePlayerNumber; 00125 00126 /** the team-name of the player */ 00127 char theTeamName[16]; 00128 }; 00129 00130 /** 00131 * Streaming operator that reads a Player from a stream. 00132 * @param stream The stream from which is read. 00133 * @param player The Player object. 00134 * @return The stream. 00135 */ 00136 In& operator>>(In& stream,Player& player); 00137 00138 /** 00139 * Streaming operator that writes a Player to a stream. 00140 * @param stream The stream to write on. 00141 * @param player The Player object. 00142 * @return The stream. 00143 */ 00144 Out& operator<<(Out& stream, const Player& player); 00145 00146 00147 #endif //__Player_h_ 00148 00149 /* 00150 * Change Log: 00151 * 00152 * $Log: Player.h,v $ 00153 * Revision 1.1.1.1 2004/05/22 17:35:53 cvsadm 00154 * created new repository GT2004_WM 00155 * 00156 * Revision 1.10 2004/05/17 17:17:50 kerdels 00157 * added symbols for the sequence control of the open challenge, 00158 * fixed a bug concerning 5-dog-mode and distribution of option-ratings, 00159 * set one = 0 in enum Player::playerNumber --> just to be sure ;-) 00160 * 00161 * Revision 1.9 2004/05/14 14:12:08 wachter 00162 * - Added communication support for 5 robots 00163 * - rewrote parts of team-communication to be faster and more stable 00164 * 00165 * Revision 1.8 2004/05/13 18:08:33 loetzsch 00166 * removed #ifdef statements, as they are not needed 00167 * 00168 * Revision 1.7 2004/05/12 19:33:14 kerdels 00169 * merged the behavior changes during australian, american and japan open 00170 * 00171 * Revision 1.6 2004/01/09 15:44:58 wachter 00172 * Added TeamName for Dog-Discovery-Protokol 00173 * 00174 * Revision 1.5 2003/12/06 23:38:46 loetzsch 00175 * bug fix 00176 * 00177 * Revision 1.4 2003/12/06 23:21:59 loetzsch 00178 * made the read functions const 00179 * 00180 * Revision 1.3 2003/12/06 19:01:05 loetzsch 00181 * replaced undefinedColor by undefinedTeamColor 00182 * 00183 * Revision 1.2 2003/12/06 17:45:34 loetzsch 00184 * replaced Player::playerRole (goalie, defender, striker1, striker2) 00185 * by Player::playerNumber (one, two, three, four) 00186 * 00187 * Revision 1.1 2003/10/07 10:13:21 cvsadm 00188 * Created GT2004 (M.J.) 00189 * 00190 * Revision 1.2 2003/09/25 11:21:59 juengel 00191 * Removed BlobCollection. 00192 * 00193 * Revision 1.1.1.1 2003/07/02 09:40:28 cvsadm 00194 * created new repository for the competitions in Padova from the 00195 * tamara CVS (Tuesday 2:00 pm) 00196 * 00197 * removed unused solutions 00198 * 00199 * Revision 1.4 2003/05/03 16:20:01 roefer 00200 * robot.cfg added 00201 * 00202 * Revision 1.3 2003/04/16 07:00:17 roefer 00203 * Bremen GO checkin 00204 * 00205 * Revision 1.3 2003/04/09 14:47:31 roefer 00206 * bodyTiltOffset is read from player.cfg 00207 * 00208 * Revision 1.2 2003/03/06 11:54:03 dueffert 00209 * missing case warning removed 00210 * 00211 * Revision 1.1 2002/09/10 15:53:58 cvsadm 00212 * Created new project GT2003 (M.L.) 00213 * - Cleaned up the /Src/DataTypes directory 00214 * - Removed challenge related source code 00215 * - Removed processing of incoming audio data 00216 * - Renamed AcousticMessage to SoundRequest 00217 * 00218 * Revision 1.7 2002/09/08 16:21:42 roefer 00219 * barChallenge name added 00220 * 00221 * Revision 1.6 2002/08/30 19:38:03 loetzsch 00222 * removed a few roles 00223 * 00224 * Revision 1.5 2002/07/23 13:48:40 loetzsch 00225 * - new streaming classes 00226 * - removed many #include statements 00227 * - exchanged StaticQueue by MessageQueue 00228 * - new debug message handling 00229 * - general clean up 00230 * 00231 * Revision 1.4 2002/06/12 17:54:12 risler 00232 * only one role barChallenger 00233 * 00234 * Revision 1.3 2002/06/10 12:29:33 tim 00235 * added roles for ball challenge 00236 * 00237 * Revision 1.2 2002/05/15 10:46:22 brunn 00238 * New Roles for Colaboration Challenge 2002 00239 * Extended draft for bar-perception 00240 * 00241 * Revision 1.1.1.1 2002/05/10 12:40:32 cvsadm 00242 * Moved GT2002 Project from ute to tamara. 00243 * 00244 * Revision 1.4 2002/05/05 14:04:36 loetzsch 00245 * added numOfPlayerRoles to the enum 00246 * 00247 * Revision 1.3 2002/04/08 13:34:14 dueffert 00248 * PlayersToolBar added 00249 * 00250 * Revision 1.2 2002/02/07 19:57:06 risler 00251 * DefaultLEDControl uses getPlayer now, removed team and role from LEDRequest 00252 * 00253 * Revision 1.1 2002/02/05 03:42:46 loetzsch 00254 * added to the cvs 00255 * 00256 */