/* This file is part of cardwords
   (c) 1998 1999 2000 Tobias Peters
   see file COPYING for the copyright terms.
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// cardwords_cardcontainer2dim.hh

#ifndef CARDWORDS_CARDCONTAINER2DIM_HH
#define CARDWORDS_CARDCONTAINER2DIM_HH

#include "cardwords_cardcontainer.hh"
#include <map>
#include "cardwords_matrix.hh"

namespace CardWords {
class CardContainer2Dim
  : public CardContainer,
    public map<Card*, CardTableLocation>
// Since every Card has its own place in memory,
// it is possible to compare the pointers directly. This is sufficient
// for a set or map.
{
public:
  // remove a special card from the container:
  virtual
  void
  remove_card (Card *);
    
  // add a card to the container:
  virtual
  void
  add_card (Card*, CardTableLocation);

  virtual
  void
  add_card (Card* t,
            size_t coordinate1,
            size_t coordinate2);

  // remove all cards and put them into pile:
  virtual
  void
  clear(class CardContainer1Dim *pile);

  CardContainer2Dim (size_t width, size_t height);

  // the destructor automatically deletes all contained cards:
  virtual
  ~CardContainer2Dim ();

  Card *
  operator[] (const CardTableLocation &) const;

  Card *
  operator() (size_t column, size_t row) const;

  Card * &
  operator [] (const CardTableLocation &);

  Card * &
  operator () (size_t column, size_t row);

  const CardTableLocation &
  operator[] (Card *) const;

  size_t
  get_width(void) const;

  size_t
  get_height(void) const;

private:
  size_t width;
  size_t height;
  Matrix<Card *> cardPointers;
};
}
#endif

