team_graphic.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_COMMON_TEAM_GRAPHIC_H
00033 #define RCSC_COMMON_TEAM_GRAPHIC_H
00034 
00035 #include <boost/shared_ptr.hpp>
00036 
00037 #include <vector>
00038 #include <map>
00039 #include <string>
00040 
00041 namespace rcsc {
00042 
00047 class TeamGraphic {
00048 public:
00049 
00051     static const int MAX_WIDTH;
00053     static const int MAX_HEIGHT;
00055     static const int TILE_SIZE;
00057     static const int MAX_COLOR;
00058 
00059 
00064     class XpmTile {
00065     private:
00066         const int M_width; 
00067         const int M_height; 
00068         const int M_cpp; 
00069 
00071         std::vector< boost::shared_ptr< std::string > > M_colors;
00073         std::vector< std::string > M_pixel_lines;
00074 
00075         // not used
00076         XpmTile();
00077     public:
00078 
00086         XpmTile( const int width,
00087                  const int height,
00088                  const int cpp );
00089 
00094         int width() const
00095           {
00096               return M_width;
00097           }
00098 
00103         int height() const
00104           {
00105               return M_width;
00106           }
00107 
00112         int cpp() const
00113           {
00114               return M_cpp;
00115           }
00116 
00121         const
00122         std::vector< boost::shared_ptr< std::string > > & colors() const
00123           {
00124               return M_colors;
00125           }
00126 
00131         const
00132         std::vector< std::string > & pixelLines() const
00133           {
00134               return M_pixel_lines;
00135           }
00136 
00141         void addColor( boost::shared_ptr< std::string > color )
00142           {
00143               M_colors.push_back( color );
00144           }
00145 
00150         void addPixelLine( const std::string & line )
00151           {
00152               M_pixel_lines.push_back( line );
00153           }
00154 
00160         std::ostream & print( std::ostream & os ) const;
00161     };
00162 
00163 
00164     typedef boost::shared_ptr< XpmTile > Ptr; 
00165     typedef std::pair< int, int > Index; 
00166     typedef std::map< Index, Ptr > Map; 
00167 
00168 private:
00169     int M_width; 
00170     int M_height; 
00171     int M_cpp; 
00172 
00174     std::vector< boost::shared_ptr< std::string > > M_colors;
00175 
00177     Map M_tiles;
00178 
00179 public:
00180 
00184     TeamGraphic();
00185 
00189     void clear();
00190 
00195     int width() const
00196       {
00197           return M_width;
00198       }
00199 
00204     int height() const
00205       {
00206           return M_height;
00207       }
00208 
00213     const
00214     std::vector< boost::shared_ptr< std::string > > & colors() const
00215       {
00216           return M_colors;
00217       }
00218 
00223     const
00224     Map & tiles() const
00225       {
00226           return M_tiles;
00227       }
00228 
00234     bool createXpmTiles( const char * const * xpm_data );
00235 
00241     bool parse( const char * server_msg );
00242 
00243 private:
00244 
00250     boost::shared_ptr< std::string > findColor( const std::string & str );
00251 
00252 public:
00253 
00259     std::ostream & print( std::ostream & os ) const;
00260 };
00261 
00262 }
00263 
00264 #endif

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