SimulationManager Class Reference

Main controller for the simulation. More...

#include <simulationManager.hpp>

Collaboration diagram for SimulationManager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SimulationManager (MainController *controller, TruthTableManager *tableManager, ForbiddenPatternManager *FPManager, RuleManager *ruleManager, LayoutManager *layoutManager)
 Constructor.
virtual ~SimulationManager ()
 Destructor.
void prepareSimulation ()
 Prepares and starts a simulation.
void startSimulation ()
 Starts a simulation.
bool nextRow ()
 Asks for new rows to simulate.
void simulateRow ()
 Simulates the current row.
void finishedRow ()
 Gathers the simulation data from the simulated row.
void results ()
 Shows the simulation results.
void rowSelected (int row)
 Selects a row to show it's results.
void informationSelected (int information)
 Selects a row event to show it's results.
void pathSelected (int path)
 Selects a simulation step to show it's results.

Private Member Functions

void addRule (Rule newRule)
 Adds a rule and its rotations to the rule list.
void addPattern (ForbiddenPattern newPattern)
 Adds a pattern and its rotations to the pattern list.
bool findRule (Rule rule)
 Finds a rule in the collection.
bool findPattern (ForbiddenPattern pattern)
 Finds a pattern in the collection.
void printRule (Rule rule)
 Prints a rule to the standard output.
void printPattern (Grid pattern)
 Prints a pattern to the standard output.
bool rotateGrid (Grid originalGrid, Grid *destGrid)
 Rotates a grid 60 degrees.
void rotateHexCoordinate (int center, int i, int j, int *ii, int *jj)
 Rotates a coordinate of a grid 60 degrees.
void updateRowList ()
 Updates the results view row list.
void updateInformationList ()
 Updates the results view event list.
void updatePathList ()
 Updates the results view simulation step list.
void updateGrid ()
 Sets the results view grid corresponding to the simulation step selected.
bool verifyRow (int row)
 Checks if a row simulation verifies the truth table.
bool verifyGrid (int row, Grid g)
 Verifies if a grid has the correct output values for a table and a row.

Private Attributes

TruthTableManagertableManager
 Truth table controller.
ForbiddenPatternManagerFPManager
 Forbidden pattern controller.
RuleManagerruleManager
 Rule controller.
LayoutManagerlayoutManager
 Space controller.
MainControllercontroller
 Main application controller.
list< Rulerules
 Rules to use for simulating.
list< ForbiddenPatternpatterns
 Forbidden patterns to use for simulating.
TruthTable table
 Truth table to simulate.
matrix layout
 Space to be simulated.
vector< coordinatetableInputs
 Input coordinates for the truth table.
vector< coordinatetableOutputs
 Output coordinates for the truth table.
vector< list< Grid > > processedLayouts
 List of simulated spaces for every table row.
vector< list< simulationStep > > finalLayouts
 List of stable spaces reached for every table row.
vector< list< simulationStep > > forbiddenLayouts
 List of forbidden pattern spaces reached for every table row.
vector< list< simulationStep > > cycles
 List of cycles found for every table row.
int row
 Row being simulated.
SimulationViewview
 Simulation presentation layer.
ResultsViewresultsView
 Results presentation layer.
Simulationsimulation
 Simulation.
int rRow
 Results row selected.
int rInformation
 Results event selected.
int rPath
 Results simulation step selected.
Grid initialGrid
 Initial space.

Detailed Description

Main controller for the simulation.

This class manages the simulation. Basically it prepares and checks the simulations and creates the necessary Simulation objects to proceed. It also controlls them and shows the results for the simulations.

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

Definition at line 54 of file simulationManager.hpp.


Constructor & Destructor Documentation

SimulationManager::SimulationManager MainController controller,
TruthTableManager tableManager,
ForbiddenPatternManager FPManager,
RuleManager ruleManager,
LayoutManager layoutManager
 

Constructor.

Parameters:
controller the main application controller.
tableManager the truth table controller.
FPManager the forbidden pattern controller.
ruleManager the rule controller.
layoutManager the space controller.

Definition at line 31 of file simulationManager.cpp.

References controller, FPManager, layoutManager, ruleManager, and tableManager.

SimulationManager::~SimulationManager  )  [virtual]
 

Destructor.

Definition at line 42 of file simulationManager.cpp.


Member Function Documentation

void SimulationManager::addPattern ForbiddenPattern  newPattern  )  [private]
 

Adds a pattern and its rotations to the pattern list.

Parameters:
newPattern pattern to add.

Definition at line 146 of file simulationManager.cpp.

References findPattern(), Grid::getHeight(), Grid::getWidth(), patterns, and rotateGrid().

Here is the call graph for this function:

void SimulationManager::addRule Rule  newRule  )  [private]
 

Adds a rule and its rotations to the rule list.

Parameters:
newRule rule to add.

Definition at line 102 of file simulationManager.cpp.

References findRule(), Grid::getHeight(), Grid::getWidth(), rotateGrid(), and rules.

Referenced by prepareSimulation().

Here is the call graph for this function:

bool SimulationManager::findPattern ForbiddenPattern  pattern  )  [private]
 

Finds a pattern in the collection.

Parameters:
pattern the pattern to be found.
Returns:
True if the pattern was found on the collection.

Definition at line 202 of file simulationManager.cpp.

References patterns.

Referenced by addPattern().

bool SimulationManager::findRule Rule  rule  )  [private]
 

Finds a rule in the collection.

Parameters:
rule the rule to be found.
Returns:
True if the rule was found on the collection.

Definition at line 184 of file simulationManager.cpp.

References rules.

Referenced by addRule().

void SimulationManager::finishedRow  ) 
 

Gathers the simulation data from the simulated row.

Definition at line 417 of file simulationManager.cpp.

References cycles, finalLayouts, forbiddenLayouts, Simulation::getCycles(), Simulation::getForbiddenLayouts(), Simulation::getProcessedLayouts(), Simulation::getStableLayouts(), processedLayouts, row, and simulation.

Here is the call graph for this function:

void SimulationManager::informationSelected int  information  ) 
 

Selects a row event to show it's results.

Parameters:
information the event to select.

Definition at line 469 of file simulationManager.cpp.

References rInformation, rPath, updateGrid(), updateInformationList(), and updatePathList().

Referenced by ResultsView::OnInformationSelected().

Here is the call graph for this function:

bool SimulationManager::nextRow  ) 
 

Asks for new rows to simulate.

Returns:
True iif there are more rows to simulate. False if all rows have been already simulated.

Definition at line 370 of file simulationManager.cpp.

References row, and tableInputs.

Referenced by Simulation::nextRow(), Simulation::simulateAll(), simulateRow(), and Simulation::updateView().

void SimulationManager::pathSelected int  path  ) 
 

Selects a simulation step to show it's results.

Parameters:
path the simulation step.

Definition at line 483 of file simulationManager.cpp.

References rPath, updateGrid(), and updatePathList().

Referenced by ResultsView::OnPathSelected().

Here is the call graph for this function:

void SimulationManager::prepareSimulation  ) 
 

Prepares and starts a simulation.

This method gathers all the information needed to do a simulation and initializes all the important data structures to do a simulation, and then it starts it.

Definition at line 53 of file simulationManager.cpp.

References addRule(), LayoutConfig::getGrid(), LayoutManager::getLayout(), LayoutManager::getListFPEnabled(), LayoutManager::getListRuleEnabled(), LayoutConfig::getMatrix(), TruthTable::getName(), LayoutManager::getTableInput(), LayoutManager::getTableOutput(), LayoutManager::getTableSelected(), initialGrid, layout, layoutManager, patterns, rules, table, tableInputs, and tableOutputs.

Referenced by MainController::startSimulation().

Here is the call graph for this function:

void SimulationManager::printPattern Grid  pattern  )  [private]
 

Prints a pattern to the standard output.

Parameters:
pattern the pattern to be printed.

Definition at line 256 of file simulationManager.cpp.

References Grid::getWidth().

Here is the call graph for this function:

void SimulationManager::printRule Rule  rule  )  [private]
 

Prints a rule to the standard output.

Parameters:
rule the rule to be printed.

Definition at line 219 of file simulationManager.cpp.

References Rule::getWidth().

Here is the call graph for this function:

void SimulationManager::results  ) 
 

Shows the simulation results.

Definition at line 428 of file simulationManager.cpp.

References controller, MainController::getNanoFrame(), initialGrid, resultsView, rInformation, rPath, rRow, ResultsView::setInputs(), ResultsView::setOutputs(), ResultsView::setTable(), table, tableInputs, tableOutputs, updateGrid(), updateInformationList(), ResultsView::updateInitialGrid(), updatePathList(), and updateRowList().

Referenced by Simulation::results().

Here is the call graph for this function:

bool SimulationManager::rotateGrid Grid  originalGrid,
Grid destGrid
[private]
 

Rotates a grid 60 degrees.

Parameters:
originalGrid the grid to be rotated.
destGrid grid where the original rotated have to be copied.
Returns:
True if the grid is rotated correctly.

Definition at line 279 of file simulationManager.cpp.

References Grid::getWidth(), and nDONTCARE.

Referenced by addPattern(), and addRule().

Here is the call graph for this function:

void SimulationManager::rotateHexCoordinate int  center,
int  i,
int  j,
int *  ii,
int *  jj
[private]
 

Rotates a coordinate of a grid 60 degrees.

Parameters:
center the central coordinate of the grid.
i the x original coordinate.
j the y original coordinate.
ii the x destination coordinate.
jj the y destination coordinate.

Definition at line 329 of file simulationManager.cpp.

void SimulationManager::rowSelected int  row  ) 
 

Selects a row to show it's results.

Parameters:
row the row to select.

Definition at line 453 of file simulationManager.cpp.

References rInformation, rPath, rRow, updateGrid(), updateInformationList(), updatePathList(), and updateRowList().

Referenced by ResultsView::OnRowsSelected().

Here is the call graph for this function:

void SimulationManager::simulateRow  ) 
 

Simulates the current row.

Definition at line 377 of file simulationManager.cpp.

References finalLayouts, LayoutManager::getLayout(), LayoutConfig::getMatrix(), layout, layoutManager, nDISABLED, nENABLED, nextRow(), row, tableInputs, and tableOutputs.

Referenced by Simulation::nextRow(), Simulation::simulateAll(), and startSimulation().

Here is the call graph for this function:

void SimulationManager::startSimulation  ) 
 

Starts a simulation.

This MUST NOT be called if all the simulation information is prepared and valid.

Definition at line 359 of file simulationManager.cpp.

References simulateRow().

Here is the call graph for this function:

void SimulationManager::updateGrid  )  [private]
 

Sets the results view grid corresponding to the simulation step selected.

Definition at line 600 of file simulationManager.cpp.

References forbiddenLayouts, and rInformation.

Referenced by informationSelected(), pathSelected(), results(), and rowSelected().

void SimulationManager::updateInformationList  )  [private]
 

Updates the results view event list.

Definition at line 517 of file simulationManager.cpp.

References forbiddenLayouts, and rRow.

Referenced by informationSelected(), results(), and rowSelected().

void SimulationManager::updatePathList  )  [private]
 

Updates the results view simulation step list.

Definition at line 549 of file simulationManager.cpp.

References forbiddenLayouts, simulationStep::path, and rInformation.

Referenced by informationSelected(), pathSelected(), results(), and rowSelected().

void SimulationManager::updateRowList  )  [private]
 

Updates the results view row list.

Definition at line 492 of file simulationManager.cpp.

References tableInputs, and verifyRow().

Referenced by results(), and rowSelected().

Here is the call graph for this function:

bool SimulationManager::verifyGrid int  row,
Grid  g
[private]
 

Verifies if a grid has the correct output values for a table and a row.

Parameters:
row the row to check.
g the grid to check.
Returns:
True if the grid verifies the row, false otherwise.

Definition at line 684 of file simulationManager.cpp.

References TruthTable::getOutput(), nDISABLED, nENABLED, table, tableInputs, and tableOutputs.

Referenced by verifyRow().

Here is the call graph for this function:

bool SimulationManager::verifyRow int  row  )  [private]
 

Checks if a row simulation verifies the truth table.

Parameters:
row the row to check.
Returns:
True if the row verifies the table, false otherwise.

Definition at line 656 of file simulationManager.cpp.

References finalLayouts, forbiddenLayouts, and verifyGrid().

Referenced by updateRowList().

Here is the call graph for this function:


Member Data Documentation

MainController* SimulationManager::controller [private]
 

Main application controller.

Definition at line 94 of file simulationManager.hpp.

Referenced by results(), and SimulationManager().

vector< list<simulationStep> > SimulationManager::cycles [private]
 

List of cycles found for every table row.

Definition at line 115 of file simulationManager.hpp.

Referenced by finishedRow().

vector< list<simulationStep> > SimulationManager::finalLayouts [private]
 

List of stable spaces reached for every table row.

Definition at line 111 of file simulationManager.hpp.

Referenced by finishedRow(), simulateRow(), and verifyRow().

vector< list<simulationStep> > SimulationManager::forbiddenLayouts [private]
 

List of forbidden pattern spaces reached for every table row.

Definition at line 113 of file simulationManager.hpp.

Referenced by finishedRow(), updateGrid(), updateInformationList(), updatePathList(), and verifyRow().

ForbiddenPatternManager* SimulationManager::FPManager [private]
 

Forbidden pattern controller.

Definition at line 88 of file simulationManager.hpp.

Referenced by SimulationManager().

Grid SimulationManager::initialGrid [private]
 

Initial space.

Definition at line 131 of file simulationManager.hpp.

Referenced by prepareSimulation(), and results().

matrix SimulationManager::layout [private]
 

Space to be simulated.

Definition at line 103 of file simulationManager.hpp.

Referenced by prepareSimulation(), and simulateRow().

LayoutManager* SimulationManager::layoutManager [private]
 

Space controller.

Definition at line 92 of file simulationManager.hpp.

Referenced by prepareSimulation(), simulateRow(), and SimulationManager().

list<ForbiddenPattern> SimulationManager::patterns [private]
 

Forbidden patterns to use for simulating.

Definition at line 99 of file simulationManager.hpp.

Referenced by addPattern(), findPattern(), and prepareSimulation().

vector< list<Grid> > SimulationManager::processedLayouts [private]
 

List of simulated spaces for every table row.

Definition at line 109 of file simulationManager.hpp.

Referenced by finishedRow().

ResultsView* SimulationManager::resultsView [private]
 

Results presentation layer.

Definition at line 121 of file simulationManager.hpp.

Referenced by results().

int SimulationManager::rInformation [private]
 

Results event selected.

Definition at line 127 of file simulationManager.hpp.

Referenced by informationSelected(), results(), rowSelected(), updateGrid(), and updatePathList().

int SimulationManager::row [private]
 

Row being simulated.

Definition at line 117 of file simulationManager.hpp.

Referenced by finishedRow(), nextRow(), and simulateRow().

int SimulationManager::rPath [private]
 

Results simulation step selected.

Definition at line 129 of file simulationManager.hpp.

Referenced by informationSelected(), pathSelected(), results(), and rowSelected().

int SimulationManager::rRow [private]
 

Results row selected.

Definition at line 125 of file simulationManager.hpp.

Referenced by results(), rowSelected(), and updateInformationList().

RuleManager* SimulationManager::ruleManager [private]
 

Rule controller.

Definition at line 90 of file simulationManager.hpp.

Referenced by SimulationManager().

list<Rule> SimulationManager::rules [private]
 

Rules to use for simulating.

Definition at line 97 of file simulationManager.hpp.

Referenced by addRule(), findRule(), and prepareSimulation().

Simulation* SimulationManager::simulation [private]
 

Simulation.

Definition at line 123 of file simulationManager.hpp.

Referenced by finishedRow().

TruthTable SimulationManager::table [private]
 

Truth table to simulate.

Definition at line 101 of file simulationManager.hpp.

Referenced by prepareSimulation(), results(), and verifyGrid().

vector<coordinate> SimulationManager::tableInputs [private]
 

Input coordinates for the truth table.

Definition at line 105 of file simulationManager.hpp.

Referenced by nextRow(), prepareSimulation(), results(), simulateRow(), updateRowList(), and verifyGrid().

TruthTableManager* SimulationManager::tableManager [private]
 

Truth table controller.

Definition at line 86 of file simulationManager.hpp.

Referenced by SimulationManager().

vector<coordinate> SimulationManager::tableOutputs [private]
 

Output coordinates for the truth table.

Definition at line 107 of file simulationManager.hpp.

Referenced by prepareSimulation(), results(), simulateRow(), and verifyGrid().

SimulationView* SimulationManager::view [private]
 

Simulation presentation layer.

Definition at line 119 of file simulationManager.hpp.


The documentation for this class was generated from the following files:
Generated on Sat Sep 2 00:00:44 2006 for NanoComp by  doxygen 1.4.6