source/Model/MatrixCell.h
Go to the documentation of this file.
00001 
00006 #ifndef __MATRIXCELL_H__
00007 #define __MATRIXCELL_H__
00008 
00009 #include <vector>
00010 #include <string>
00011 
00012 #include "../Lib/Observer.h"
00013 #include "../Lib/CellAttribute.h"
00014 #include "../Lib/MatrixCellAttribute.h"
00015 #include "Cell.h"
00016 
00021 class MatrixCell : public Subject
00022 {
00023 public:
00027     MatrixCell(long i_lColMax, long i_lRowMax)
00028         {
00029                 this->init(i_lColMax, i_lRowMax);
00030         }
00031 
00035         virtual ~MatrixCell() { }
00036 
00042     void init(long i_lColMax, long i_lRowMax);
00043 
00049     long getColMax() const { return this->m_lColMax; }
00050 
00056     long getRowMax() const { return this->m_lRowMax; }
00057 
00064     Cell* getCell(long i_lCol, long i_lRow)
00065         {
00066                 Cell* a_pcCell = this->m_vecCellArray[i_lRow][i_lCol];
00067                 return a_pcCell;
00068         }
00069 
00077     void setCellState(long i_lCol, long i_lRow, CellAttribute::CELL_STATE i_eState)
00078         {
00079                 Cell* a_pcCell = this->getCell(i_lCol, i_lRow);
00080                 a_pcCell->setState(i_eState);
00081         }
00082 
00091     CellAttribute::CELL_STATE getCellState(long i_lCol, long i_lRow)
00092         {
00093                 Cell* a_pcCell = this->getCell(i_lCol, i_lRow);
00094                 CellAttribute::CELL_STATE a_eState = a_pcCell->getState();
00095                 return a_eState;
00096         }
00097 
00105     bool refreshCell();
00106 
00111         std::string dispAllCellState();
00112 
00117         std::string dispNeighborAliveCell();
00118 
00119 private:
00123     long m_lColMax;
00124 
00128     long m_lRowMax;
00129 
00133     std::vector< std::vector <Cell*> > m_vecCellArray;
00134 
00142     bool makeCell();
00143 
00149     bool linkCell();
00150 
00158         bool setNeighborCell(Cell* i_pcTargetCell, long i_lCol, long i_lRow);
00159 
00168         long check_region(long i_lValue, long i_lMax);
00169 
00177     bool sendStateToNeighborCell();
00178 
00186     bool decideNextGeneration();
00187 
00195     void setColMax(long i_lColMax){ this->m_lColMax = i_lColMax; }
00196 
00204         bool sendState(long i_lCol, long i_lRow, CellAttribute::CELL_STATE a_eState);
00205 
00213     void setRowMax(long i_lRowMax){ this->m_lRowMax = i_lRowMax; }
00214 
00215 };
00216 
00217 #endif  //__MATRIXCELL_H__
 All Classes Files Functions Variables Enumerations Enumerator Defines