/* This file is part of cardwords
   (c) 1998 1999 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
*/

#ifndef CARDWORDS_CARDSELECTION_HH
#define CARDWORDS_CARDSELECTION_HH

#include <vector>
#include "cardwords_carddescription.hh"
#include "cardwords_iostream.hh"
#include "cardwords_cardcontainer1dim.hh"
#include "cardwords_string.hh"

/*
  A cardselection is similar to a one-dimenional card-container, except for:
  - A selection is no "physical" object, but an object in mind. Therefor,
    it contains CardWords_CardDescriptions instead of CardWords_Cards.
  - It has no fixed length.

  The purpose of card selections: base class for Trade-ins and
  moves to the table
*/

/* The input/output format of CardWords_CardSelection:
   N <N times CardWords_CardDescriptions>
   N is the number of cards in the selection
   The input/output format of CardWords_CardDescriptions is described in
   the file cardwords_cardbase.hh.
*/


class CardWords_CardSelection : public vector<CardWords_CardDescription> {
public:
  CardWords_CardSelection (istream &);

  CardWords_CardSelection ();

  CardWords_CardSelection & operator +=(const CardWords_CardBase &);
  CardWords_CardSelection & operator +=(const CardWords_CardSelection &);

  CardWords_CardSelection & operator=(const CardWords_CardBase &);

  void clear(void);
}
;

inline
void 
CardWords_CardSelection::clear(void)
{
  erase (begin(),end());
}


istream & operator >>( istream &, CardWords_CardSelection &);
ostream & operator <<( ostream &, const CardWords_CardSelection &);

inline
CardWords_CardSelection::CardWords_CardSelection (istream & istream)
{
  istream >> *this;
}
inline
CardWords_CardSelection::CardWords_CardSelection ()
{}

inline
CardWords_CardSelection &
CardWords_CardSelection::operator += (const CardWords_CardBase & t)
{
  push_back (t);
  return *this;
}

inline
CardWords_CardSelection &
CardWords_CardSelection::operator += (const CardWords_CardSelection & other)
{
  back_insert_iterator<CardWords_CardSelection> dest(*this);

  copy (other.begin(), other.end(), dest);
  return *this;
}

inline
CardWords_CardSelection &
CardWords_CardSelection::operator=(const CardWords_CardBase & t)
{
  clear();
  return (*this) += t;
}

#endif

