rack.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 1999-2005 Eliot
00003  * Authors: Antoine Fraboulet <antoine.fraboulet@free.fr>
00004  *          Olivier Teuliere  <ipkiss@via.ecp.fr>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  *****************************************************************************/
00020 
00021 /**
00022  *  \file   rack.h
00023  *  \brief  Rack class : multiset of tiles
00024  *  \author Antoine Fraboulet & Olivier Teuliere
00025  *  \date   2002 - 2005
00026  */
00027 
00028 #ifndef _RACK_H_
00029 #define _RACK_H_
00030 
00031 #include "tile.h"
00032 #include <set>
00033 #include <list>
00034 #include <string>
00035 
00036 using namespace std;
00037 
00038 
00039 /**
00040  * A rack is a set of tiles, no more.
00041  * Tiles have to be in the bag for the rack to be valid.
00042  */
00043 class Rack
00044 {
00045 public:
00046     Rack() {}
00047     virtual ~Rack() {}
00048 
00049     int nTiles() const          { return m_tiles.size(); }
00050     bool isEmpty() const        { return nTiles() == 0; }
00051 
00052     unsigned int in(const Tile &t) const { return m_tiles.count(t); }
00053     void add(const Tile &t)     { m_tiles.insert(t); }
00054     void remove(const Tile &t);
00055     void clear()                { m_tiles.clear(); }
00056     void getTiles(list<Tile> &oTiles) const;
00057 
00058     string toString();
00059 
00060 private:
00061     multiset<Tile> m_tiles;
00062 };
00063 
00064 #endif
00065 
00066 /// Local Variables:
00067 /// mode: c++
00068 /// mode: hs-minor
00069 /// c-basic-offset: 4
00070 /// indent-tabs-mode: nil
00071 /// End:

Generated on Thu Dec 29 02:01:14 2005 for Eliot by  doxygen 1.4.5