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_RCG_SERIALIZER_H
00033 #define RCSC_RCG_SERIALIZER_H
00034
00035 #include <rcsc/rcg/types.h>
00036 #include <rcsc/types.h>
00037
00038 #include <boost/shared_ptr.hpp>
00039
00040 #include <string>
00041 #include <ostream>
00042
00043 namespace rcsc {
00044 namespace rcg {
00045
00050 class Serializer {
00051 protected:
00052
00053 char M_playmode;
00054 TeamT M_teams[2];
00055
00056 protected:
00057
00062 Serializer();
00063
00067 virtual
00068 ~Serializer()
00069 { }
00070
00072
00073
00080 std::ostream & serializeImpl( std::ostream & os,
00081 const int version );
00082
00089 std::ostream & serializeImpl( std::ostream & os,
00090 const server_params_t & param );
00091
00098 std::ostream & serializeImpl( std::ostream & os,
00099 const player_params_t & pparam );
00100
00106 std::ostream & serializeImpl( std::ostream & os,
00107 const player_type_t & type );
00108
00114 std::ostream & serializeImpl( std::ostream & os,
00115 const team_t & team_l,
00116 const team_t & team_r );
00122 std::ostream & serializeImpl( std::ostream & os,
00123 const char pmode );
00124
00130 std::ostream & serializeImpl( std::ostream & os,
00131 const PlayMode pmode );
00132
00138 std::ostream & serializeImpl( std::ostream & os,
00139 const dispinfo_t & disp );
00140
00146 std::ostream & serializeImpl( std::ostream & os,
00147 const showinfo_t & show );
00148
00155 std::ostream & serializeImpl( std::ostream & os,
00156 const showinfo_t2 & show2 );
00157
00163 std::ostream & serializeImpl( std::ostream & os,
00164 const short_showinfo_t2 & show2 );
00165
00171 std::ostream & serializeImpl( std::ostream & os,
00172 const msginfo_t & msg );
00173
00179 std::ostream & serializeImpl( std::ostream & os,
00180 const drawinfo_t & draw );
00181
00187 std::ostream & serializeImpl( std::ostream & os,
00188 const dispinfo_t2 & disp2 );
00189
00190
00191
00192 public:
00194
00195
00201 static
00202 void convert( const pos_t & from,
00203 BallT & to );
00204
00210 static
00211 void convert( const ball_t & from,
00212 BallT & to );
00213
00219 static
00220 void convert( const pos_t & from,
00221 player_t & to );
00222
00230 static
00231 void convert( const SideID side,
00232 const int unum,
00233 const player_t & from,
00234 pos_t & to );
00235
00241 static
00242 void convert( const pos_t & from,
00243 PlayerT & to );
00244
00250 static
00251 void convert( const PlayerT & from,
00252 player_t & to );
00253
00259 static
00260 void convert( const player_t & from,
00261 PlayerT & to );
00262
00269 static
00270 void convert( const std::string & name,
00271 const int score,
00272 team_t & to );
00273
00279 static
00280 void convert( const TeamT & from,
00281 team_t & to );
00282
00288 static
00289 void convert( const team_t & from,
00290 TeamT & to );
00291
00297 static
00298 void convert( const showinfo_t & from,
00299 showinfo_t2 & to );
00300
00306 static
00307 void convert( const showinfo_t & from,
00308 short_showinfo_t2 & to );
00309
00315 static
00316 void convert( const showinfo_t2 & from,
00317 showinfo_t & to );
00318
00327 static
00328 void convert( const char playmode,
00329 const TeamT & team_l,
00330 const TeamT & team_r,
00331 const short_showinfo_t2 & from,
00332 showinfo_t & to );
00333
00342 static
00343 void convert( const char playmode,
00344 const TeamT & team_l,
00345 const TeamT & team_r,
00346 const ShowInfoT & from,
00347 showinfo_t & to );
00348
00354 static
00355 void convert( const showinfo_t & from,
00356 ShowInfoT & to );
00357
00366 static
00367 void convert( const char playmode,
00368 const TeamT & team_l,
00369 const TeamT & team_r,
00370 const ShowInfoT & from,
00371 showinfo_t2 & to );
00372
00378 static
00379 void convert( const showinfo_t2 & from,
00380 ShowInfoT & to );
00381
00387 static
00388 void convert( const ShowInfoT & from,
00389 short_showinfo_t2 & to );
00390
00396 static
00397 void convert( const short_showinfo_t2 & from,
00398 ShowInfoT & to );
00399
00405 static
00406 void convert( const std::string & from,
00407 msginfo_t & to );
00408
00410
00411
00417 virtual
00418 std::ostream & serializeHeader( std::ostream & os ) = 0;
00419
00426 virtual
00427 std::ostream & serializeParam( std::ostream & os,
00428 const std::string & msg ) = 0;
00429
00436 virtual
00437 std::ostream & serialize( std::ostream & os,
00438 const server_params_t & param ) = 0;
00439
00446 virtual
00447 std::ostream & serialize( std::ostream & os,
00448 const player_params_t & pparam ) = 0;
00449
00456 virtual
00457 std::ostream & serialize( std::ostream & os,
00458 const player_type_t & type ) = 0;
00459
00466 virtual
00467 std::ostream & serialize( std::ostream & os,
00468 const dispinfo_t & disp ) = 0;
00469
00476 virtual
00477 std::ostream & serialize( std::ostream & os,
00478 const showinfo_t & show ) = 0;
00479
00486 virtual
00487 std::ostream & serialize( std::ostream & os,
00488 const showinfo_t2 & show2 ) = 0;
00489
00496 virtual
00497 std::ostream & serialize( std::ostream & os,
00498 const short_showinfo_t2 & show2 ) = 0;
00499
00506 virtual
00507 std::ostream & serialize( std::ostream & os,
00508 const msginfo_t & msg ) = 0;
00509
00517 virtual
00518 std::ostream & serialize( std::ostream & os,
00519 const Int16 board,
00520 const std::string & msg ) = 0;
00521
00528 virtual
00529 std::ostream & serialize( std::ostream & os,
00530 const drawinfo_t & draw ) = 0;
00531
00538 virtual
00539 std::ostream & serialize( std::ostream & os,
00540 const char playmode ) = 0;
00541
00549 virtual
00550 std::ostream & serialize( std::ostream & os,
00551 const team_t & team_l,
00552 const team_t & team_r ) = 0;
00553
00561 virtual
00562 std::ostream & serialize( std::ostream & os,
00563 const TeamT & team_l,
00564 const TeamT & team_r ) = 0;
00565
00572 virtual
00573 std::ostream & serialize( std::ostream & os,
00574 const ShowInfoT & show ) = 0;
00575
00582 virtual
00583 std::ostream & serialize( std::ostream & os,
00584 const DispInfoT & disp ) = 0;
00585
00586 };
00587
00589 typedef boost::shared_ptr< Serializer > SerializerPtr;
00590
00591 }
00592 }
00593
00594 #endif