- Main Page
- Classes
- Files

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

# node_impl Class Reference

`#include <node_impl.hpp>`

Inheritance diagram for node_impl:

List of all members.

## Public Member Functions
| node_impl ()
virtual | ~node_impl ()
void | print (std::ostream &stream, int indent) const
double | evaluate () const
std::string | to_string () const
void | add_ref ()
void | del_ref ()
## Private Member Functions
| node_impl (node_impl const &n)
| not implemented
node_impl & | operator= (node_impl const &n)
| not implemented
virtual void | print_node (std::ostream &stream, int indent) const =0
virtual double | evaluate_node () const =0
virtual std::string | evaluate_string () const
## Private Attributes
std::size_t | refcount_

## Detailed Description

Base class for all parse tree nodes. The node classes all derive from node_impl. Each derived class overrides print_node(), for debugging and evalute_node() to evaluate the node. A few classes also override evaluate_string(), but most classes can inherit the node_impl::evaluate_string implementation, which prints the result of calling evaluate().

This class primarily manages the reference count.

Definition at line 19 of file node_impl.hpp.

## Constructor & Destructor Documentation

node_impl::node_impl | ( |  | ) |

Definition at line 9 of file node_impl.cpp.

    00010 : refcount_(1)
    00011 {}

node_impl::~node_impl | ( |  | ) | `[virtual]`

Definition at line 13 of file node_impl.cpp.

    00014 {}

node_impl::node_impl | ( | node_impl const & | n | ) | `[private]`

not implemented

## Member Function Documentation

void node_impl::print | ( | std::ostream & | stream,
|  | int | indent |
| ) |  |  | const

Definition at line 16 of file node_impl.cpp.

References print_node().

Referenced by node::print().

    00018 {
    00019   print_node(stream, indent);
    00020 }

double node_impl::evaluate | ( |  | ) | const

Definition at line 22 of file node_impl.cpp.

References evaluate_node().

Referenced by node::evaluate(), and evaluate_string().

    00024 {
    00025   return evaluate_node();
    00026 }

std::string node_impl::to_string | ( |  | ) | const

Definition at line 28 of file node_impl.cpp.

References evaluate_string().

Referenced by node::to_string().

    00030 {
    00031   return evaluate_string();
    00032 }

void node_impl::add_ref | ( |  | ) |

Definition at line 34 of file node_impl.cpp.

References refcount_.

Referenced by node::node(), and node::operator=().

    00035 {
    00036   ++refcount_;
    00037 }

void node_impl::del_ref | ( |  | ) |

Definition at line 39 of file node_impl.cpp.

References refcount_.

Referenced by node::operator=(), and node::~node().

    00040 {
    00041   --refcount_;
    00042   if (refcount_ == 0)
    00043     delete this;
    00044 }

node_impl& node_impl::operator= | ( | node_impl const & | n | ) | `[private]`

not implemented

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

Implemented in node_void, node_number, node_identifier, node_assign, node_unary, node_binary, node_negate, node_add, node_subtract, node_multiply, and node_divide.

Referenced by print().

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

Implemented in node_void, node_number, node_identifier, node_assign, node_unary, node_binary, node_negate, node_add, node_subtract, node_multiply, and node_divide.

Referenced by evaluate().

std::string node_impl::evaluate_string | ( |  | ) | const`[private, virtual]`

Reimplemented in node_void, and node_identifier.

Definition at line 46 of file node_impl.cpp.

References evaluate().

Referenced by to_string().

    00048 {
    00049   std::ostringstream stream;
    00050   stream << evaluate();
    00051   return stream.str();
    00052 }

## Member Data Documentation

std::size_t node_impl::refcount_`[private]`

Definition at line 41 of file node_impl.hpp.

Referenced by add_ref(), and del_ref().

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

- node_impl.hpp
- node_impl.cpp