openvrml::node_metatype Class Referenceabstract

A class object for node instances. More...

#include <openvrml/node.h>

Inheritance diagram for openvrml::node_metatype:

Public Member Functions

virtual ~node_metatype ()=0 throw ()
 Destructor. More...
 
const node_metatype_idid () const throw ()
 Identifier. More...
 
openvrml::browserbrowser () const throw ()
 The browser associated with this node_metatype. More...
 
void initialize (viewpoint_node *initial_viewpoint, double time) throw ()
 node_metatype-specific initialization. More...
 
void render (viewer &v) const throw ()
 node_metatype-specific rendering. More...
 
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. More...
 
void shutdown (double time) throw ()
 Shut down. More...
 

Protected Member Functions

 node_metatype (const node_metatype_id &id, openvrml::browser &b) throw ()
 Constructor. More...
 

Private Member Functions

virtual void do_initialize (viewpoint_node *initial_viewpoint, double time) throw ()
 node_metatype-specific initialization. More...
 
virtual void do_render (viewer &v) const throw ()
 node_metatype-specific rendering. More...
 
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. More...
 
virtual void do_shutdown (double time) throw ()
 Shut down. More...
 

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 (
)
explicitprotected

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]idan identifier unique to b.
[in]bthe 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_viewpointthe viewpoint_node that should be bound initially; or 0 if the default viewpoint_node should be bound.
[in]timethe current time.
void openvrml::node_metatype::render ( viewer v) const
throw (
)

node_metatype-specific rendering.

This function delegates to do_render.

Parameters
[in,out]vthe 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]idthe name for the new node_type.
[in]interfacesa node_interface_set containing the interfaces for the new type.
Returns
a newly created node_type.
Exceptions
unsupported_interfaceif the node_metatype cannot support one of the node_interfaces in interfaces.
std::bad_allocif 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]timethe current time.
void openvrml::node_metatype::do_initialize ( viewpoint_node initial_viewpoint,
double  time 
)
throw (
)
privatevirtual

node_metatype-specific initialization.

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

Parameters
[in,out]initial_viewpointthe viewpoint_node that should be bound initially; or 0 if the default viewpoint_node should be bound.
[in]timethe current time.
See also
node_metatype::initialize
void openvrml::node_metatype::do_render ( viewer v) const
throw (
)
privatevirtual

node_metatype-specific rendering.

The default implementation of this method does nothing.

Parameters
[in,out]vthe 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
)
privatepure virtual

Create a new node_type.

Parameters
[in]idthe name for the new node_type.
[in]interfacesa node_interface_set containing the interfaces for the new type.
Returns
a newly created node_type.
Exceptions
unsupported_interfaceif the node_metatype cannot support one of the node_interfaces in interfaces.
std::bad_allocif 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 (
)
privatevirtual

Shut down.

This function is called by shutdown.

Parameters
[in]timethe current time.