Milo  0.1
Milo:EquationManipulationProgram
Public Types | Static Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes | List of all members
Constant Class Reference

#include <nodes.h>

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

Public Types

using const_map = std::unordered_map< char, Complex >
 Specialization for mapping name to value.
 
- Public Types inherited from Node
enum  Select { NONE, START, END, ALL }
 

Public Member Functions

Constructor and Virtual Destructor
 Constant (Parser &p, Node *parent)
 
 Constant (char name, Complex value, Node *parent, bool neg=false, Node::Select s=Node::Select::NONE)
 
 Constant (EqnXMLParser &in, Node *parent)
 
 ~Constant ()
 
Virtual Public Member Functions
std::string toString () const
 
const std::string & getName () const
 
std::type_index getType () 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 isLeaf () const
 
virtual bool isFactor () const
 
virtual Node * findNode (int x, int y)
 
virtual Node * findNode (const Box &b)
 
virtual int numFactors () const
 
virtual void normalize ()
 
virtual bool simplify ()
 
virtual bool less (NodePtr b) const
 

Static Public Member Functions

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

Static Public Attributes

static const std::string name = "constant"
 Name of constant.
 
static const std::type_index type = typeid(Constant)
 Type of constant.
 
- Static Public Attributes inherited from Node
static const std::vector< std::string > select_tags = { "NONE", "START", "END", "ALL" }
 

Private Member Functions

Virtual Private Member Functions
void xml_out (XML::Stream &xml) const
 
Frame calcSize (UI::Graphics &gc)
 
void calcOrig (UI::Graphics &gc, int x, int y)
 
void drawNode (UI::Graphics &gc) const
 
Complex getNodeValue () const
 

Private Attributes

char m_name
 Name of constant.
 
Complex m_value
 Value of constant.
 
Box m_internal
 Bounding box of this node.
 

Static Private Attributes

static const const_map constants
 Mapping of all constant name to their values. More...
 

Detailed Description

Represents a Constant factor node. Each Constant maps a name to a value implemented by a constant static map.

Constructor & Destructor Documentation

Constant::Constant ( Parser &  p,
Node *  parent 
)

Parser constructor for Constant class.

Parameters
pParser object.
parentParent node.
Constant::Constant ( char  name,
Complex  value,
Node *  parent,
bool  neg = false,
Node::Select  s = Node::Select::NONE 
)
inline

Constructor for Constant class.

Parameters
nameConstant name.
valueComplex value of constant.
parentParent node.
negIf true, node is negative.
sSelection state of node.
Constant::Constant ( EqnXMLParser &  in,
Node *  parent 
)

XML constructor for Constant class. Read in XML for Constant class.

Parameters
inXML input stream.
parentParent node object.
Constant::~Constant ( )
inline

Abstract base class needs virtual destructor.

Member Function Documentation

void Constant::calcOrig ( UI::Graphics &  gc,
int  x,
int  y 
)
privatevirtual

Calculate origin of this node offset from the point (x,y) given it.

Parameters
gcGraphics context.
xHorizontal origin.
yVertical origin.

Implements Node.

Node::Frame Constant::calcSize ( UI::Graphics &  gc)
privatevirtual

Calculate size of this node in given graphics context.

Parameters
gcGraphics context.
Returns
Return frame containing size of this node.

Implements Node.

void Constant::drawNode ( UI::Graphics &  gc) const
privatevirtual

Draw this node in the given graphical context.

Parameters
gcGraphical context.

Implements Node.

const std::string& Constant::getName ( ) const
inlinevirtual

Get name of this class.

Returns
Name of this class.

Implements Node.

Complex Constant::getNodeValue ( ) const
inlineprivatevirtual

Get value of this constant.

Returns
Complex value of this constant.

Implements Node.

std::type_index Constant::getType ( ) const
inlinevirtual

Get name of this class.

Returns
Name of this class.

Implements Node.

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

Static helper function to parse Constant class.

Parameters
pParser object pointing to operator.
parentParent node.
Returns
Constant object or null if constant not present.
std::string Constant::toString ( ) const
inlinevirtual

String representation of constant is its name.

Returns
Name of constant.

Implements Node.

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

Output XML of this node.

Parameters
xmlXML output stream.

Implements Node.

Member Data Documentation

const Constant::const_map Constant::constants
staticprivate
Initial value:
= {
{ 'e', Complex(exp(1.0), 0) },
{ 'P', Complex(4*atan(1.0), 0) },
{ 'i', Complex(0, 1) },
}

Mapping of all constant name to their values.


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