Calculator  Step 4
Public Member Functions | Private Member Functions | Private Attributes | List of all members
node_function Class Reference

#include <node_impl.hpp>

Inheritance diagram for node_function:
node_impl

Public Member Functions

 node_function (identifier_list parameters, node definition)
 
identifier_list const & parameters () const
 
node definition () const
 
- Public Member Functions inherited from node_impl
 node_impl ()
 
 node_impl (node_impl &&)=default
 
node_imploperator= (node_impl &&)=default
 
virtual ~node_impl ()
 
void print (std::ostream &stream, int indent) const
 
double evaluate () const
 
std::string to_string () const
 
identifier_list const & get_parameters () const
 

Private Member Functions

virtual void print_node (std::ostream &stream, int indent) const override
 
virtual double evaluate_node () const override
 
virtual identifier_list const & evaluate_parameters () const override
 

Private Attributes

identifier_list parameters_
 
node definition_
 

Detailed Description

Function definition. A function has parameters and a definition.

Definition at line 86 of file node_impl.hpp.

Constructor & Destructor Documentation

node_function::node_function ( identifier_list  parameters,
node  definition 
)

Definition at line 132 of file node_impl.cpp.

133 : node_impl{}, parameters_{std::move(parameters)}, definition_{definition}
134 {}
node definition_
Definition: node_impl.hpp:97
identifier_list parameters_
Definition: node_impl.hpp:96
identifier_list const & parameters() const
Definition: node_impl.cpp:136

Member Function Documentation

node node_function::definition ( ) const

Definition at line 142 of file node_impl.cpp.

References definition_.

Referenced by evaluate_node(), and print_node().

144 {
145  return definition_;
146 }
node definition_
Definition: node_impl.hpp:97
double node_function::evaluate_node ( ) const
overrideprivatevirtual

Implements node_impl.

Definition at line 168 of file node_impl.cpp.

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

170 {
171  return definition().evaluate();
172 }
node definition() const
Definition: node_impl.cpp:142
double evaluate() const
Definition: node.cpp:57
identifier_list const & node_function::evaluate_parameters ( ) const
overrideprivatevirtual

Reimplemented from node_impl.

Definition at line 174 of file node_impl.cpp.

References parameters().

176 {
177  return parameters();
178 }
identifier_list const & parameters() const
Definition: node_impl.cpp:136
identifier_list const & node_function::parameters ( ) const

Definition at line 136 of file node_impl.cpp.

References parameters_.

Referenced by evaluate_parameters(), and print_node().

138 {
139  return parameters_;
140 }
identifier_list parameters_
Definition: node_impl.hpp:96
void node_function::print_node ( std::ostream &  stream,
int  indent 
) const
overrideprivatevirtual

Implements node_impl.

Definition at line 159 of file node_impl.cpp.

References definition(), parameters(), node::print(), and print_identifier_list().

161 {
162  stream << std::setw(indent) << "" << "fun\n";
164  stream << '=';
165  definition().print(stream, indent + 2);
166 }
node definition() const
Definition: node_impl.cpp:142
void print(std::ostream &stream, int indent=0) const
Definition: node.cpp:51
void print_identifier_list(std::ostream &stream, identifier_list const &identifiers)
Definition: node_impl.cpp:148
identifier_list const & parameters() const
Definition: node_impl.cpp:136

Member Data Documentation

node node_function::definition_
private

Definition at line 97 of file node_impl.hpp.

Referenced by definition().

identifier_list node_function::parameters_
private

Definition at line 96 of file node_impl.hpp.

Referenced by parameters().


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