- Main Page
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# node_function Class Reference

`#include <node_impl.hpp>`

Inheritance diagram for node_function:

List of all members.

## Public Member Functions
| node_function (identifier_list const &parameters, node definition)
| node_function (std::istream &stream)
identifier_list const & | parameters () const
node | definition () const
## Private Member Functions
virtual void | print_node (std::ostream &stream, int indent) const
virtual double | evaluate_node () const
virtual identifier_list const & | evaluate_parameters () const
virtual void | save_node (std::ostream &stream) const
## Private Attributes
identifier_list | parameters_
node | definition_

## Detailed Description

Function definition. A function has parameters and a definition.

Definition at line 102 of file node_impl.hpp.

## Constructor & Destructor Documentation

node_function::node_function | ( | identifier_list const & | parameters,
|  | node | definition |
| ) |  |  |

Definition at line 215 of file node_impl.cpp.

    00216 : node_impl(), parameters_(parameters), definition_(definition)
    00217 {}

node_function::node_function | ( | std::istream & | stream | ) |

Definition at line 219 of file node_impl.cpp.

References definition_, and parameters_.

    00220 : node_impl()
    00221 {
    00222   std::size_t size;
    00223   if (not (stream >> size))
    00224     throw calc_error("malformed library file, cannot read function");
    00225   parameters_.reserve(size);
    00226   while (size-- != 0) {
    00227     std::string parameter;
    00228     if (not (stream >> parameter))
    00229       throw calc_error("malformed library file, cannot read function parameter");
    00230     parameters_.push_back(parameter);
    00231   }
    00232   definition_ = node(stream);
    00233 }

## Member Function Documentation

identifier_list const & node_function::parameters | ( |  | ) | const

Definition at line 235 of file node_impl.cpp.

References parameters_.

Referenced by evaluate_parameters(), print_node(), and save_node().

    00237 {
    00238   return parameters_;
    00239 }

node node_function::definition | ( |  | ) | const

Definition at line 241 of file node_impl.cpp.

References definition_.

Referenced by evaluate_node(), print_node(), and save_node().

    00243 {
    00244   return definition_;
    00245 }

void node_function::print_node | ( | std::ostream & | stream,
|  | int | indent |
| ) |  |  | const`[private, virtual]`

Implements node_impl.

Definition at line 258 of file node_impl.cpp.

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

    00260 {
    00261   stream << std::setw(indent) << "" << "fun\n";
    00262   print_identifier_list(stream, parameters());
    00263   stream << '=';
    00264   definition().print(stream, indent + 2);
    00265 }

double node_function::evaluate_node | ( |  | ) | const`[private, virtual]`

Implements node_impl.

Definition at line 267 of file node_impl.cpp.

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

    00269 {
    00270   return definition().evaluate();
    00271 }

identifier_list const & node_function::evaluate_parameters | ( |  | ) | const`[private, virtual]`

Reimplemented from node_impl.

Definition at line 273 of file node_impl.cpp.

References parameters().

    00275 {
    00276   return parameters();
    00277 }

void node_function::save_node | ( | std::ostream & | stream | ) | const`[private, virtual]`

Implements node_impl.

Definition at line 279 of file node_impl.cpp.

References definition(), parameters(), and node::save().

    00281 {
    00282   stream << "function " << parameters().size() << ' ';
    00283   std::copy(parameters().begin(), parameters().end(), std::ostream_iterator<std::string>(stream, " "));
    00284   definition().save(stream);
    00285 }

## Member Data Documentation

identifier_list node_function::parameters_`[private]`

Definition at line 114 of file node_impl.hpp.

Referenced by node_function(), and parameters().

node node_function::definition_`[private]`

Definition at line 115 of file node_impl.hpp.

Referenced by definition(), and node_function().

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

- node_impl.hpp
- node_impl.cpp