TruthTable Class Reference

Model class for a truth table. More...

#include <truthTable.hpp>

List of all members.

Public Member Functions

 TruthTable (wxString name, int inputs, int outputs)
 Constructor.
 TruthTable ()
 Constructor.
virtual ~TruthTable ()
 Destructor.
vector< bool > getOutput (vector< bool > input)
 Returns the outputs for a given input.
wxString getOutput (wxString input)
 Returns the outputs of an input combination.
bool getOutput (vector< bool > input, int output)
 Returns a concrete output of an input combination.
bool getOutput (wxString input, int output)
 Returns a concrete output of an input combination.
wxString getName ()
 Returns the name of the table.
void setOutput (vector< bool > input, vector< bool > output)
 Sets the output values for an input combination.
void setOutput (wxString input, wxString output)
 Sets the output values for an input combination.
void setName (wxString newName)
 Sets the name of the table.
void setTable (vector< vector< bool > > table)
 Sets the table values.
int getInputs ()
 Returns the number of inputs of the table.
int getOutputs ()
 Returns the number of outputs of the table.
void copyTable (TruthTable newTable)
 Copies the contents of a table.
vector< vector< bool > > getTable ()
 Returns the table.

Private Member Functions

int getIndex (vector< bool >input)
 Maps an input combination to an index to access the table outputs.
int getIndex (wxString input)
 Maps an input combination to an index to access the table outputs.
vector< bool > stringToVector (wxString input)
 Converts a string to a vector.
wxString vectorToString (vector< bool > input)
 Converts a vector to a string.

Private Attributes

wxString name
 Truth table name.
int inputs
 Truth table inputs.
int outputs
 Truth table outputs.
vector< vector< bool > > table


Detailed Description

Model class for a truth table.

This is a class representing a truth table.

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

Definition at line 36 of file truthTable.hpp.


Constructor & Destructor Documentation

TruthTable::TruthTable wxString  name,
int  inputs,
int  outputs
 

Constructor.

Parameters:
name the table name.
inputs the table number of inputs.
outputs the table number of outputs.

Definition at line 31 of file truthTable.cpp.

References table.

TruthTable::TruthTable  ) 
 

Constructor.

Builds an empty table.

Definition at line 55 of file truthTable.cpp.

References inputs, and outputs.

TruthTable::~TruthTable  )  [virtual]
 

Destructor.

Definition at line 63 of file truthTable.cpp.


Member Function Documentation

void TruthTable::copyTable TruthTable  newTable  ) 
 

Copies the contents of a table.

Parameters:
newTable table to be copied.

Definition at line 270 of file truthTable.cpp.

References getInputs(), getName(), getOutputs(), getTable(), inputs, name, outputs, and table.

Referenced by TruthTableCanvas::setNewTable().

Here is the call graph for this function:

int TruthTable::getIndex wxString  input  )  [private]
 

Maps an input combination to an index to access the table outputs.

It's a converter between decimal and binary sistems because this is the way the class it's implemented: the inputs are reproduced and the outputs are accessed using indexes.

Parameters:
input the input combination in string form.
Returns:
The table index corresponding to the input combination.
See also:
getIndex(vector<bool> input)

Definition at line 198 of file truthTable.cpp.

References getIndex(), and stringToVector().

Here is the call graph for this function:

int TruthTable::getIndex vector< bool >  input  )  [private]
 

Maps an input combination to an index to access the table outputs.

It's a converter between decimal and binary sistems because this is the way the class it's implemented: the inputs are reproduced and the outputs are accessed using indexes.

Parameters:
input the input combination.
Returns:
The table index corresponding to the input combination.
See also:
getIndex(wxString input)

Definition at line 88 of file truthTable.cpp.

Referenced by getIndex(), getOutput(), and setOutput().

int TruthTable::getInputs  ) 
 

Returns the number of inputs of the table.

Returns:
the table input number.

Definition at line 120 of file truthTable.cpp.

References inputs.

Referenced by copyTable(), TruthTableCanvas::getInputsString(), TruthTableCanvas::getInputsVector(), TruthTableCanvas::getOutputs(), TruthTableCanvas::OnCellChanged(), TruthTableDiskManager::saveTable(), TruthTableCanvas::setNewTable(), and TruthTableCanvas::setTable().

wxString TruthTable::getName  ) 
 

Returns the name of the table.

Returns:
The name of the table.

Definition at line 283 of file truthTable.cpp.

References name.

Referenced by copyTable(), TruthTableManager::newTable(), SimulationManager::prepareSimulation(), and TruthTableDiskManager::saveTable().

bool TruthTable::getOutput wxString  input,
int  output
 

Returns a concrete output of an input combination.

Parameters:
input the input combination in string form.
output the output number.
Returns:
The number output for a given input combination.
See also:
getOutput(vector<bool> input, int output)

Definition at line 168 of file truthTable.cpp.

References getOutput(), and stringToVector().

Here is the call graph for this function:

bool TruthTable::getOutput vector< bool >  input,
int  output
 

Returns a concrete output of an input combination.

Parameters:
input the input combination.
output the output number.
Returns:
The number output for a given input combination.
See also:
getOutput(wxString input, int output)

Definition at line 155 of file truthTable.cpp.

References getOutput().

Here is the call graph for this function:

wxString TruthTable::getOutput wxString  input  ) 
 

Returns the outputs of an input combination.

Parameters:
input the input combination ("1" = true, "0" = false).
Returns:
The outputs of the input combination in string form ("1" = true, "0" = false).

Definition at line 141 of file truthTable.cpp.

References getOutput(), stringToVector(), and vectorToString().

Here is the call graph for this function:

vector< bool > TruthTable::getOutput vector< bool >  input  ) 
 

Returns the outputs for a given input.

Parameters:
input the input combination.
Returns:
The values of the outputs for the given input values.

Definition at line 73 of file truthTable.cpp.

References getIndex(), and table.

Referenced by getOutput(), TruthTableCanvas::setTable(), and SimulationManager::verifyGrid().

Here is the call graph for this function:

int TruthTable::getOutputs  ) 
 

Returns the number of outputs of the table.

Returns:
the table output number.

Definition at line 130 of file truthTable.cpp.

References outputs.

Referenced by copyTable(), TruthTableCanvas::getOutputs(), TruthTableDiskManager::saveTable(), and TruthTableCanvas::setNewTable().

vector< vector< bool > > TruthTable::getTable  ) 
 

Returns the table.

Returns:
A vector of vector of booleans containing the output values of the table (the inputs can be recreated).

Definition at line 260 of file truthTable.cpp.

References table.

Referenced by copyTable(), and TruthTableDiskManager::saveTable().

void TruthTable::setName wxString  newName  ) 
 

Sets the name of the table.

Parameters:
newName the name of the table.

Definition at line 293 of file truthTable.cpp.

References name.

void TruthTable::setOutput wxString  input,
wxString  output
 

Sets the output values for an input combination.

Parameters:
input the input combination in string form.
output the output values for the input combination in string form.
See also:
setOutput(vector<bool> input, vector<bool> output)

Definition at line 181 of file truthTable.cpp.

References setOutput(), and stringToVector().

Here is the call graph for this function:

void TruthTable::setOutput vector< bool >  input,
vector< bool >  output
 

Sets the output values for an input combination.

Parameters:
input the input combination.
output the output values for the input combination.
See also:
setOutput(wxString input, wxString output)

Definition at line 110 of file truthTable.cpp.

References getIndex(), and table.

Referenced by setOutput().

Here is the call graph for this function:

void TruthTable::setTable vector< vector< bool > >  table  ) 
 

Sets the table values.

Parameters:
table values to set.

Definition at line 303 of file truthTable.cpp.

References table.

vector< bool > TruthTable::stringToVector wxString  input  )  [private]
 

Converts a string to a vector.

Parameters:
input the string to be converted.
Returns:
A vector version of the string.
See also:
vectorToString(vector<bool> input)

Definition at line 211 of file truthTable.cpp.

Referenced by getIndex(), getOutput(), and setOutput().

wxString TruthTable::vectorToString vector< bool >  input  )  [private]
 

Converts a vector to a string.

Parameters:
input the vector to be converted.
Returns:
A string version of the vector.
See also:
stringToVector(wxString input)

Definition at line 236 of file truthTable.cpp.

Referenced by getOutput().


Member Data Documentation

int TruthTable::inputs [private]
 

Truth table inputs.

Definition at line 60 of file truthTable.hpp.

Referenced by copyTable(), getInputs(), and TruthTable().

wxString TruthTable::name [private]
 

Truth table name.

Definition at line 58 of file truthTable.hpp.

Referenced by copyTable(), getName(), and setName().

int TruthTable::outputs [private]
 

Truth table outputs.

Definition at line 62 of file truthTable.hpp.

Referenced by copyTable(), getOutputs(), and TruthTable().

vector< vector<bool> > TruthTable::table [private]
 

Definition at line 63 of file truthTable.hpp.

Referenced by copyTable(), getOutput(), getTable(), setOutput(), setTable(), and TruthTable().


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