Drake
FunctionalForm::Variable Class Reference

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...
 
Variableoperator= (Variable const &v)
 Copy-assign a variable from an lvalue. More...
 
Variableoperator= (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...
 

Detailed Description

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:

  • nil: No identifier.
  • index: Identified by a non-negative numeric index (type std::size_t).
  • named: Identified by a non-empty string name (type 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.

Constructor & Destructor Documentation

Variable ( )

Construct the nil variable.

Here is the caller graph for this function:

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.

Variable ( char const (&)  name[N])
inline

Construct a variable identified by a non-empty string name (string literal).

Here is the call graph for this function:

Variable ( Variable const &  v)

Copy-construct a variable from an lvalue.

Variable ( Variable &&  v)
noexcept

Move-construct a variable from an rvalue.

Here is the call graph for this function:

~Variable ( )

Destroy a variable.

Member Function Documentation

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.

Here is the call graph for this function:

bool is_index ( ) const

Return true if this variable is identified by a numeric index.

Here is the caller graph for this function:

bool is_named ( ) const

Return true if this variable is identified by a string name.

Here is the caller graph for this function:

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.

Here is the call graph for this function:

FunctionalForm::Variable & operator= ( Variable const &  v)

Copy-assign a variable from an lvalue.

FunctionalForm::Variable & operator= ( Variable &&  v)
noexcept

Move-assign a variable from an rvalue.

Here is the call graph for this function:

Friends And Related Function Documentation

DRAKECORE_EXPORT bool operator!= ( FunctionalForm::Variable const &  l,
FunctionalForm::Variable const &  r 
)
friend

Return false if both variables have the same identifier type and value.

DRAKECORE_EXPORT bool operator< ( FunctionalForm::Variable const &  l,
FunctionalForm::Variable const &  r 
)
friend

Return true if lhs comes before rhs in the Variable Ordering.

DRAKECORE_EXPORT std::ostream& operator<< ( std::ostream &  os,
FunctionalForm::Variable const &  v 
)
friend

Print the variable's identifier, if any, to the given stream.

DRAKECORE_EXPORT bool operator<= ( FunctionalForm::Variable const &  l,
FunctionalForm::Variable const &  r 
)
friend

Return true if lhs does not come after rhs in the Variable Ordering.

DRAKECORE_EXPORT bool operator== ( FunctionalForm::Variable const &  l,
FunctionalForm::Variable const &  r 
)
friend

Return true if both variables have the same identifier type and value.

DRAKECORE_EXPORT bool operator> ( FunctionalForm::Variable const &  l,
FunctionalForm::Variable const &  r 
)
friend

Return true if lhs comes after rhs in the Variable Ordering.

DRAKECORE_EXPORT bool operator>= ( FunctionalForm::Variable const &  l,
FunctionalForm::Variable const &  r 
)
friend

Return true if lhs does not come before rhs in the Variable Ordering.


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