- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Models::Base::BaseModelVariable Class Reference

`#include <BaseModelVariable.h>`

Inheritance diagram for Mers::Models::Base::BaseModelVariable:

[legend]
Collaboration diagram for Mers::Models::Base::BaseModelVariable:

[legend]
List of all members.

## Public Types
enum | VariableType { Unknown = 0, SecondsClock = 1, MinutesClock = 2, HoursClock = 3, DaysClock = 4, Control = 5, CONTROL = Control, Dependent = 6, DEPENDENT = Dependent, Observable = 7, OBSERVABLE = Observable, State = 8, STATE = State, Local = 9 }
## Public Member Functions
| BaseModelVariable (VariableType myType=Unknown)
| BaseModelVariable (char const *myName, VariableType myType=Unknown)
| BaseModelVariable (char const *myName, BaseModelDomain *myDomain, VariableType myType=Unknown, unsigned int myUID=0)
| BaseModelVariable (BaseModelVariable const &other)
virtual | ~BaseModelVariable ()
int | setName (char const *newName)
char const * | getName () const
void | setUID (unsigned int newUID)
unsigned int | getUID () const
void | setVariableType (VariableType newType)
VariableType | getVariableType () const
void | setDomain (BaseModelDomain *newDomain)
BaseModelDomain * | getDomain ()
BaseModelDomain const * | getDomain () const
BaseModelValue * | getValue (unsigned int valueUID)
BaseModelValue const * | getValue (unsigned int valueUID) const
BaseModelValue * | getValue (char const *valueName)
BaseModelValue const * | getValue (char const *valueName) const
BaseModelVariable const & | operator= (BaseModelVariable const &other)
bool | operator== (BaseModelVariable const &other) const
bool | operator!= (BaseModelVariable const &other) const
void | print (std::ostream &out) const
## Static Public Member Functions
static char const * | variableTypeToString (VariableType variableType)
static int | stringToVariableType (char const *variableTypeString, VariableType &variableType)
## Protected Member Functions
void | destroy ()
int | copy (BaseModelVariable const &variable)
## Protected Attributes
VariableType | variableType
| The variable type of this object.
unsigned int | uid
| the identifier or array index of this object
char * | name
| the name of this variable
BaseModelDomain * | domain
| the domain of this variable

## Detailed Description

A Logical Variable that has a domain and a classification. Variables can be used in assignments to be assigned to a Value in the Domain of the Variable.

Author:
  Paul H. Elliott

Definition at line 37 of file BaseModelVariable.h.

## Member Enumeration Documentation

enum Mers::Models::Base::BaseModelVariable::VariableType

These should be explicitly numbered so they can be written to a file and be loaded again as the right types, should more be added later.

##########
## NOTE ##
##########

If you add a type, add it to the variableTypeToString() function as well as the stringToVariableType().

Definition at line 52 of file BaseModelVariable.h.

## Constructor & Destructor Documentation

BaseModelVariable::BaseModelVariable | ( | VariableType | myType = `Unknown` | ) |

Creates a new variable of the requested type.

Parameters:

  | myType | the value type of this variable

Definition at line 29 of file BaseModelVariable.cpp.

References domain, name, uid, and variableType.

BaseModelVariable::BaseModelVariable | ( | char const * | myName,
|  | VariableType | myType = `Unknown` |
| ) |  |  |

Creates a new variable of the requested type.

Parameters:

  | myName | the name of this variable, this name is copied into this object.
  | myType | the value type of this variable.

Definition at line 40 of file BaseModelVariable.cpp.

References domain, name, setName(), uid, and variableType.

Here is the call graph for this function:

BaseModelVariable::BaseModelVariable | ( | char const * | myName,
|  | BaseModelDomain * | myDomain,
|  | VariableType | myType = `Unknown`,
|  | unsigned int | myUID = `0` |
| ) |  |  |

Creates a new variable of the requested type.

Parameters:

  | myName | the name of this variable, this name is copied into this object.
  | myDomain | the domain of this variable.
  | myType | the value type of this variable.
  | myUID | the UID of this variable, often used as an index into a VariableArray.

Definition at line 52 of file BaseModelVariable.cpp.

References domain, name, setName(), uid, and variableType.

Here is the call graph for this function:

BaseModelVariable::BaseModelVariable | ( | BaseModelVariable const & | other | ) |

Creates a new variable with a copy of the contents from the other variable.

Parameters:

  | other | the variable being copied

Definition at line 65 of file BaseModelVariable.cpp.

References domain, name, setName(), uid, and variableType.

Here is the call graph for this function:

BaseModelVariable::~BaseModelVariable | ( |  | ) | `[virtual]`

Destroys the value.

Definition at line 77 of file BaseModelVariable.cpp.

References destroy().

Here is the call graph for this function:

## Member Function Documentation

char const * BaseModelVariable::variableTypeToString | ( | VariableType | variableType | ) | `[static]`

Returns the string representation of the variableType.

Parameters:

  | variableType | the variable type being sought.

Returns the string equivalent of variableType.

Definition at line 84 of file BaseModelVariable.cpp.

Referenced by print(), and Mers::Models::Base::Io::Mof::BaseModelReader::saveBaseModel().

int BaseModelVariable::stringToVariableType | ( | char const * | variableTypeString,
|  | VariableType & | variableType |
| ) |  |  | `[static]`

Converts the string representation of the variableTypeString into the enumerated type. This function computes the inverse of the above variableTypeToString() function.

Parameters:

  | variableTypeString | the string representation being converted into the VariableType enumerated type.
  | variableType | the resulting type is stored here, if the variableTypeString was a valid VariableType.

Returns:
  0 on success or a positive number if the string was not a valid VariableType enumerated type.

Definition at line 114 of file BaseModelVariable.cpp.

References name.

int BaseModelVariable::setName | ( | char const * | newName | ) |

Sets the name of this variable to a copy of newName.

Parameters:

  | newName | the new name for this variable.

Returns:
  0 on success or a positive number if the name could not be duplicated

Definition at line 166 of file BaseModelVariable.cpp.

References name, and BaseModelUtils::setName().

Referenced by BaseModelVariable(), and copy().

Here is the call graph for this function:

char const * BaseModelVariable::getName | ( |  | ) | const

Returns a handle to the current name of this variable. This may be NULL if this variable doesn't have a name.

Returns:
  the variable's name

Definition at line 173 of file BaseModelVariable.cpp.

References name.

Referenced by Mers::Models::CCA::CCAModel::addAutomaton(), Mers::Models::CCA::CCAModel::addVariable(), Mers::Models::CCA::CCAAutomaton::CCAAutomaton(), Mers::Generators::BFIG::BFIGVariable::getNameString(), Mers::Models::CCA::CCAModel::is_valid(), Mers::Models::CCA::Io::Mof::MOFReader::loadMOFFromString(), Mers::Models::CCA::CCAAutomaton::name(), Mers::Models::Base::BaseModelAssignment::print(), Mers::Estimation::Discrete::read_trajectory(), Mers::Executives::DeductiveController::DCInterface::step(), Mers::Executives::DeductiveController::Task::toString(), and Mers::Solvers::Entailment::GI::GoalInterpreter::updateGoal().

void BaseModelVariable::setUID | ( | unsigned int | newUID | ) |

Sets the UID of this variable. This is generally the array index of the variable in some enclosing variable array.

Parameters:

  | newUID | the new UID of this variable

Definition at line 180 of file BaseModelVariable.cpp.

References uid.

unsigned int BaseModelVariable::getUID | ( |  | ) | const

Returns the current UID of this variable.

Returns:
  the UID of this variable.

Definition at line 187 of file BaseModelVariable.cpp.

References uid.

Referenced by Mers::Generators::BFIG::BFIGGenerator::addConflict(), Mers::Executives::DeductiveController::Command::CommandDispatcher::addConnection(), Mers::Estimation::Discrete::ModeEstimation::ModeEstimator::addGuardAssign(), Mers::Estimation::Discrete::CompiledTransition::getAntecedentVariableUID(), Mers::Executives::DeductiveController::DCInterface::getCurrentState(), Mers::Solvers::SAT::ValidSAT::VSATVariable::getUID(), Mers::Executives::DeductiveController::DCInterface::getValue(), Mers::Executives::DeductiveController::DCInterface::loadInitialState(), Mers::Estimation::Discrete::read_trajectory(), Mers::Executives::DeductiveController::DCInterface::step(), Mers::Executives::DeductiveController::Task::toString(), and Mers::Solvers::Entailment::GI::GoalInterpreter::variableAndValueToUID().

void BaseModelVariable::setVariableType | ( | VariableType | newType | ) |

Sets the variable type of this object.

Parameters:

  | newType | the new type of this variable

Definition at line 194 of file BaseModelVariable.cpp.

References variableType.

BaseModelVariable::VariableType BaseModelVariable::getVariableType | ( |  | ) | const

Returns the variable's type.

Returns:
  the VariableType of this object

Definition at line 201 of file BaseModelVariable.cpp.

References variableType.

Referenced by Mers::Estimation::Discrete::Estimate::addAssignment(), Mers::Models::CCA::CCAModel::addAutomaton(), Mers::Estimation::Discrete::ModeEstimation::ModeEstimator::addGuardAssign(), Mers::Estimation::Discrete::assign(), Mers::Estimation::Discrete::CompiledTransition::CompiledTransition(), Mers::Estimation::Discrete::read_trajectory(), Mers::Models::CCA::CCAModel::set_state_constraint(), and Mers::Models::CCA::CCAModel::set_state_type().

void BaseModelVariable::setDomain | ( | BaseModelDomain * | newDomain | ) |

Sets the domain of this object. This value object will register itself with the new domain and unregister itself with the old domain as appropriate.

Parameters:

  | newDomain | the new domain of this value

Definition at line 208 of file BaseModelVariable.cpp.

References domain.

BaseModelDomain * BaseModelVariable::getDomain | ( |  | ) |

Returns the current domain of this value.

Returns:
  this value's domain

Definition at line 215 of file BaseModelVariable.cpp.

References domain.

Referenced by Mers::Executives::DeductiveController::Command::CommandDispatcher::addConnection(), Mers::Estimation::Discrete::ModeEstimation::ModeEstimator::addGuardAssign(), Mers::Models::Base::BaseModelAssignment::BaseModelAssignment(), Mers::Models::CCA::CCAAutomaton::CCAAutomaton(), Mers::Generators::BFIG::BFIGVariable::getDomainSize(), Mers::Generators::BFIG::BFIGVariable::getDomainTotalSize(), Mers::Executives::DeductiveController::DCInterface::getValue(), Mers::Generators::BFIG::BFIGVariable::nullDomain(), Mers::Generators::BFIG::BFIGVariable::toString(), and Mers::Solvers::SAT::ValidSAT::VSATVariable::VSATVariable().

BaseModelDomain const * BaseModelVariable::getDomain | ( |  | ) | const

Returns the current domain of this value.

Returns:
  this value's domain

Definition at line 222 of file BaseModelVariable.cpp.

References domain.

BaseModelValue * BaseModelVariable::getValue | ( | unsigned int | valueUID | ) |

Returns a value from the domain of the variable with the matching value UID.

Parameters:

  | valueUID | the UID of the value being sought.

Returns:
  the value with the matching valueUID

Definition at line 229 of file BaseModelVariable.cpp.

References domain.

Referenced by Mers::Models::CCA::CCAModel::assignment_(), Mers::Models::CCA::CCAState::CCAState(), Mers::Models::Base::Io::Xml::Sax::BMAssignmentCH::endElement(), Mers::Generators::BFIG::BFIGGenerator::generateBestImplicant(), Mers::Models::CCA::CCAModel::get_assignment(), Mers::Models::Base::BaseModel::getAssignment(), Mers::Models::CCA::CCAModel::is_valid(), tut::BMHelper::loadAssignments(), tut::BFIGHelper::loadAssignments(), Mers::Estimation::Discrete::read_trajectory(), and Mers::Solvers::Entailment::GI::GoalInterpreter::updateGoal().

BaseModelValue const * BaseModelVariable::getValue | ( | unsigned int | valueUID | ) | const

Returns a value from the domain of the variable with the matching value UID.

Parameters:

  | valueUID | the UID of the value being sought.

Returns:
  the value with the matching valueUID.

Definition at line 236 of file BaseModelVariable.cpp.

References domain.

BaseModelValue * BaseModelVariable::getValue | ( | char const * | valueName | ) |

Returns a value from the domain of the variable with the matching value name.

Parameters:

  | valueName | the name of the value being sought.

Returns:
  the value with the matching valueName

Definition at line 243 of file BaseModelVariable.cpp.

References domain, and Mers::Models::Base::BaseModelDomain::getValue().

Here is the call graph for this function:

BaseModelValue const * BaseModelVariable::getValue | ( | char const * | valueName | ) | const

Returns a value from the domain of the variable with the matching value name.

Parameters:

  | valueName | the name of the value being sought.

Returns:
  the value with the matching valueName.

Definition at line 250 of file BaseModelVariable.cpp.

References domain, and Mers::Models::Base::BaseModelDomain::getValue().

Here is the call graph for this function:

BaseModelVariable const & BaseModelVariable::operator= | ( | BaseModelVariable const & | other | ) |

Copies the other variable to this variable. The origional data in this variable is destroyed.

Parameters:

  | other | the variable supplying the data for this variable.

Returns:
  the other variable.

Definition at line 257 of file BaseModelVariable.cpp.

References copy().

Here is the call graph for this function:

bool BaseModelVariable::operator== | ( | BaseModelVariable const & | other | ) | const

Returns true if the two variables have the same domains, types, and UIDs.

Parameters:

  | other | the variable being compared to this variable.

Returns:
  true if the two variables are the same.

Definition at line 265 of file BaseModelVariable.cpp.

References domain, Mers::Models::Base::BaseModelDomain::getName(), name, uid, and variableType.

Referenced by operator!=().

Here is the call graph for this function:

bool BaseModelVariable::operator!= | ( | BaseModelVariable const & | other | ) | const

Returns false if the two variables have the same domains, types, and UIDs.

Parameters:

  | other | the variable being compared to this variable.

Returns:
  false if the two variables are the same.

Definition at line 278 of file BaseModelVariable.cpp.

References operator==().

Here is the call graph for this function:

void BaseModelVariable::print | ( | std::ostream & | out | ) | const`[virtual]`

Prints the contents of this variable to the ostream out. Derived classes should overide this function to change printing behavior.

Parameters:

  | out | all the data from this object is printed to this ostream object.

Implements Mers::Utils::Lang::BaseModelObject.

Definition at line 287 of file BaseModelVariable.cpp.

References domain, Mers::Models::Base::BaseModelDomain::getName(), name, uid, variableType, and variableTypeToString().

Referenced by Mers::Models::Base::BaseModelVariableArray::printElement().

Here is the call graph for this function:

void BaseModelVariable::destroy | ( |  | ) | `[protected]`

Destroys the contents of this variable object, freeing all allocated memory and reseting all values in preperation for a copy or delete operation. Derived classes that define this function should ensure that this function is also called: BaseModelVariable::destroy();

Definition at line 301 of file BaseModelVariable.cpp.

References domain, name, and variableType.

Referenced by ~BaseModelVariable().

int BaseModelVariable::copy | ( | BaseModelVariable const & | variable | ) | `[protected]`

Copies the contents of the other variable to this variable. This destroys the contents of this variable.

Parameters:

  | variable | the variable being copied to this variable.

Returns:
  0 on success or a positive number if the copy failed.

Definition at line 312 of file BaseModelVariable.cpp.

References domain, name, setName(), uid, and variableType.

Referenced by operator=().

Here is the call graph for this function:

The documentation for this class was generated from the following files:

- /Users/fpy/titan-1-5-MBARI/Mers/Models/Base/BaseModelVariable.h
- /Users/fpy/titan-1-5-MBARI/Mers/Models/Base/BaseModelVariable.cpp