Math Type Library (libmath++) 0.0.3
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
math::TNode< T > Class Template Referenceabstract

#include <nodes.h>

Inheritance diagram for math::TNode< T >:
math::TBinaryNodeOp< T > math::TNumberNode< T > math::TParamNode< T > math::TSymbolNode< T > math::TUnaryNodeOp< T > math::TDivNode< T > math::TEquNode< T > math::TGreaterEquNode< T > math::TGreaterNode< T > math::TIfNode< T > math::TLessEquNode< T > math::TLessNode< T > math::TMulNode< T > math::TPlusNode< T > math::TPowNode< T > math::TUnEquNode< T > math::TCosNode< T > math::TFuncNode< T > math::TLnNode< T > math::TNegNode< T > math::TSinNode< T > math::TSqrtNode< T > math::TTanNode< T >

Public Types

enum  TNodeType {
  NUMBER_NODE , SYMBOL_NODE , PARAM_NODE , PLUS_NODE ,
  NEG_NODE , MUL_NODE , DIV_NODE , MOD_NODE ,
  POW_NODE , EQU_NODE , UNEQU_NODE , LESS_EQU_NODE ,
  GREATER_EQU_NODE , LESS_NODE , GREATER_NODE , FUNC_NODE ,
  SQRT_NODE , SIN_NODE , COS_NODE , TAN_NODE ,
  LN_NODE , IF_NODE
}
 
typedef TNodeIterator< Titerator
 
typedef const TNodeIterator< Tconst_iterator
 
typedef TOperandIter< TNode< T > > operand_iterator
 
typedef TOperandIter< const TNode< T > > const_operand_iterator
 

Public Member Functions

virtual ~TNode ()
 each virtual class needs a virtual destructor (this one does nothing)
 
TNodeType nodeType () const
 returns the type of this node
 
short priority () const
 returns the node priority
 
TNode< T > * parent () const
 returns the parent node (returns 0 if this node is the root node)
 
virtual TNode< T > * left () const
 returns the left child node (returns 0 if this node doesn't support one)
 
virtual TNode< T > * right () const
 returns the right child node (returns 0 if this node doesn't support one)
 
virtual void accept (TNodeVisitor< T > &)=0
 calls the visit method in TNodeVisitor<>
 
virtual TNode< T > * clone () const =0
 clones that node
 
iterator begin ()
 iterator access to the first value node in this operator level
 
iterator end ()
 iterator access to the end
 
virtual bool equals (const TNode< T > *ANode) const =0
 returns true, if given node equals to this one
 

Protected Member Functions

 TNode (TNodeType ANodeType, short APriority, TNode< T > *AParentNode=0)
 initializes this node for given node type.
 
 TNode (const TNode< T > &n)
 
void parent (TNode< T > *AParent)
 initializes the parent node with the given one
 

Friends

class TUnaryNodeOp< T >
 
class TBinaryNodeOp< T >
 

Detailed Description

template<typename T>
class math::TNode< T >

TNode<T> represents the abstract node base.

Definition at line 228 of file nodes.h.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef const TNodeIterator<T> math::TNode< T >::const_iterator

Definition at line 231 of file nodes.h.

◆ const_operand_iterator

template<typename T >
typedef TOperandIter<const TNode<T> > math::TNode< T >::const_operand_iterator

Definition at line 234 of file nodes.h.

◆ iterator

template<typename T >
typedef TNodeIterator<T> math::TNode< T >::iterator

Definition at line 230 of file nodes.h.

◆ operand_iterator

template<typename T >
typedef TOperandIter<TNode<T> > math::TNode< T >::operand_iterator

Definition at line 233 of file nodes.h.

Member Enumeration Documentation

◆ TNodeType

This enumeration, TNodeType, is implemented for node type access. This makes it also faster because it replaces the dynamic_cast<> operator.

Definition at line 240 of file nodes.h.

240 {
241 // take care, the order below is hard coded
242
243 NUMBER_NODE, // numbers: 0, 3.1415, 2.17, 0.815, ... (prio: 0)
244 SYMBOL_NODE, // any symbol value: pi, e, ... (prio: 0)
245 PARAM_NODE, // the function parameter... (e.g. x) (prio: 0)
246
247 PLUS_NODE, // x + y (prio: -5)
248 NEG_NODE, // -x (prio: -5)
249
250 MUL_NODE, // x * y (prio: -3)
251 DIV_NODE, // x / y (prio: -3)
252 MOD_NODE, // x mod y (prio: -3)
253
254 POW_NODE, // x ^ y (prio: -1)
255
256 EQU_NODE, // x == y (prio: -10)
257 UNEQU_NODE, // x != y (prio: -10)
258 LESS_EQU_NODE, // x <= y (prio: -10)
259 GREATER_EQU_NODE,// x >= y (prio: -10)
260 LESS_NODE, // x < y (prio: -10)
261 GREATER_NODE, // x > y (prio: -10)
262
263 FUNC_NODE, // userfunc(x) (prio: -1)
264
265 SQRT_NODE, // sqrt(x); x ^ 0.5 (prio: -1)
266 SIN_NODE, // sin(x) (prio: -1)
267 COS_NODE, // cos(x) (prio: -1)
268 TAN_NODE, // tan(x) (prio: -1)
269 LN_NODE, // logn(x) (prio: -1)
270
271 IF_NODE // IF(cond, then, else) (prio: -1)
272 };

Member Function Documentation

◆ accept()

template<typename T >
virtual void math::TNode< T >::accept ( TNodeVisitor< T > &  )
pure virtual

◆ begin()

template<typename T >
iterator math::TNode< T >::begin ( )
inline

iterator access to the first value node in this operator level

Definition at line 319 of file nodes.h.

319{ return iterator(this).rewind(); }

◆ clone()

template<typename T >
virtual TNode< T > * math::TNode< T >::clone ( ) const
pure virtual

◆ end()

template<typename T >
iterator math::TNode< T >::end ( )
inline

iterator access to the end

Definition at line 322 of file nodes.h.

322{ return iterator(0); }

◆ equals()

template<typename T >
virtual bool math::TNode< T >::equals ( const TNode< T > *  ANode) const
pure virtual

returns true, if given node equals to this one

Implemented in math::TNumberNode< T >, math::TSymbolNode< T >, math::TParamNode< T >, math::TUnaryNodeOp< T >, and math::TBinaryNodeOp< T >.

◆ left()

template<typename T >
virtual TNode< T > * math::TNode< T >::left ( ) const
virtual

returns the left child node (returns 0 if this node doesn't support one)

Reimplemented in math::TBinaryNodeOp< T >.

◆ right()

template<typename T >
virtual TNode< T > * math::TNode< T >::right ( ) const
virtual

returns the right child node (returns 0 if this node doesn't support one)

Reimplemented in math::TUnaryNodeOp< T >, and math::TBinaryNodeOp< T >.

Friends And Related Symbol Documentation

◆ TBinaryNodeOp< T >

template<typename T >
friend class TBinaryNodeOp< T >
friend

Definition at line 288 of file nodes.h.

◆ TUnaryNodeOp< T >

template<typename T >
friend class TUnaryNodeOp< T >
friend

Definition at line 288 of file nodes.h.


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