RuleManager Class Reference

Main controller for the rules. More...

#include <ruleManager.hpp>

Collaboration diagram for RuleManager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RuleManager (MainController *controller)
 Constructor.
virtual ~RuleManager ()
 Destructor.
void setView (RuleView *view)
 Sets the rule view.
void newRule (int width, int height)
 Creates a new rule.
void newRule (Rule *rule)
 Adds a new rule to the collection.
void ruleSelected (unsigned int ruleId)
 Selects a rule.
void cellChanged (GridType grid, int x, int y)
 Cell status change.
void removeRule ()
 Deletes the selected rule from the collection.
void copyGrids ()
 Copies the initial configuration of the selected rule to its final configuration.
bool saveFile ()
 Saves the rule collection.
bool saveFileAs ()
 Saves the rule collection to a specified file.
void openFile ()
 Opens a rule collection file.
bool openPFile (wxString file)
 Opens a rule collection file for a new project.
bool saveFilename (wxString file)
 Saves the rule collection to a file.
wxArrayString getRuleList ()
 Member accessor.
bool isModified ()
 Member accessor.
wxString getFileName ()
 Member accessor.
void clean ()
bool checkRules ()
 Checks the rule collection for invalid or repeated rules.
RulegetRule (unsigned int id)
 Returns a rule from the collection.

Private Member Functions

void updateGrids (bool changed)
 Updates the grids of the view to the selected rule.
void updateList ()
 Updates the view rule list.
void deleteRules ()
 Deletes all the rules from the collection.
bool appendRules (bool mustDeleteRules, bool newFile)
 Appends a rule file.

Private Attributes

RuleViewview
 Rule view.
FileManagerView fileView
 File System interation view.
RuleDiskManagerdiskManager
 Data persistance.
MainControllercontroller
 Main application controller.
map< unsigned int, Rule * > ruleList
 The rule collection.
unsigned int nextId
 Next identifier to be used for a new rule.
unsigned int currentRule
 Current selected rule.
bool modified
 Has been the collection been modified after saving?
bool needNewFile
 Do we need a filename for saving the rule collection?
wxString fileName
 FIlename of the rule collection.

Detailed Description

Main controller for the rules.

This class is the main controller for the rule collection. It manages it's view and data persistance layers and also provides services to the other controllers.

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

Definition at line 46 of file ruleManager.hpp.


Constructor & Destructor Documentation

RuleManager::RuleManager MainController controller  ) 
 

Constructor.

Parameters:
controller the main application controller.

Definition at line 29 of file ruleManager.cpp.

References controller, currentRule, diskManager, fileName, modified, needNewFile, and nextId.

RuleManager::~RuleManager  )  [virtual]
 

Destructor.

Definition at line 42 of file ruleManager.cpp.

References diskManager.


Member Function Documentation

bool RuleManager::appendRules bool  mustDeleteRules,
bool  newFile
[private]
 

Appends a rule file.

Parameters:
mustDeleteRules True if the existing rules hve to be deleted.
newFile If true, the opened filename is used as the new rule collection file name, if not, the current file name is mantained.
Returns:
True if the rules were correctly opened.

Definition at line 381 of file ruleManager.cpp.

References controller, currentRule, deleteRules(), diskManager, MainController::elementChanged(), fileName, fileView, modified, FileManagerView::openFileChoose(), RuleDiskManager::openRules(), ruleSelected(), RuleView::selectRule(), updateList(), and view.

Here is the call graph for this function:

void RuleManager::cellChanged GridType  grid,
int  x,
int  y
 

Cell status change.

Parameters:
grid the grid to be changed, can be the initial grid or the final grid.
x the x coordinate.
y the y coordinate.

Definition at line 101 of file ruleManager.cpp.

References controller, currentRule, MainController::elementChanged(), modified, nFINAL, nINITIAL, ruleList, and updateGrids().

Referenced by RuleView::OnClick().

Here is the call graph for this function:

bool RuleManager::checkRules  ) 
 

Checks the rule collection for invalid or repeated rules.

Returns:
True iif all the rules are valid and unique.

Definition at line 508 of file ruleManager.cpp.

References ruleList.

Referenced by RuleView::OnCheck(), and MainController::prepareSimulation().

void RuleManager::clean  ) 
 

Deletes the rule collection and cleans all the controller information.

Definition at line 491 of file ruleManager.cpp.

References controller, currentRule, deleteRules(), MainController::elementChanged(), fileName, modified, MainController::rulesChanged(), ruleSelected(), RuleView::selectRule(), updateList(), and view.

Referenced by MainController::newFile().

Here is the call graph for this function:

void RuleManager::copyGrids  ) 
 

Copies the initial configuration of the selected rule to its final configuration.

Definition at line 194 of file ruleManager.cpp.

References currentRule, ruleList, and updateGrids().

Referenced by RuleView::OnCopy().

Here is the call graph for this function:

void RuleManager::deleteRules  )  [private]
 

Deletes all the rules from the collection.

Definition at line 365 of file ruleManager.cpp.

References controller, currentRule, MainController::elementChanged(), nextId, and ruleList.

Referenced by appendRules(), clean(), openFile(), and openPFile().

Here is the call graph for this function:

wxString RuleManager::getFileName  ) 
 

Member accessor.

Returns:
The rule collection file name.

Definition at line 457 of file ruleManager.cpp.

References fileName.

Referenced by MainController::save(), and MainController::saveFileNames().

Rule * RuleManager::getRule unsigned int  id  ) 
 

Returns a rule from the collection.

Parameters:
id the rule identifier.
Returns:
A pointer to the rule identified by id.

Definition at line 563 of file ruleManager.cpp.

References ruleList.

Referenced by LayoutManager::getListRuleEnabled().

wxArrayString RuleManager::getRuleList  ) 
 

Member accessor.

Returns:
The rule collection list strings.

Definition at line 430 of file ruleManager.cpp.

References ruleList.

Referenced by LayoutManager::rulesChanged().

bool RuleManager::isModified  ) 
 

Member accessor.

Returns:
True if the collection was changed since last save.

Definition at line 447 of file ruleManager.cpp.

References modified.

Referenced by MainController::open().

void RuleManager::newRule Rule rule  ) 
 

Adds a new rule to the collection.

Parameters:
rule the rule to add.

Definition at line 415 of file ruleManager.cpp.

References controller, currentRule, MainController::elementChanged(), modified, nextId, ruleList, and MainController::rulesChanged().

Here is the call graph for this function:

void RuleManager::newRule int  width,
int  height
 

Creates a new rule.

Parameters:
width the rule width.
height the rule height.

Definition at line 53 of file ruleManager.cpp.

References controller, currentRule, MainController::elementChanged(), fileName, modified, needNewFile, nextId, ruleList, MainController::rulesChanged(), ruleSelected(), RuleView::selectRule(), RuleView::updateGrids(), updateList(), and view.

Referenced by RuleView::OnNewRule(), and RuleDiskManager::returnRules().

Here is the call graph for this function:

void RuleManager::openFile  ) 
 

Opens a rule collection file.

The user is asked to append the rules to the existing ones or overwrite them.

Definition at line 301 of file ruleManager.cpp.

References deleteRules(), modified, RuleView::msgYesNo(), ruleList, saveFile(), and view.

Referenced by RuleView::OnOpen().

Here is the call graph for this function:

bool RuleManager::openPFile wxString  file  ) 
 

Opens a rule collection file for a new project.

Parameters:
file the file name.
Returns:
True if the file is opened correctly.

Definition at line 350 of file ruleManager.cpp.

References controller, currentRule, deleteRules(), diskManager, MainController::elementChanged(), fileName, RuleDiskManager::openRules(), ruleSelected(), RuleView::selectRule(), updateList(), and view.

Here is the call graph for this function:

void RuleManager::removeRule  ) 
 

Deletes the selected rule from the collection.

Definition at line 142 of file ruleManager.cpp.

References currentRule, and ruleList.

Referenced by RuleView::OnRemove().

void RuleManager::ruleSelected unsigned int  ruleId  ) 
 

Selects a rule.

Parameters:
ruleId the rule identifier.

Definition at line 88 of file ruleManager.cpp.

References currentRule, and updateGrids().

Referenced by appendRules(), clean(), newRule(), RuleView::OnSelection(), and openPFile().

Here is the call graph for this function:

bool RuleManager::saveFile  ) 
 

Saves the rule collection.

If the collection has not been saved before, the user is asked for a file name.

Returns:
True if the file is saved correctly.

Definition at line 210 of file ruleManager.cpp.

References diskManager, fileName, fileView, modified, needNewFile, ruleList, FileManagerView::saveFileChoose(), RuleDiskManager::saveRules(), and view.

Referenced by RuleView::OnSave(), openFile(), MainController::save(), and MainController::saveAs().

Here is the call graph for this function:

bool RuleManager::saveFileAs  ) 
 

Saves the rule collection to a specified file.

Returns:
True if the file is saved correctly.

Definition at line 258 of file ruleManager.cpp.

References fileName, fileView, ruleList, FileManagerView::saveFileChoose(), and view.

Referenced by RuleView::OnSaveAs().

Here is the call graph for this function:

bool RuleManager::saveFilename wxString  file  ) 
 

Saves the rule collection to a file.

Parameters:
file the file to save.
Returns:
True if the rules were saved correctly.

Definition at line 468 of file ruleManager.cpp.

References ruleList.

Referenced by MainController::save().

void RuleManager::setView RuleView view  ) 
 

Sets the rule view.

Parameters:
view the rule view.

Definition at line 78 of file ruleManager.cpp.

References view.

void RuleManager::updateGrids bool  changed  )  [private]
 

Updates the grids of the view to the selected rule.

Parameters:
changed true if the selected rule has changed, false if only the grids have changed.

Definition at line 128 of file ruleManager.cpp.

References currentRule, ruleList, RuleView::updateGrids(), and view.

Referenced by cellChanged(), copyGrids(), and ruleSelected().

Here is the call graph for this function:

void RuleManager::updateList  )  [private]
 

Updates the view rule list.

Definition at line 179 of file ruleManager.cpp.

References ruleList.

Referenced by appendRules(), clean(), newRule(), and openPFile().


Member Data Documentation

MainController* RuleManager::controller [private]
 

Main application controller.

Definition at line 78 of file ruleManager.hpp.

Referenced by appendRules(), cellChanged(), clean(), deleteRules(), newRule(), openPFile(), and RuleManager().

unsigned int RuleManager::currentRule [private]
 

Current selected rule.

Definition at line 84 of file ruleManager.hpp.

Referenced by appendRules(), cellChanged(), clean(), copyGrids(), deleteRules(), newRule(), openPFile(), removeRule(), RuleManager(), ruleSelected(), and updateGrids().

RuleDiskManager* RuleManager::diskManager [private]
 

Data persistance.

Definition at line 76 of file ruleManager.hpp.

Referenced by appendRules(), openPFile(), RuleManager(), saveFile(), and ~RuleManager().

wxString RuleManager::fileName [private]
 

FIlename of the rule collection.

Definition at line 90 of file ruleManager.hpp.

Referenced by appendRules(), clean(), getFileName(), newRule(), openPFile(), RuleManager(), saveFile(), and saveFileAs().

FileManagerView RuleManager::fileView [private]
 

File System interation view.

Definition at line 74 of file ruleManager.hpp.

Referenced by appendRules(), saveFile(), and saveFileAs().

bool RuleManager::modified [private]
 

Has been the collection been modified after saving?

Definition at line 86 of file ruleManager.hpp.

Referenced by appendRules(), cellChanged(), clean(), isModified(), newRule(), openFile(), RuleManager(), and saveFile().

bool RuleManager::needNewFile [private]
 

Do we need a filename for saving the rule collection?

Definition at line 88 of file ruleManager.hpp.

Referenced by newRule(), RuleManager(), and saveFile().

unsigned int RuleManager::nextId [private]
 

Next identifier to be used for a new rule.

Definition at line 82 of file ruleManager.hpp.

Referenced by deleteRules(), newRule(), and RuleManager().

map<unsigned int, Rule*> RuleManager::ruleList [private]
 

The rule collection.

Definition at line 80 of file ruleManager.hpp.

Referenced by cellChanged(), checkRules(), copyGrids(), deleteRules(), getRule(), getRuleList(), newRule(), openFile(), removeRule(), saveFile(), saveFileAs(), saveFilename(), updateGrids(), and updateList().

RuleView* RuleManager::view [private]
 

Rule view.

Definition at line 72 of file ruleManager.hpp.

Referenced by appendRules(), clean(), newRule(), openFile(), openPFile(), saveFile(), saveFileAs(), setView(), and updateGrids().


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