Calculator  Step 6
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
node_binary Class Referenceabstract

#include <node_impl.hpp>

Inheritance diagram for node_binary:
node_impl node_add node_divide node_multiply node_subtract

Public Member Functions

 node_binary (node left, node right)
 
node left () const
 
node right () const
 
- Public Member Functions inherited from node_impl
 node_impl ()
 
virtual ~node_impl ()
 
 node_impl (node_impl &&)=default
 
node_imploperator= (node_impl &&)=default
 
void print (std::ostream &stream, int indent) const
 
number evaluate () const
 
std::string to_string () const
 
identifier_list const & get_parameters () const
 
void save (std::ostream &stream) const
 

Protected Member Functions

 node_binary (std::istream &stream)
 
number evaluate_left () const
 
number evaluate_right () const
 

Private Member Functions

virtual void print_node (std::ostream &stream, int indent) const override=0
 
virtual number evaluate_node () const override=0
 
virtual void save_node (std::ostream &stream) const override=0
 

Private Attributes

node left_
 
node right_
 

Additional Inherited Members

- Static Public Member Functions inherited from node_impl
static std::shared_ptr< node_implread_node (std::istream &stream)
 

Detailed Description

Abstract base class for binary operators.

Definition at line 150 of file node_impl.hpp.

Constructor & Destructor Documentation

node_binary::node_binary ( node  left,
node  right 
)

Definition at line 371 of file node_impl.cpp.

372 : node_impl{}, left_{left}, right_{right}
373 {}
node_binary::node_binary ( std::istream &  stream)
protected

Definition at line 375 of file node_impl.cpp.

376 : node_impl{}, left_{stream}, right_{stream}
377 {}

Member Function Documentation

number node_binary::evaluate_left ( ) const
protected

Definition at line 391 of file node_impl.cpp.

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

Referenced by node_add::evaluate_node(), node_subtract::evaluate_node(), node_multiply::evaluate_node(), and node_divide::evaluate_node().

393 {
394  return left().evaluate();
395 }
number evaluate() const
Definition: node.cpp:73
node left() const
Definition: node_impl.cpp:379
virtual number node_binary::evaluate_node ( ) const
overrideprivatepure virtual

Implements node_impl.

Implemented in node_divide, node_multiply, node_subtract, and node_add.

number node_binary::evaluate_right ( ) const
protected

Definition at line 397 of file node_impl.cpp.

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

Referenced by node_add::evaluate_node(), node_subtract::evaluate_node(), node_multiply::evaluate_node(), and node_divide::evaluate_node().

399 {
400  return right().evaluate();
401 }
node right() const
Definition: node_impl.cpp:385
number evaluate() const
Definition: node.cpp:73
node node_binary::left ( ) const
virtual void node_binary::print_node ( std::ostream &  stream,
int  indent 
) const
overrideprivatepure virtual

Implements node_impl.

Implemented in node_divide, node_multiply, node_subtract, and node_add.

node node_binary::right ( ) const
virtual void node_binary::save_node ( std::ostream &  stream) const
overrideprivatepure virtual

Implements node_impl.

Implemented in node_divide, node_multiply, node_subtract, and node_add.

Member Data Documentation

node node_binary::left_
private

Definition at line 164 of file node_impl.hpp.

Referenced by left().

node node_binary::right_
private

Definition at line 165 of file node_impl.hpp.

Referenced by right().


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