node_impl Class Reference

#include <node_impl.hpp>

Inheritance diagram for node_impl:

node_binary node_function node_function_call node_identifier node_number node_unary node_void node_add node_divide node_multiply node_subtract node_negate

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
identifier_list const & get_parameters () const
void add_ref ()
void del_ref ()

Private Member Functions

 node_impl (node_impl const &n)
 not implemented
node_imploperator= (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
virtual
identifier_list
const & 
evaluate_parameters () 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 11 of file node_impl.cpp.

00012 : refcount_(1)
00013 {}

node_impl::~node_impl (  )  [virtual]

Definition at line 15 of file node_impl.cpp.

00016 {}

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 18 of file node_impl.cpp.

References print_node().

Referenced by node::print().

00020 {
00021   print_node(stream, indent);
00022 }

double node_impl::evaluate (  )  const

Definition at line 24 of file node_impl.cpp.

References evaluate_node().

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

00026 {
00027   return evaluate_node();
00028 }

std::string node_impl::to_string (  )  const

Definition at line 30 of file node_impl.cpp.

References evaluate_string().

Referenced by node::to_string().

00032 {
00033   return evaluate_string();
00034 }

identifier_list const & node_impl::get_parameters (  )  const

Definition at line 41 of file node_impl.cpp.

References evaluate_parameters().

Referenced by node::get_parameters().

00043 {
00044   return evaluate_parameters();
00045 }

void node_impl::add_ref (  ) 

Definition at line 36 of file node_impl.cpp.

References refcount_.

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

00037 {
00038   ++refcount_;
00039 }

void node_impl::del_ref (  ) 

Definition at line 47 of file node_impl.cpp.

References refcount_.

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

00048 {
00049   --refcount_;
00050   if (refcount_ == 0)
00051     delete this;
00052 }

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_function, node_function_call, 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_function, node_function_call, 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 54 of file node_impl.cpp.

References evaluate().

Referenced by to_string().

00056 {
00057   std::ostringstream stream;
00058   stream << evaluate();
00059   return stream.str();
00060 }

identifier_list const & node_impl::evaluate_parameters (  )  const [private, virtual]

Reimplemented in node_function.

Definition at line 62 of file node_impl.cpp.

Referenced by get_parameters().

00064 {
00065   static identifier_list const empty;
00066   return empty;
00067 }


Member Data Documentation

std::size_t node_impl::refcount_ [private]

Definition at line 44 of file node_impl.hpp.

Referenced by add_ref(), and del_ref().


The documentation for this class was generated from the following files:
Generated on Sun Nov 30 10:05:28 2008 for Calculator by  doxygen 1.5.3