Milo  0.1
Milo:EquationManipulationProgram
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Binary Class Reference

#include <nodes.h>

Inheritance diagram for Binary:
Inheritance graph
[legend]
Collaboration diagram for Binary:
Collaboration graph
[legend]

Public Member Functions

ExpressionPtr getFirstExpression ()
 
ExpressionPtr getSecondExpression ()
 
Constructor and Virtual Destructor
 Binary (char op, Node *one, Node *two, Node *parent, bool neg, Node::Select s)
 
 Binary (EqnXMLParser &in, Node *parent)
 
virtual ~Binary ()
 
Virtual Public Member Functions
std::string toString () const
 
bool isLeaf () const
 
Node * findNode (int x, int y)
 
Node * findNode (const Box &b)
 
int numFactors () const
 
- Public Member Functions inherited from Node
void calculateSize (UI::Graphics &gc)
 
void out (XML::Stream &xml)
 
void calculateOrigin (UI::Graphics &gc, int x, int y)
 
void setUpDraw (UI::Graphics &gc)
 
void draw (UI::Graphics &gc) const
 
void setSelect (Select s)
 
Select getSelect () const
 
void setDrawParenthesis (bool fDrawPar)
 
bool getDrawParenthesis () const
 
const Frame & getFrame () const
 
Node * first ()
 
Node * last ()
 
Node * getNextLeft ()
 
Node * getNextRight ()
 
void setParent (Node *parent)
 
Node * getParent () const
 
int getDepth () const
 
int getNth () const
 
void addNth (int n)
 
void multNth (int n)
 
void setNth (int n)
 
void negative ()
 
bool getSign () const
 
Complex getValue () const
 
std::shared_ptr< Node > getSharedPtr ()
 
 Node (Node *parent=nullptr, bool fNeg=false, Select s=NONE)
 
 Node (EqnXMLParser &in, Node *parent)
 
virtual ~Node ()
 Abstract base class needs virtual desctructor.
 
virtual bool isFactor () const
 
virtual void normalize ()
 
virtual bool simplify ()
 
virtual bool less (NodePtr b) const
 
virtual const std::string & getName () const =0
 
virtual std::type_index getType () const =0
 

Static Public Member Functions

static Node * parse (Parser &p, Node *one, Node *parent)
 
- Static Public Member Functions inherited from Node
static bool createNodeByName (std::string name, Equation &eqn)
 

Protected Attributes

char m_op
 Character repesentation of operator.
 
NodePtr m_first
 First expression owned by this object.
 
NodePtr m_second
 Second expression owned by this object.
 
Box m_internal
 Bounding box of this node.
 

Private Member Functions

Virtual Private Member Functions
Node * downLeft ()
 
Node * downRight ()
 
Node * getLeftSibling (Node *node)
 
Node * getRightSibling (Node *node)
 
void xml_out (XML::Stream &xml) const
 

Additional Inherited Members

- Public Types inherited from Node
enum  Select { NONE, START, END, ALL }
 
- Static Public Attributes inherited from Node
static const std::vector< std::string > select_tags = { "NONE", "START", "END", "ALL" }
 

Detailed Description

Base class for nodes represent an operator that contains two expressions. Not all pure virtual functions are overriden so is an abstract base class.

Constructor & Destructor Documentation

Binary::Binary ( char  op,
Node *  one,
Node *  two,
Node *  parent,
bool  neg,
Node::Select  s 
)
inline

Constructor for Binary class.

Parameters
opCharacter representing operator.
oneFirst expression.
twoSecond expression.
parentParent node.
negIf true, node is negative.
sSelection state of node.
Binary::Binary ( EqnXMLParser &  in,
Node *  parent 
)

XML constructor for Binary class. Read in XML that is common for all nodes that have a Binary base class.

Parameters
inXML input stream.
parentParent node object.
virtual Binary::~Binary ( )
inlinevirtual

Virtual desctructor. Abstract base class needs virtual desctructor.

Member Function Documentation

Node* Binary::downLeft ( )
inlineprivatevirtual

Get left node. For Binary class is its first expression.

Returns
Left node.

Reimplemented from Node.

Node* Binary::downRight ( )
inlineprivatevirtual

Get right node. For Binary class is its second expression.

Returns
Right node.

Reimplemented from Node.

Node * Binary::findNode ( int  x,
int  y 
)
virtual

Rescursive search to find deepest node at point (x,y).

Parameters
xhorizontal coordinate.
yvertical coordinate.
Returns
Deepest node at point (x,y).

Reimplemented from Node.

Node * Binary::findNode ( const Box &  b)
virtual

Recursive function to return first node from a top to bottom search whose frame is inside Box b.

Parameters
bBounding box.
Returns
Top node inside bounding box.

Reimplemented from Node.

ExpressionPtr Binary::getFirstExpression ( )

Get first expression of this node.

Returns
First expression.
Node* Binary::getLeftSibling ( Node *  node)
inlineprivatevirtual

Left sibiling of given node. If node given is right node, return left node.

Parameters
nodeReference node.
Returns
Left sibiling or null.

Reimplemented from Node.

Node* Binary::getRightSibling ( Node *  node)
inlineprivatevirtual

Right sibiling of given node. If node given is left node, return right node.

Parameters
nodeReference node.
Returns
Right sibiling or null.

Reimplemented from Node.

ExpressionPtr Binary::getSecondExpression ( )

Get second expression of this node.

Returns
Second expression.
bool Binary::isLeaf ( ) const
inlinevirtual

Override for isLeaf virtual function.

Returns
False, this node has child nodes.

Reimplemented from Node.

int Binary::numFactors ( ) const
inlinevirtual

Get number of factor in this subtree.

Returns
Return number of factors in both expressions.

Reimplemented from Node.

Node * Binary::parse ( Parser &  p,
Node *  one,
Node *  parent 
)
static

Static helper function to parse Binary class.

Parameters
pParser object pointing to operator.
oneFirst expression already parsed.
parentParent node.
Returns
Binary object or null if operator not binary.
std::string Binary::toString ( ) const
inlinevirtual

Get string representation of Binary object. Simply first node, operator, second node.

Returns
String representation of Binary object.

Implements Node.

void Binary::xml_out ( XML::Stream &  xml) const
privatevirtual

Output XML of this node.

Parameters
xmlXML output stream.

Implements Node.


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