basic_client.h

説明を見る。
00001 // -*-c++-*-
00002 
00008 /*
00009  *Copyright:
00010 
00011  Copyright (C) Hidehisa AKIYAMA
00012 
00013  This code is free software; you can redistribute it and/or
00014  modify it under the terms of the GNU Lesser General Public
00015  License as published by the Free Software Foundation; either
00016  version 2.1 of the License, or (at your option) any later version.
00017 
00018  This library is distributed in the hope that it will be useful,
00019  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  Lesser General Public License for more details.
00022 
00023  You should have received a copy of the GNU Lesser General Public
00024  License along with this library; if not, write to the Free Software
00025  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027  *EndCopyright:
00028  */
00029 
00031 
00032 #ifndef RCSC_BASIC_CLIENT_H
00033 #define RCSC_BASIC_CLIENT_H
00034 
00035 #include <boost/shared_ptr.hpp>
00036 
00037 #include <string>
00038 
00039 namespace rcsc {
00040 
00041 class UDPSocket;
00042 class GZCompressor;
00043 class GZDecompressor;
00044 class CmdLineParser;
00045 class SoccerAgent;
00046 
00055 class BasicClient {
00056 public:
00057     enum {
00058         MAX_MESG = 8192, 
00059     };
00060 
00061 private:
00063     boost::shared_ptr< UDPSocket > M_socket;
00064 
00066     bool M_server_alive;
00067 
00069     long M_interval_msec;
00070 
00072     char M_message[MAX_MESG];
00073 
00075     boost::shared_ptr< GZCompressor > M_compressor;
00076 
00078     boost::shared_ptr< GZDecompressor > M_decompressor;
00079 
00081     int M_compression_level;
00082 
00084     std::string M_compression_message;
00085 
00087     std::string M_decompression_message;
00088 
00089     // nocopyable
00090     BasicClient( const BasicClient & );
00091     BasicClient & operator=( const BasicClient & );
00092 
00093 public:
00097     BasicClient();
00098 
00102     virtual
00103     ~BasicClient();
00104 
00112     bool connectTo( const char * hostname,
00113                     const int port,
00114                     const long & interval_msec );
00115 
00126     void run( SoccerAgent * agent );
00127 
00132     void setIntervalMSec( const long & interval_msec );
00133 
00138     void setServerAlive( const bool alive );
00139 
00145     int setCompressionLevel( const int level );
00146 
00152     int sendMessage( const char * msg );
00153 
00158     int recvMessage();
00159 
00164     bool isServerAlive() const
00165       {
00166           return M_server_alive;
00167       }
00168 
00173     const
00174     char * message() const
00175       {
00176           return M_decompression_message.c_str();
00177       }
00178 
00179 };
00180 
00181 }
00182 
00183 #endif

librcscに対してThu May 1 15:41:20 2008に生成されました。  doxygen 1.5.0