/***************************************************************************
 *   Copyright (C) 2005 by Tavarez Arnaud Bakoula                          *
 *   tbakoula@yahoo.fr                                                     *
 *                                                                         *
 *   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.             *
 ***************************************************************************/
#include "siterow.h"
#include "site.h"
#include "utilities.h"

SiteRow::SiteRow( uint idx, uint sz )
    :  CellRow( idx, sz )
{
}

SiteRow::~SiteRow()
{
    // Nothing to do
}

/**
   This function create all the ticks of this manager. It must
   be called, once, after the instanciation of this object.
 */
void SiteRow::createCells()
{
    uint i=0;
    for ( ; i<dim; i++ )
    {
      Cell* cell = new Site( index, i );
      cell_list->push_back( cell );
      computePosition( cell, i );
    }
}

/**
   This function reset the state of all the site contained in
   this row.
 */
void SiteRow::reset()
{
    cell_iterator it = cell_list->begin();
    for ( ; it != cell_list->end(); it++ )
    {
      Site* site = static_cast<Site*>(*it);
      site->setColor( None );
      site->empty( TRUE );
    }
}

/**
   This function is a specific reimplementation used to add
   cells of type Site.
 */
void SiteRow::appendCells( uint ap )
{
    uint i=0;
    for ( ; i!=ap; i++ )
    {
      Cell* cell = new Site( index, dim+i );
      cell_list->push_back( cell );
      computePosition( cell, dim+i );
    }
    dim += ap;
}

void SiteRow::ready()
{
    cell_iterator it = cell_list->begin();
    for ( ; it != cell_list->end(); it++ )
    {
      Site* site = static_cast<Site*>(*it);
      site->setColor( Shade );
      site->empty( TRUE );
    }
}
