/home/enzo/treballs/fib/pfc/nanocomp/src/simulation.hpp

Go to the documentation of this file.
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 
00031 #ifndef SIMULATION_HPP_
00032 #define SIMULATION_HPP_
00033 
00034 #include "simulationManager.hpp"
00035 #include "simulationView.hpp"
00036 #include <vector>
00037 #include <list>
00038 
00040 
00041 struct simulationStep
00042 {
00043     list <Grid> path; 
00044     Grid space; 
00045 };
00046 
00048 
00049 struct ruleApplying
00050 {
00051     Rule *rule; 
00052     coordinate c; 
00053 };
00054 
00055 using namespace std;
00056 
00057 class SimulationManager;
00058 
00059 class SimulationView;
00060 
00061 class Simulation
00062 {
00063 public:
00064         Simulation(SimulationView *view, SimulationManager *controller, Grid initialLayout, list<Rule> *rules, list<ForbiddenPattern> *patterns);
00065         virtual ~Simulation();
00066     bool isFinished();
00067     bool nextStep(bool gui);
00068     void nextRow();
00069     void results();
00070     void simulateAll();
00071     void resetSimulation(SimulationView *view, SimulationManager *controller, Grid initialLayout, list<Rule> *rules, list<ForbiddenPattern> *patterns);
00072     list<simulationStep> getStableLayouts();
00073     list<Grid> getProcessedLayouts();
00074     list<simulationStep> getForbiddenLayouts();
00075     list<simulationStep> getCycles();
00076 
00077 private:
00078     list<coordinate> findRule(Grid layout, Rule rule);
00079     list<coordinate> findPattern(Grid layout, ForbiddenPattern pattern);
00080     Grid applyRule(Grid layout, Rule rule, coordinate position);
00081     bool ruleApplicable(Grid layout, coordinate position, Rule rule);
00082     void printRule(Rule rule);
00083     void printLayout(Grid layout);
00084     bool find(Grid initialLayout, list<Grid> *processedLayouts);
00085     bool patternApplicable(Grid layout, coordinate position, ForbiddenPattern pattern);
00086     void updateView();
00088     SimulationView *view;
00090     SimulationManager *controller;
00092     list<simulationStep> *finalLayouts;
00094     list<simulationStep> *patternsToSimulate;
00096     list<Grid> *patternsSimulated;
00098     list<simulationStep> *forbiddenPatternsFound;
00100     list<simulationStep> *cycles;
00102     list<Rule> *rules;
00104     list<ForbiddenPattern> *patterns;
00106     bool finished;
00108     bool simulating;
00110     bool stillRows;
00111 };
00112 
00113 #endif /*SIMULATION_HPP_*/

Generated on Fri Sep 1 23:55:14 2006 for NanoComp by  doxygen 1.4.6