00001 /* 00002 * * 00003 * This program is free software; you can redistribute it and/or modify * 00004 * it under the terms of the GNU General Public License as published by * 00005 * the Free Software Foundation; either version 2 of the License, or * 00006 * (at your option) any later version. * 00007 * * 00008 * This program is distributed in the hope that it will be useful, * 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00011 * GNU General Public License for more details. * 00012 * * 00013 * You should have received a copy of the GNU General Public License * 00014 * along with this program; if not, write to the * 00015 * Free Software Foundation, Inc., * 00016 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00017 */ 00018 00028 #ifndef RULE_HPP_ 00029 #define RULE_HPP_ 00030 00031 #include "grid.hpp" 00032 #include <vector> 00033 00035 00036 enum GridType 00037 { 00038 nINITIAL, 00039 nFINAL 00040 }; 00041 00042 using namespace std; 00043 00044 typedef vector< vector<int> > matrix; 00045 00046 class Rule 00047 { 00048 public: 00049 Rule(int width, int height); 00050 virtual ~Rule(); 00051 bool operator ==(Rule rule); 00052 bool cellChanged(int x, int y, int status, GridType layout); 00053 Grid getInitialGrid(); 00054 void setInitialGrid(Grid newGrid); 00055 Grid getFinalGrid(); 00056 void setFinalGrid(Grid newGrid); 00057 bool cellChanged(int x, int y, GridType layout); 00058 int getWidth(); 00059 int getHeight(); 00060 bool equals(Rule *rule); 00061 bool sameInitialFinal(); 00062 bool valid(); 00063 void print(); 00064 matrix getInitialMatrix(); 00065 matrix getFinalMatrix(); 00066 00067 private: 00069 int width; 00071 int height; 00073 Grid initialGrid; 00075 Grid finalGrid; 00076 }; 00077 00078 #endif /*RULE_HPP_*/