Calculator  Step 3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
node_assign Class Reference

#include <node_impl.hpp>

Inheritance diagram for node_assign:
node_impl

Public Member Functions

 node_assign (node identifier, node value)
 
node identifier () const
 
node value () const
 
- Public Member Functions inherited from node_impl
 node_impl ()
 
virtual ~node_impl ()
 
void print (std::ostream &stream, int indent) const
 
double evaluate () const
 
std::string to_string () const
 

Private Member Functions

std::string get_identifier () const
 
double evaluate_value () const
 
virtual void print_node (std::ostream &stream, int indent) const override
 
virtual double evaluate_node () const override
 

Private Attributes

node identifier_
 
node value_
 

Detailed Description

Assignment Keep track of an identifier and a value.

Definition at line 81 of file node_impl.hpp.

Constructor & Destructor Documentation

node_assign::node_assign ( node  identifier,
node  value 
)

Definition at line 117 of file node_impl.cpp.

118 : node_impl{}, identifier_{identifier}, value_{value}
119 {}
node identifier_
Definition: node_impl.hpp:93

Member Function Documentation

double node_assign::evaluate_node ( ) const
overrideprivatevirtual

Implements node_impl.

Definition at line 152 of file node_impl.cpp.

References evaluate_value(), get_identifier(), and set_variable().

154 {
155  double result( evaluate_value() );
156  set_variable(get_identifier(), result);
157  return result;
158 }
void set_variable(std::string name, double value)
Definition: variables.cpp:23
std::string get_identifier() const
Definition: node_impl.cpp:133
double evaluate_value() const
Definition: node_impl.cpp:139
double node_assign::evaluate_value ( ) const
private

Definition at line 139 of file node_impl.cpp.

References node::evaluate(), and value().

Referenced by evaluate_node().

141 {
142  return value().evaluate();
143 }
node value() const
Definition: node_impl.cpp:127
double evaluate() const
Definition: node.cpp:50
std::string node_assign::get_identifier ( ) const
private

Definition at line 133 of file node_impl.cpp.

References identifier(), and node::to_string().

Referenced by evaluate_node(), and print_node().

135 {
136  return identifier().to_string();
137 }
node identifier() const
Definition: node_impl.cpp:121
std::string to_string() const
Definition: node.cpp:56
node node_assign::identifier ( ) const

Definition at line 121 of file node_impl.cpp.

References identifier_.

Referenced by get_identifier().

123 {
124  return identifier_;
125 }
node identifier_
Definition: node_impl.hpp:93
void node_assign::print_node ( std::ostream &  stream,
int  indent 
) const
overrideprivatevirtual

Implements node_impl.

Definition at line 145 of file node_impl.cpp.

References get_identifier(), node::print(), and value().

147 {
148  stream << std::setw(indent) << "" << get_identifier() << ":=\n";
149  value().print(stream, indent + 2);
150 }
node value() const
Definition: node_impl.cpp:127
std::string get_identifier() const
Definition: node_impl.cpp:133
void print(std::ostream &stream, int indent=0) const
Definition: node.cpp:44
node node_assign::value ( ) const

Definition at line 127 of file node_impl.cpp.

References value_.

Referenced by evaluate_value(), and print_node().

129 {
130  return value_;
131 }

Member Data Documentation

node node_assign::identifier_
private

Definition at line 93 of file node_impl.hpp.

Referenced by identifier().

node node_assign::value_
private

Definition at line 94 of file node_impl.hpp.

Referenced by value().


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