Home | Download | Screen shots | Discussion | Documentation
--- | --- | --- | --- | ---

Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

# openvrml::node_ptr Class Reference

List of all members.

## Detailed Description

A reference-counted smart pointer for nodes.

## Public Member Functions

| node_ptr (node *node=0) throw (std::bad_alloc)
| Construct.
| node_ptr (const node_ptr &ptr) throw ()
| Construct a copy.
| ~node_ptr () throw ()
| Destructor.
| operator bool () const throw ()
| Automatic conversion to bool.
node_ptr & | operator= (const node_ptr &ptr) throw ()
| Assignment operator.
node & | operator * () const throw ()
| Dereference operator.
node * | operator-> () const throw ()
| Access a method of the node.
node * | get () const throw ()
| Get a raw pointer to the node.
void | reset (node *node=0) throw (std::bad_alloc)
| Reset the node_ptr to point to a different node.
void | swap (node_ptr &ptr) throw ()
| Swap the values of the node_ptr and `ptr`.

## Static Public Attributes

static const node_ptr | self
| Special value used when initializing a script_node.

## Private Member Functions

void | dispose () throw ()
| Relinquish ownership of the node.
void | share (std::map< node *, size_t >::value_type *count_ptr) throw ()
| Share ownership of a node.

## Private Attributes

std::map< node *, size_t >::value_type * | count_ptr
| Pointer to an entry in count_map.

## Friends

class | script_node
| Script nodes can be self-referential, so node_ptr works some special magic.
bool | operator== (const node_ptr &lhs, const node_ptr &rhs) throw ()
| Compare for equality.

## Related Functions

(Note that these are not member functions.)
bool | operator!= (const node_ptr &lhs, const node_ptr &rhs) throw()
| Compare for inequality.

## Constructor & Destructor Documentation

openvrml::node_ptr::node_ptr | ( | node * | node = `0` | ) | throw (std::bad_alloc)`[explicit]`

Construct.

Parameters:

  | node | a pointer to a node

Exceptions:

  | std::bad_alloc | if memory allocation fails.

openvrml::node_ptr::node_ptr | ( | const node_ptr & | ptr | ) | throw ()

Construct a copy.

Parameters:

  | ptr |

openvrml::node_ptr::~node_ptr | ( |  | ) | throw ()`[inline]`

| Destructor.

## Member Function Documentation

openvrml::node_ptr::operator bool | ( |  | ) | const throw ()`[inline]`

| Automatic conversion to bool.

node_ptr & openvrml::node_ptr::operator= | ( | const node_ptr & | ptr | ) | throw ()`[inline]`

Assignment operator.

Parameters:

  | ptr |

node & openvrml::node_ptr::operator * | ( |  | ) | const throw ()`[inline]`

Dereference operator.

Returns:
  a reference to the underlying node.

node * openvrml::node_ptr::operator-> | ( |  | ) | const throw ()`[inline]`

| Access a method of the node.

node * openvrml::node_ptr::get | ( |  | ) | const throw ()`[inline]`

Get a raw pointer to the node.

Returns:
  a raw pointer to the underlying node.

void openvrml::node_ptr::reset | ( | node * | node = `0` | ) | throw (std::bad_alloc)

Reset the node_ptr to point to a different node.

Parameters:

  | node |

Exceptions:

  | std::bad_alloc | if memory allocation fails.

void openvrml::node_ptr::swap | ( | node_ptr & | ptr | ) | throw ()`[inline]`

| Swap the values of the node_ptr and `ptr`.

void openvrml::node_ptr::dispose | ( |  | ) | throw ()`[private]`

| Relinquish ownership of the node. Decrement the reference count; if it drops to zero, call node::shutdown on the node, delete the node, and remove its entry from the count map.

void openvrml::node_ptr::share | ( | std::map< node *, size_t >::value_type * | count_ptr | ) | throw ()`[private]`

Share ownership of a node.

Parameters:

  | count_ptr | a pointer to an entry in the count map to share.

## Friends And Related Function Documentation

openvrml::node_ptr::script_node`[friend]`

| Script nodes can be self-referential, so node_ptr works some special magic.

bool operator== | ( | const node_ptr & | lhs,
|  | const node_ptr & | rhs
| ) | throw ()`[friend]`

Compare for equality.

Parameters:

  | lhs | left-hand operand.
  | rhs | right-hand operand.

Returns:
  `true` if `lhs` and `rhs` point to the same node; `false` otherwise.

bool operator!= | ( | const node_ptr & | lhs,
|  | const node_ptr & | rhs
| ) | throw()`[related]`

Compare for inequality.

Parameters:

  | lhs | left-hand operand.
  | rhs | right-hand operand.

Returns:
  `true` if `lhs` and `rhs` point to different nodes; `false` otherwise.

## Member Data Documentation

std::map< node *, size_t >::value_type * openvrml::node_ptr::count_ptr `[private]`

| Pointer to an entry in count_map. For internal use only.

const node_ptr openvrml::node_ptr::self `[static]`

| Special value used when initializing a script_node. One should never attempt to dereference this value. It is useful only for comparison.