00001
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031
00032 #ifndef RCSC_PLAYER_PLAYER_MESSAGE_BUILDER_H
00033 #define RCSC_PLAYER_PLAYER_MESSAGE_BUILDER_H
00034
00035 #include <rcsc/geom/vector_2d.h>
00036 #include <rcsc/common/say_message_parser.h>
00037
00038 #include <string>
00039
00040 namespace rcsc {
00041
00042
00047 class SayMessage {
00048 private:
00049
00050
00051 SayMessage( const SayMessage & );
00052 SayMessage & operator=( const SayMessage & );
00053
00054 protected:
00055
00059 SayMessage()
00060 { }
00061
00062 public:
00063
00067 virtual
00068 ~SayMessage()
00069 { }
00070
00075 virtual
00076 char header() const = 0;
00077
00082 virtual
00083 std::size_t length() const = 0;
00084
00090 virtual
00091 bool toStr( std::string & to ) const = 0;
00092
00093 };
00094
00095
00096
00105 class BallMessage
00106 : public SayMessage {
00107 private:
00108
00109 Vector2D M_ball_pos;
00110 Vector2D M_ball_vel;
00111
00112 public:
00113
00119 BallMessage( const Vector2D & ball_pos,
00120 const Vector2D & ball_vel )
00121 : M_ball_pos( ball_pos )
00122 , M_ball_vel( ball_vel )
00123 { }
00124
00129 char header() const
00130 {
00131 return BallMessageParser::sheader();
00132 }
00133
00138 static
00139 std::size_t slength()
00140 {
00141 return BallMessageParser::slength();
00142 }
00143
00148 std::size_t length() const
00149 {
00150 return slength();
00151 }
00152
00158 bool toStr( std::string & to ) const;
00159
00160 };
00161
00162
00171 class PassMessage
00172 : public SayMessage {
00173 private:
00174
00175 int M_receiver_unum;
00176 Vector2D M_receive_point;
00177
00178 Vector2D M_ball_pos;
00179 Vector2D M_ball_vel;
00180
00181 public:
00182
00188 PassMessage( const int receiver_unum,
00189 const Vector2D & receive_point,
00190 const Vector2D & ball_pos,
00191 const Vector2D & ball_vel )
00192 : M_receiver_unum( receiver_unum )
00193 , M_receive_point( receive_point )
00194 , M_ball_pos( ball_pos )
00195 , M_ball_vel( ball_vel )
00196 { }
00197
00202 char header() const
00203 {
00204 return PassMessageParser::sheader();
00205 }
00206
00211 static
00212 std::size_t slength()
00213 {
00214 return PassMessageParser::slength();
00215 }
00216
00221 std::size_t length() const
00222 {
00223 return slength();
00224 }
00225
00231 bool toStr( std::string & to ) const;
00232
00233 };
00234
00235
00244 class InterceptMessage
00245 : public SayMessage {
00246 private:
00247
00248 bool M_our;
00249 int M_unum;
00250 int M_cycle;
00251
00252 public:
00253
00260 InterceptMessage( const bool our,
00261 const int unum,
00262 const int cycle )
00263 : M_our( our )
00264 , M_unum( unum )
00265 , M_cycle( cycle )
00266 { }
00267
00272 char header() const
00273 {
00274 return InterceptMessageParser::sheader();
00275 }
00276
00281 static
00282 std::size_t slength()
00283 {
00284 return InterceptMessageParser::slength();
00285 }
00286
00291 std::size_t length() const
00292 {
00293 return slength();
00294 }
00295
00301 bool toStr( std::string & to ) const;
00302 };
00303
00304
00313 class GoalieMessage
00314 : public SayMessage {
00315 private:
00316
00317 int M_goalie_unum;
00318 Vector2D M_goalie_pos;
00319 AngleDeg M_goalie_body;
00320
00321 public:
00322
00328 GoalieMessage( const int goalie_unum,
00329 const Vector2D & goalie_pos,
00330 const AngleDeg & goalie_body )
00331 : M_goalie_unum( goalie_unum )
00332 , M_goalie_pos( goalie_pos )
00333 , M_goalie_body( goalie_body )
00334 { }
00335
00340 char header() const
00341 {
00342 return GoalieMessageParser::sheader();
00343 }
00344
00349 static
00350 std::size_t slength()
00351 {
00352 return GoalieMessageParser::slength();
00353 }
00354
00359 std::size_t length() const
00360 {
00361 return slength();
00362 }
00363
00369 bool toStr( std::string & to ) const;
00370 };
00371
00372
00381 class OffsideLineMessage
00382 : public SayMessage {
00383 private:
00384
00385 double M_offside_line_x;
00386
00387 public:
00388
00393 explicit
00394 OffsideLineMessage( const double & offside_line_x )
00395 : M_offside_line_x( offside_line_x )
00396 { }
00397
00402 char header() const
00403 {
00404 return OffsideLineMessageParser::sheader();
00405 }
00406
00411 static
00412 std::size_t slength()
00413 {
00414 return OffsideLineMessageParser::slength();
00415 }
00416
00421 std::size_t length() const
00422 {
00423 return slength();
00424 }
00425
00431 bool toStr( std::string & to ) const;
00432 };
00433
00434
00443 class DefenseLineMessage
00444 : public SayMessage {
00445 private:
00446
00447 double M_defense_line_x;
00448
00449 public:
00450
00455 explicit
00456 DefenseLineMessage( const double & defense_line_x )
00457 : M_defense_line_x( defense_line_x )
00458 { }
00459
00464 char header() const
00465 {
00466 return DefenseLineMessageParser::sheader();
00467 }
00468
00473 static
00474 std::size_t slength()
00475 {
00476 return DefenseLineMessageParser::slength();
00477 }
00478
00483 std::size_t length() const
00484 {
00485 return slength();
00486 }
00487
00493 bool toStr( std::string & to ) const;
00494 };
00495
00496
00505 class WaitRequestMessage
00506 : public SayMessage {
00507 private:
00508
00509 public:
00510
00514 WaitRequestMessage()
00515 { }
00516
00521 char header() const
00522 {
00523 return WaitRequestMessageParser::sheader();
00524 }
00525
00530 static
00531 std::size_t slength()
00532 {
00533 return WaitRequestMessageParser::slength();
00534 }
00535
00540 std::size_t length() const
00541 {
00542 return slength();
00543 }
00544
00550 bool toStr( std::string & to ) const;
00551 };
00552
00553
00562 class PassRequestMessage
00563 : public SayMessage {
00564 private:
00565
00566 Vector2D M_target_point;
00567
00568 public:
00569
00574 explicit
00575 PassRequestMessage( const Vector2D & target_point )
00576 : M_target_point( target_point )
00577 { }
00578
00583 char header() const
00584 {
00585 return PassRequestMessageParser::sheader();
00586 }
00587
00592 static
00593 std::size_t slength()
00594 {
00595 return PassRequestMessageParser::slength();
00596 }
00597
00602 std::size_t length() const
00603 {
00604 return slength();
00605 }
00606
00612 bool toStr( std::string & to ) const;
00613 };
00614
00615
00624 class StaminaMessage
00625 : public SayMessage {
00626 private:
00627
00628 double M_stamina;
00629
00630 public:
00631
00636 explicit
00637 StaminaMessage( const double & stamina )
00638 : M_stamina( stamina )
00639 { }
00640
00645 char header() const
00646 {
00647 return StaminaMessageParser::sheader();
00648 }
00649
00654 static
00655 std::size_t slength()
00656 {
00657 return StaminaMessageParser::slength();
00658 }
00659
00664 std::size_t length() const
00665 {
00666 return slength();
00667 }
00668
00674 bool toStr( std::string & to ) const;
00675 };
00676
00677
00686 class RecoveryMessage
00687 : public SayMessage {
00688 private:
00689
00690 double M_recovery;
00691
00692 public:
00693
00698 explicit
00699 RecoveryMessage( const double & recovery )
00700 : M_recovery( recovery )
00701 { }
00702
00707 char header() const
00708 {
00709 return RecoveryMessageParser::sheader();
00710 }
00711
00716 static
00717 std::size_t slength()
00718 {
00719 return RecoveryMessageParser::slength();
00720 }
00721
00726 std::size_t length() const
00727 {
00728 return slength();
00729 }
00730
00736 bool toStr( std::string & to ) const;
00737 };
00738
00739
00748 class DribbleMessage
00749 : public SayMessage {
00750 private:
00751
00752 Vector2D M_target_point;
00753 int M_queue_count;
00754
00755 public:
00756
00762 DribbleMessage( const Vector2D & target_point,
00763 const int queue_count )
00764 : M_target_point( target_point )
00765 , M_queue_count( queue_count )
00766 { }
00767
00772 char header() const
00773 {
00774 return DribbleMessageParser::sheader();
00775 }
00776
00781 static
00782 std::size_t slength()
00783 {
00784 return DribbleMessageParser::slength();
00785 }
00786
00791 std::size_t length() const
00792 {
00793 return slength();
00794 }
00795
00801 bool toStr( std::string & to ) const;
00802 };
00803
00804
00813 class BallGoalieMessage
00814 : public SayMessage {
00815 private:
00816
00817 Vector2D M_ball_pos;
00818 Vector2D M_ball_vel;
00819 Vector2D M_goalie_pos;
00820 AngleDeg M_goalie_body;
00821
00822 public:
00823
00831 BallGoalieMessage( const Vector2D & ball_pos,
00832 const Vector2D & ball_vel,
00833 const Vector2D & goalie_pos,
00834 const AngleDeg & goalie_body )
00835 : M_ball_pos( ball_pos )
00836 , M_ball_vel( ball_vel )
00837 , M_goalie_pos( goalie_pos )
00838 , M_goalie_body( goalie_body )
00839 { }
00840
00845 char header() const
00846 {
00847 return BallGoalieMessageParser::sheader();
00848 }
00849
00854 static
00855 std::size_t slength()
00856 {
00857 return BallGoalieMessageParser::slength();
00858 }
00859
00864 std::size_t length() const
00865 {
00866 return slength();
00867 }
00868
00874 bool toStr( std::string & to ) const;
00875 };
00876
00877
00886 class OnePlayerMessage
00887 : public SayMessage {
00888 private:
00889
00890 int M_unum;
00891 Vector2D M_player_pos;
00892 AngleDeg M_player_body;
00893
00894 public:
00895
00902 OnePlayerMessage( const int unum,
00903 const Vector2D & player_pos,
00904 const AngleDeg & player_body )
00905 : M_unum( unum )
00906 , M_player_pos( player_pos )
00907 , M_player_body( player_body )
00908 { }
00909
00914 char header() const
00915 {
00916 return OnePlayerMessageParser::sheader();
00917 }
00918
00923 static
00924 std::size_t slength()
00925 {
00926 return OnePlayerMessageParser::slength();
00927 }
00928
00933 std::size_t length() const
00934 {
00935 return slength();
00936 }
00937
00943 bool toStr( std::string & to ) const;
00944 };
00945
00946
00955 class BallPlayerMessage
00956 : public SayMessage {
00957 private:
00958
00959 Vector2D M_ball_pos;
00960 Vector2D M_ball_vel;
00961
00962 int M_unum;
00963 Vector2D M_player_pos;
00964 AngleDeg M_player_body;
00965
00966 public:
00967
00976 BallPlayerMessage( const Vector2D & ball_pos,
00977 const Vector2D & ball_vel,
00978 const int unum,
00979 const Vector2D & player_pos,
00980 const AngleDeg & player_body )
00981 : M_ball_pos( ball_pos )
00982 , M_ball_vel( ball_vel )
00983 , M_unum( unum )
00984 , M_player_pos( player_pos )
00985 , M_player_body( player_body )
00986 { }
00987
00992 char header() const
00993 {
00994 return BallPlayerMessageParser::sheader();
00995 }
00996
01001 static
01002 std::size_t slength()
01003 {
01004 return BallPlayerMessageParser::slength();
01005 }
01006
01011 std::size_t length() const
01012 {
01013 return slength();
01014 }
01015
01021 bool toStr( std::string & to ) const;
01022 };
01023
01024 }
01025
01026 #endif