OpenCurves  0.9
PlotBinaryOperatorT< Operator > Class Template Reference

A template binary operator, using a functional object to evaluate the expression. More...

#include <plotbinaryoperator.h>

Inheritance diagram for PlotBinaryOperatorT< Operator >:
PlotBinaryOperator PlotExpression

Public Member Functions

 PlotBinaryOperatorT ()
 Default constructor: left and right are null.
 
 PlotBinaryOperatorT (PlotExpression *left, PlotExpression *right, const QString &opstr=QString())
 Branched constructor. More...
 
virtual double sample (double sampleTime) const
 Sample the branches and evaluate the results. More...
 
const QString & opStr () const
 Return the string used to combine left and right branches. More...
 
void setOpStr (const QString &str)
 Sets the string used to combine left and right branches. More...
 
virtual PlotExpressionclone () const
 Deep clone.
 
- Public Member Functions inherited from PlotBinaryOperator
 PlotBinaryOperator (PlotExpression *left, PlotExpression *right)
 Create a binary operator on the given left and right expressions. More...
 
 ~PlotBinaryOperator ()
 Destructor, destroying left and right.
 
void setLeft (PlotExpression *left)
 Set the left branch. More...
 
const PlotExpressionleft () const
 Get the left branch. More...
 
void setRight (PlotExpression *right)
 Set the right branch. More...
 
const PlotExpressionright () const
 Get the right branch. More...
 
virtual BindResult bind (const QList< PlotInstance * > &curves, PlotBindingTracker &bindTracker, PlotExpressionBindDomain &domain, bool repeatLastBinding=false)
 Binds the left and right branch expressions. More...
 
virtual void unbind ()
 Unbind left and right branches.
 
bool explicitTime () const override
 Is the generated expression sensitive to changes in the time domain? More...
 
- Public Member Functions inherited from PlotExpression
 PlotExpression ()
 Empty constructor.
 
virtual ~PlotExpression ()
 Empty, virtual destructor.
 
QString toString () const
 Converts the PlotExpression into a parseable string form. More...
 

Detailed Description

template<class Operator>
class PlotBinaryOperatorT< Operator >

A template binary operator, using a functional object to evaluate the expression.

This class extends the PlotBinaryOperator to create a concrete derivation which uses Operator evaluate the expression. The Operator type must be an object supporting the bracket operator accepting two double arguments and returning a double. The operator performs the expression calculations. For example, std::plus<double>.

As a convenience, the object supports a opStr(), which is used when toString() is called. Essentially, the complete string is formed by: left->toString() + opStr() + right->toString().

Template Parameters
OperatorThe functional object used to evaluate the expression.

Constructor & Destructor Documentation

template<class Operator>
PlotBinaryOperatorT< Operator >::PlotBinaryOperatorT ( PlotExpression left,
PlotExpression right,
const QString &  opstr = QString() 
)
inline

Branched constructor.

Parameters
leftThe left branch.
rightThe right branch.
opstrThe string used to combine the branches when toString() is called.

Member Function Documentation

template<class Operator>
const QString& PlotBinaryOperatorT< Operator >::opStr ( ) const
inline

Return the string used to combine left and right branches.

Returns
The operation string (e.g., "+" for addition).
template<class Operator>
virtual double PlotBinaryOperatorT< Operator >::sample ( double  sampleTime) const
inlinevirtual

Sample the branches and evaluate the results.

Evaluates left and right branches at sampleTime, and passes the results to Operator for evaluation. Returns the result.

Parameters
sampleTimeThe time to sample at.
Returns
The left and right samples combined with Operator.

Implements PlotExpression.

template<class Operator>
void PlotBinaryOperatorT< Operator >::setOpStr ( const QString &  str)
inline

Sets the string used to combine left and right branches.

Parameters
strThe operation string.

Referenced by PlotBinaryOperatorT< std::minus< double > >::clone().


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