Grid Class Reference

Class representing the spaces. More...

#include <grid.hpp>

List of all members.

Public Member Functions

 Grid ()
 Constructor.
 Grid (matrix newList)
 Constructor.
 Grid (int w, int h)
 Constructor.
virtual ~Grid ()
 Destructor.
int getWidth () const
 Member accessor.
int getHeight () const
 Member accessor.
matrix getCells () const
 Member accessor.
void init (const Grid &grid)
 Initializes the grid.
bool operator== (Grid grid)
 Equality operator.
int & operator() (int x, int y)
 Cell accessor.
bool isEnabled (int x, int y)
 Cell status.
bool isDisabled (int x, int y)
 Cell status.
bool isInput (int x, int y)
 Cell status.
bool isOutput (int x, int y)
 Cell status.
bool isSpace (int x, int y)
 Cell status.

Private Attributes

matrix cells
 Matrix of cells.
int width
 Grid width.
int height
 Grid height.


Detailed Description

Class representing the spaces.

The Grid class is the main class for spaces, forbidden patterns and rules, as all of them are a composition of one of two grids.

Author:
Bernat Rāfales Mulet <the_bell@users.sourceforge.net>
Version:
Revision
1.13

Definition at line 53 of file grid.hpp.


Constructor & Destructor Documentation

Grid::Grid  ) 
 

Constructor.

Creates a default grid with width and height of zero.

Definition at line 31 of file grid.cpp.

References height, and width.

Grid::Grid matrix  newList  ) 
 

Constructor.

Parameters:
newList matrix of cells.

Definition at line 61 of file grid.cpp.

References cells, height, and width.

Grid::Grid int  w,
int  h
 

Constructor.

Parameters:
w width of the grid.
h height of the grid.

Definition at line 43 of file grid.cpp.

References cells, height, and width.

Grid::~Grid  )  [virtual]
 

Destructor.

Definition at line 70 of file grid.cpp.


Member Function Documentation

matrix Grid::getCells  )  const
 

Member accessor.

Returns:
The grid in a matrix form.

Definition at line 177 of file grid.cpp.

References cells.

Referenced by ForbiddenPattern::equals(), Rule::getFinalMatrix(), Rule::getInitialMatrix(), LayoutConfig::getMatrix(), ForbiddenPattern::getMatrix(), and init().

int Grid::getHeight  )  const
 

Member accessor.

Returns:
The grid height.

Definition at line 92 of file grid.cpp.

References height.

Referenced by SimulationManager::addPattern(), SimulationManager::addRule(), LayoutCanvas::drawCells(), Simulation::findPattern(), Simulation::findRule(), init(), LayoutCanvas::initTransitions(), LayoutCanvas::resetTransitions(), RuleDiskManager::saveGrid(), LayoutDiskManager::saveGrid(), ForbiddenPatternDiskManager::saveGrid(), LayoutCanvas::setGrid(), and ForbiddenPattern::setGrid().

int Grid::getWidth  )  const
 

Member accessor.

Returns:
The grid width

Definition at line 102 of file grid.cpp.

References width.

Referenced by SimulationManager::addPattern(), SimulationManager::addRule(), LayoutCanvas::drawCells(), Simulation::findPattern(), Simulation::findRule(), init(), LayoutCanvas::initTransitions(), operator==(), Simulation::patternApplicable(), Simulation::printLayout(), SimulationManager::printPattern(), SimulationManager::rotateGrid(), Simulation::ruleApplicable(), RuleDiskManager::saveGrid(), LayoutDiskManager::saveGrid(), ForbiddenPatternDiskManager::saveGrid(), LayoutCanvas::setGrid(), and ForbiddenPattern::setGrid().

void Grid::init const Grid grid  ) 
 

Initializes the grid.

Parameters:
grid the grid to be set.

Definition at line 80 of file grid.cpp.

References cells, getCells(), getHeight(), getWidth(), height, and width.

Referenced by Rule::setFinalGrid(), LayoutCanvas::setGrid(), ForbiddenPattern::setGrid(), and Rule::setInitialGrid().

Here is the call graph for this function:

bool Grid::isDisabled int  x,
int  y
 

Cell status.

Allows to know the status of the cell at x, y.

Parameters:
x x coordinate.
y y coordinate.
Returns:
True iif the cell at x, y has the status nDISABLED.

Definition at line 128 of file grid.cpp.

References cells, and nDISABLED.

bool Grid::isEnabled int  x,
int  y
 

Cell status.

Allows to know the status of the cell at x, y.

Parameters:
x x coordinate.
y y coordinate.
Returns:
True iif the cell at x, y has the status nENABLED.

Definition at line 115 of file grid.cpp.

References cells, and nENABLED.

bool Grid::isInput int  x,
int  y
 

Cell status.

Allows to know the status of the cell at x, y.

Parameters:
x x coordinate.
y y coordinate.
Returns:
True iif the cell at x, y has the status nINPUT.

Definition at line 141 of file grid.cpp.

References cells, and nINPUT.

bool Grid::isOutput int  x,
int  y
 

Cell status.

Allows to know the status of the cell at x, y.

Parameters:
x x coordinate.
y y coordinate.
Returns:
True iif the cell at x, y has the status nOUTPUT.

Definition at line 154 of file grid.cpp.

References cells, and nOUTPUT.

bool Grid::isSpace int  x,
int  y
 

Cell status.

Allows to know the status of the cell at x, y.

Parameters:
x x coordinate.
y y coordinate.
Returns:
True iif the cell at x, y has the status nNOSPACE.

Definition at line 167 of file grid.cpp.

References cells, and nNOSPACE.

int & Grid::operator() int  x,
int  y
 

Cell accessor.

Special operator to get a reference to a cell. Using this the status of a cell can be inspected this way: int status = grid(x, y) or modified the same way: grid(x, y) = nENABLED.

Parameters:
x x coordinate.
y y coordinate.
Returns:
Reference to the cell at x, y.

Definition at line 192 of file grid.cpp.

References cells.

bool Grid::operator== Grid  grid  ) 
 

Equality operator.

Parameters:
grid the grid to be compared to.
Returns:
True iif the grid equals to the parameter. This is if the grids have the same width and height and if all cells of the grids have the same status.

Definition at line 205 of file grid.cpp.

References getWidth().

Here is the call graph for this function:


Member Data Documentation

matrix Grid::cells [private]
 

Matrix of cells.

Definition at line 74 of file grid.hpp.

Referenced by getCells(), Grid(), init(), isDisabled(), isEnabled(), isInput(), isOutput(), isSpace(), and operator()().

int Grid::height [private]
 

Grid height.

Definition at line 78 of file grid.hpp.

Referenced by getHeight(), Grid(), and init().

int Grid::width [private]
 

Grid width.

Definition at line 76 of file grid.hpp.

Referenced by getWidth(), Grid(), and init().


The documentation for this class was generated from the following files:
Generated on Fri Sep 1 23:57:19 2006 for NanoComp by  doxygen 1.4.6