Drake
|
Represent a variable in a FunctionalForm. More...
#include <drake/core/functional_form.h>
Public Member Functions | |
Variable () | |
Construct the nil variable. More... | |
Variable (std::size_t index) | |
Construct a variable identified by a non-negative numeric index . More... | |
Variable (std::string name) | |
Construct a variable identified by a non-empty string name . More... | |
template<int N> | |
Variable (char const (&name)[N]) | |
Construct a variable identified by a non-empty string name (string literal). More... | |
Variable (Variable const &v) | |
Copy-construct a variable from an lvalue. More... | |
Variable (Variable &&v) noexcept | |
Move-construct a variable from an rvalue. More... | |
~Variable () | |
Destroy a variable. More... | |
Variable & | operator= (Variable const &v) |
Copy-assign a variable from an lvalue. More... | |
Variable & | operator= (Variable &&v) noexcept |
Move-assign a variable from an rvalue. More... | |
bool | is_nil () const |
Return true if this variable has no identifier. More... | |
bool | is_index () const |
Return true if this variable is identified by a numeric index. More... | |
bool | is_named () const |
Return true if this variable is identified by a string name. More... | |
std::size_t | index () const |
If this variable is identified by a numeric index, return the index. More... | |
std::string const & | name () const |
If this variable is identified by a string name, return the name. More... | |
Friends | |
DRAKECORE_EXPORT std::ostream & | operator<< (std::ostream &os, Variable const &v) |
Print the variable's identifier, if any, to the given stream. More... | |
DRAKECORE_EXPORT bool | operator== (Variable const &lhs, Variable const &rhs) |
Return true if both variables have the same identifier type and value. More... | |
DRAKECORE_EXPORT bool | operator!= (Variable const &lhs, Variable const &rhs) |
Return false if both variables have the same identifier type and value. More... | |
DRAKECORE_EXPORT bool | operator< (Variable const &lhs, Variable const &rhs) |
Return true if lhs comes before rhs in the Variable Ordering. More... | |
DRAKECORE_EXPORT bool | operator<= (Variable const &lhs, Variable const &rhs) |
Return true if lhs does not come after rhs in the Variable Ordering. More... | |
DRAKECORE_EXPORT bool | operator> (Variable const &lhs, Variable const &rhs) |
Return true if lhs comes after rhs in the Variable Ordering. More... | |
DRAKECORE_EXPORT bool | operator>= (Variable const &lhs, Variable const &rhs) |
Return true if lhs does not come before rhs in the Variable Ordering. More... | |
Represent a variable in a FunctionalForm.
A FunctionalForm is defined with respect to zero or more variables that an expression combines in some form. Instances of Variable serve as placeholders identifying distinct variables in a FunctionalForm. Each Variable has a distinguishing identifier of one of these types:
std::size_t
).std::string
).Instances are considered equivalent if they have the same identification type and value.
We define a Variable Ordering first by type (in the above order) and then by the natural order of values within each type.
Variable | ( | ) |
Construct the nil variable.
Variable | ( | std::size_t | index | ) |
Construct a variable identified by a non-negative numeric index
.
Variable | ( | std::string | name | ) |
Construct a variable identified by a non-empty string name
.
|
inline |
Construct a variable identified by a non-empty string name
(string literal).
Move-construct a variable from an rvalue.
~Variable | ( | ) |
Destroy a variable.
std::size_t index | ( | ) | const |
If this variable is identified by a numeric index, return the index.
Otherwise, return the largest index representable by std::size_t
.
bool is_index | ( | ) | const |
Return true if this variable is identified by a numeric index.
bool is_named | ( | ) | const |
Return true if this variable is identified by a string name.
bool is_nil | ( | ) | const |
Return true if this variable has no identifier.
std::string const & name | ( | ) | const |
If this variable is identified by a string name, return the name.
Otherwise, return the empty string.
FunctionalForm::Variable & operator= | ( | Variable const & | v | ) |
Copy-assign a variable from an lvalue.
|
noexcept |
Move-assign a variable from an rvalue.
|
friend |
Return false if both variables have the same identifier type and value.
|
friend |
Return true if lhs
comes before rhs
in the Variable Ordering.
|
friend |
Print the variable's identifier, if any, to the given stream.
|
friend |
Return true if lhs
does not come after rhs
in the Variable Ordering.
|
friend |
Return true if both variables have the same identifier type and value.
|
friend |
Return true if lhs
comes after rhs
in the Variable Ordering.
|
friend |
Return true if lhs
does not come before rhs
in the Variable Ordering.