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

# openvrml::node_metatype Class Reference

A class object for node instances. More...

`#include <openvrml/node.h>`

Inheritance diagram for openvrml::node_metatype:
[legend]

List of all members.

## Public Member Functions
virtual | ~node_metatype ()=0 throw ()
| Destructor.
const node_metatype_id & | id () const throw ()
| Identifier.
openvrml::browser & | browser () const throw ()
| The `browser` associated with this `node_metatype`.
void | initialize (viewpoint_node *initial_viewpoint, double time) throw ()
| `node_metatype`-specific initialization.
void | render (viewer &v) const throw ()
| `node_metatype`-specific rendering.
const boost::shared_ptr < node_type > | create_type (const std::string &id, const node_interface_set &interfaces) throw ( unsupported_interface , std::bad_alloc )
| Create a new `node_type`.
void | shutdown (double time) throw ()
| Shut down.
## Protected Member Functions
| node_metatype (const node_metatype_id &id, openvrml::browser &b) throw ()
| Constructor.
## Private Member Functions
virtual void | do_initialize (viewpoint_node *initial_viewpoint, double time) throw ()
| `node_metatype`-specific initialization.
virtual void | do_render (viewer &v) const throw ()
| `node_metatype`-specific rendering.
virtual const boost::shared_ptr< node_type > | do_create_type (const std::string &id, const node_interface_set &interfaces) const =0 throw ( unsupported_interface , std::bad_alloc )
| Create a new `node_type`.
virtual void | do_shutdown (double time) throw ()
| Shut down.
## Private Attributes
const node_metatype_id | id_
| `node_metatype` identifier.
openvrml::browser *const | browser_
| The `browser` associated with this `node_metatype`.

## Detailed Description

A class object for node instances.

`node_metatype` can be thought of as a “supertype” of sorts. A given node implementation can support as many node types as there are unique combinations of the interfaces it supports. The most readily apparent role of the `node_metatype` object for a node implementation is to serve as a factory for these `node_types`.

## Constructor & Destructor Documentation

openvrml::node_metatype::~node_metatype | ( |  | ) | throw ()`[pure virtual]`

Destructor.

openvrml::node_metatype::node_metatype | ( | const node_metatype_id & | id,
|  | openvrml::browser & | b |
| ) |  |  | throw ()`[explicit, protected]`

Constructor.

A `node_metatype` is constructed using a `browser`. All `node` instances that share a particular `node_metatype` “belong to” the `browser` associated with the `node_metatype`.

Parameters:

  `[in]` | id | an identifier unique to `b`.
  `[in]` | b | the `browser` to be associated with the `node_metatype`.

## Member Function Documentation

const openvrml::node_metatype_id & openvrml::node_metatype::id | ( |  | ) | const throw ()

Identifier.

Returns:
  the `node_metatype` identifier.

openvrml::browser & openvrml::node_metatype::browser | ( |  | ) | const throw ()

The `browser` associated with this `node_metatype`.

Returns:
  the `browser` associated with this `node_metatype`.

void openvrml::node_metatype::initialize | ( | viewpoint_node * | initial_viewpoint,
|  | double | time |
| ) |  |  | throw ()

`node_metatype`-specific initialization.

This method is called during initialization of a `browser` object with a new root `scene`. It is called after the individual `node` instances have been initialized, and before the world starts running. It delegates to `do_initialize`.

Parameters:

  `[in,out]` | initial_viewpoint | the `viewpoint_node` that should be bound initially; or 0 if the default `viewpoint_node` should be bound.
  `[in]` | time | the current time.

void openvrml::node_metatype::render | ( | viewer & | v | ) | const throw ()

`node_metatype`-specific rendering.

This function delegates to `do_render`.

Parameters:

  `[in,out]` | v | the `viewer` to which to render.

const boost::shared_ptr< openvrml::node_type > openvrml::node_metatype::create_type | ( | const std::string & | id,
|  | const node_interface_set & | interfaces |
| ) |  |  | throw ( unsupported_interface , std::bad_alloc )

Create a new `node_type`.

`node_types` can be said to subset the master type provided by the `node_metatype`. Each `node_metatype` instance can support certain `node` interfaces; the `node_interface_set` passed to `create_type` must be a subset of those supported interfaces.

This function delegates to `do_create_type`.

Parameters:

  `[in]` | id | the name for the new `node_type`.
  `[in]` | interfaces | a `node_interface_set` containing the interfaces for the new type.

Returns:
  a newly created `node_type`.

Exceptions:

  | unsupported_interface | if the `node_metatype` cannot support one of the `node_interfaces` in `interfaces`.
  | std::bad_alloc | if memory allocation fails.

See also:
  http://boost.org/libs/smart_ptr/shared_ptr.htm

void openvrml::node_metatype::shutdown | ( | double | time | ) | throw ()

Shut down.

This function is called during destruction of the `browser`, after the root `scene` has been shut down. This function delegates to `do_shutdown`.

Parameters:

  `[in]` | time | the current time.

void openvrml::node_metatype::do_initialize | ( | viewpoint_node * | initial_viewpoint,
|  | double | time |
| ) |  |  | throw ()`[private, virtual]`

`node_metatype`-specific initialization.

Node implementations should override this method to perform any `node_metatype`-wide initialization.

Parameters:

  `[in,out]` | initial_viewpoint | the `viewpoint_node` that should be bound initially; or 0 if the default `viewpoint_node` should be bound.
  `[in]` | time | the current time.

See also:
  node_metatype::initialize

void openvrml::node_metatype::do_render | ( | viewer & | v | ) | const throw ()`[private, virtual]`

`node_metatype`-specific rendering.

The default implementation of this method does nothing.

Parameters:

  `[in,out]` | v | the `viewer` to which to render.

See also:
  node_metatype::render

const boost::shared_ptr< openvrml::node_type > openvrml::node_metatype::do_create_type | ( | const std::string & | id,
|  | const node_interface_set & | interfaces |
| ) |  |  | const throw ( unsupported_interface , std::bad_alloc )`[private, pure virtual]`

Create a new `node_type`.

Parameters:

  `[in]` | id | the name for the new `node_type`.
  `[in]` | interfaces | a `node_interface_set` containing the interfaces for the new type.

Returns:
  a newly created `node_type`.

Exceptions:

  | unsupported_interface | if the `node_metatype` cannot support one of the `node_interfaces` in `interfaces`.
  | std::bad_alloc | if memory allocation fails.

See also:
  create_type
  http://boost.org/libs/smart_ptr/shared_ptr.htm

Implemented in openvrml::null_node_metatype, and openvrml::script_node_metatype.

void openvrml::node_metatype::do_shutdown | ( | double | time | ) | throw ()`[private, virtual]`

Shut down.

This function is called by `shutdown`.

Parameters:

  `[in]` | time | the current time.

## Member Data Documentation

const std::string openvrml::node_metatype::id_`[private]`

`node_metatype` identifier.

For internal use only.

openvrml::browser *const openvrml::node_metatype::browser_`[private]`

The `browser` associated with this `node_metatype`.

For internal use only.