philsupertramp/game-math
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Function Class Reference

#include <Operator.h>

Inheritance diagram for Function:
Operator MathNode

Public Member Functions

 Function (const std::string &val, const std::function< double(double)> &fun)
 
 Function (const std::string &val, const std::function< double(double, double)> &fun)
 
double Evaluate () const override
 
- Public Member Functions inherited from Operator
 Operator (const std::string &name, std::function< double(double, double)> fun, OperatorPriority operatorPriority)
 
 Operator (const Operator &other)
 
double Evaluate () const override
 
- Public Member Functions inherited from MathNode
 MathNode (const std::string &val)
 
 MathNode (const MathNode &other)
 
virtual double Evaluate () const =0
 
std::string GetString () const
 
bool operator== (MathNode *rhs)
 

Additional Inherited Members

- Public Attributes inherited from Operator
std::function< double(double, double)> op
 Operator implementation, this will be evaluated during Evaluate calls. More...
 
OperatorPriority priority
 Operator priority, used to create AST. More...
 
- Public Attributes inherited from MathNode
bool isNegative = false
 helper to determine whether a node is negated or not More...
 
bool hasParentheses = false
 helper to determine if node is within parentheses More...
 
MathNodeType type
 node type representation More...
 
NodeConnectionType connectionType = NodeConnectionType::ConnectionType_Dual
 type of connection allowed for this node More...
 
std::shared_ptr< MathNodeleft = nullptr
 next node on left side More...
 
std::shared_ptr< MathNoderight = nullptr
 next node on right side More...
 
char * value {}
 char representation of value More...
 
- Protected Attributes inherited from MathNode
size_t valSize = 0
 helper to store size of value More...
 

Detailed Description

Function representation as node.

Current implementation represents single operand functions, like

\[ \sqrt{x} \quad \text{ or } \quad \log{x} \]

Constructor & Destructor Documentation

◆ Function() [1/2]

Function::Function ( const std::string &  val,
const std::function< double(double)> &  fun 
)
inline

Single operand default constructor

Parameters
valstring representation
funsingle value evaluation function

◆ Function() [2/2]

Function::Function ( const std::string &  val,
const std::function< double(double, double)> &  fun 
)
inline

Two operand default constructor

Parameters
valstring representation
funtwo value evaluation function

TODO: enable parsing for this kind of function!

Member Function Documentation

◆ Evaluate()

double Function::Evaluate ( ) const
inlineoverridevirtual

evaluates op(left, right)

Returns

TODO: whenever enabled comment out. else if(connectionType == NodeConnectionType::ConnectionType_Dual) return op(left->Evaluate(), right->Evaluate());

Reimplemented from Operator.


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