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

- Main Page
- Namespaces
- Classes
- Files
- Related Pages
- Examples

- Class List
- Class Hierarchy
- Class Members

# openvrml::script_node Class Reference

`#include <openvrml/script.h>`

Inheritance diagram for openvrml::script_node:

[legend]

List of all members.

## Detailed Description

Represents a VRML Script node.

## Public Types

typedef std::map< std::string, boost::shared_ptr < field_value > > | field_value_map_t
| A `std::map` that keys field values on their field name.
typedef boost::shared_ptr < eventout > | eventout_ptr
| Reference-counted smart pointer to an `eventout`.
typedef std::map< std::string, eventout_ptr > | eventout_map_t
| Map of `eventout` instances.

## Public Member Functions

| script_node (script_node_metatype &class_, const boost::shared_ptr< openvrml::scope > &scope, const node_interface_set &interfaces, const initial_value_map &initial_values) throw ( unsupported_interface , std::bad_cast , std::bad_alloc , std::invalid_argument )
| Construct.
virtual | ~script_node () throw ()
| Destroy.
void | update (double current_time)
| Update the script_node for the current time.
const field_value_map_t & | field_value_map () const throw ()
| Field value map accessor.
const eventout_map_t & | eventout_map () const throw ()
| `eventOut` map accessor.

## Private Types

typedef script_event_listener < sfbool > | sfbool_listener
| `sfbool` event listener.
typedef script_event_listener < sfcolor > | sfcolor_listener
| `sfcolor` event listener.
typedef script_event_listener < sfcolorrgba > | sfcolorrgba_listener
| `sfcolorrgba` event listener.
typedef script_event_listener < sffloat > | sffloat_listener
| `sffloat` event listener.
typedef script_event_listener < sfdouble > | sfdouble_listener
| `sfdouble` event listener.
typedef script_event_listener < sfimage > | sfimage_listener
| `sfimage` event listener.
typedef script_event_listener < sfint32 > | sfint32_listener
| `sfint32` event listener.
typedef script_event_listener < sfnode > | sfnode_listener
| `sfnode` event listener.
typedef script_event_listener < sfrotation > | sfrotation_listener
| `sfrotation` event listener.
typedef script_event_listener < sfstring > | sfstring_listener
| `sfstring` event listener.
typedef script_event_listener < sftime > | sftime_listener
| `sftime` event listener.
typedef script_event_listener < sfvec2f > | sfvec2f_listener
| `sfvec2f` event listener.
typedef script_event_listener < sfvec2d > | sfvec2d_listener
| `sfvec2d` event listener.
typedef script_event_listener < sfvec3f > | sfvec3f_listener
| `sfvec3f` event listener.
typedef script_event_listener < sfvec3d > | sfvec3d_listener
| `sfvec3d` event listener.
typedef script_event_listener < mfbool > | mfbool_listener
| `mfbool` event listener.
typedef script_event_listener < mfcolor > | mfcolor_listener
| `mfcolor` event listener.
typedef script_event_listener < mfcolorrgba > | mfcolorrgba_listener
| `mfcolorrgba` event listener.
typedef script_event_listener < mffloat > | mffloat_listener
| `mffloat` event listener.
typedef script_event_listener < mfdouble > | mfdouble_listener
| `mfdouble` event listener.
typedef script_event_listener < mfimage > | mfimage_listener
| `mfimage` event listener.
typedef script_event_listener < mfint32 > | mfint32_listener
| `mfint32` event listener.
typedef script_event_listener < mfnode > | mfnode_listener
| `mfnode` event listener.
typedef script_event_listener < mfrotation > | mfrotation_listener
| `mfrotation` event listener.
typedef script_event_listener < mfstring > | mfstring_listener
| `mfstring` event listener.
typedef script_event_listener < mftime > | mftime_listener
| `mftime` event listener.
typedef script_event_listener < mfvec2f > | mfvec2f_listener
| `mfvec2f` event listener.
typedef script_event_listener < mfvec2d > | mfvec2d_listener
| `mfvec2d` event listener.
typedef script_event_listener < mfvec3f > | mfvec3f_listener
| `mfvec3f` event listener.
typedef script_event_listener < mfvec3d > | mfvec3d_listener
| `mfvec3d` event listener.
typedef boost::shared_ptr < openvrml::event_listener > | event_listener_ptr
| Reference-counted smart pointer to an event_listener.
typedef std::map< std::string, event_listener_ptr > | event_listener_map_t
| Map of event listeners.

## Private Member Functions

script * | create_script ()
| Create a script object.
void | assign_with_self_ref_check (const sfnode &, sfnode &) const throw ()
| Special assignment function to take into account the fact that Script nodes can be self-referential.
void | assign_with_self_ref_check (const mfnode &, mfnode &) const throw ()
| Special assignment function to take into account the fact that Script nodes can be self referential.
virtual script_node * | to_script () throw ()
| Return a pointer to this `script_node`.
virtual void | do_initialize (double timestamp) throw ( std::bad_alloc )
| Initialize.
virtual const field_value & | do_field (const std::string &id) const throw ( unsupported_interface )
| Get the value of a field.
virtual openvrml::event_listener & | do_event_listener (const std::string &id) throw ( unsupported_interface )
| Get an event listener.
virtual openvrml::event_emitter & | do_event_emitter (const std::string &id) throw ( unsupported_interface )
| Get an event emitter.
virtual void | do_shutdown (double timestamp) throw ()
| Called by `node::shutdown`.
virtual void | do_render_child (viewer &v, rendering_context context)
| `node::render_child` implementation.

## Static Private Member Functions

static const boost::shared_ptr < openvrml::event_listener > | create_listener (field_value::type_id type, const std::string &id, script_node &node) throw ( std::bad_alloc )
| Create a Script node event listener.
static std::auto_ptr < openvrml::event_emitter > | create_emitter (script_node &node, const field_value &value) throw ( std::bad_alloc )
| Create a Script node event emitter.

## Private Attributes

script_node_type | type
| Type object for the `script_node` instance.
set_metadata_listener | set_metadata_listener_
| `set_metadata` `eventIn` handler.
sfnode | metadata_
| `metadata` field value.
metadata_changed_emitter | metadata_changed_emitter_
| `metadata_changed` `eventOut` emitter.
sfbool | direct_output
| `directOutput` field.
sfbool | must_evaluate
| `mustEvaluate` field.
set_url_listener_t | set_url_listener
| `set_url` `eventIn` handler.
mfstring | url_
| `url` `exposedField`.
url_changed_emitter | url_changed_emitter_
| url_changed eventOut emitter.
field_value_map_t | field_value_map_
| Maps user-defined field names to their values.
event_listener_map_t | event_listener_map
| Map of event listeners.
eventout_map_t | eventout_map_
| Map of eventout instances.
script * | script_
| A pointer to a script object.
int | events_received
| A count of the number of events received since `update` was called.

## Friends

class | script
| Abstract base class for script runtimes.

## Classes

class | eventout
| An `event_emitter` along with the emitted value. More...
class | metadata_changed_emitter
| `metadata_changed` event emitter. More...
class | script_node_type
| Type objects for `script_nodes`. More...
class | set_metadata_listener
| `set_metadata` event listener. More...
class | set_url_listener_t
| `set_url` event listener. More...
class | url_changed_emitter
| `url_changed` event emitter. More...

## Member Typedef Documentation

openvrml::script_node::field_value_map_t

A `std::map` that keys field values on their field name.

openvrml::script_node::eventout_ptr

Reference-counted smart pointer to an `eventout`.

openvrml::script_node::eventout_map_t

Map of `eventout` instances.

openvrml::script_node::sfbool_listener `[private]`

`sfbool` event listener.

For internal use only.

openvrml::script_node::sfcolor_listener `[private]`

`sfcolor` event listener.

For internal use only.

openvrml::script_node::sfcolorrgba_listener `[private]`

`sfcolorrgba` event listener.

For internal use only.

openvrml::script_node::sffloat_listener `[private]`

`sffloat` event listener.

For internal use only.

openvrml::script_node::sfdouble_listener `[private]`

`sfdouble` event listener.

For internal use only.

openvrml::script_node::sfimage_listener `[private]`

`sfimage` event listener.

For internal use only.

openvrml::script_node::sfint32_listener `[private]`

`sfint32` event listener.

For internal use only.

openvrml::script_node::sfnode_listener `[private]`

`sfnode` event listener.

For internal use only.

openvrml::script_node::sfrotation_listener `[private]`

`sfrotation` event listener.

For internal use only.

openvrml::script_node::sfstring_listener `[private]`

`sfstring` event listener.

For internal use only.

openvrml::script_node::sftime_listener `[private]`

`sftime` event listener.

For internal use only.

openvrml::script_node::sfvec2f_listener `[private]`

`sfvec2f` event listener.

For internal use only.

openvrml::script_node::sfvec2d_listener `[private]`

`sfvec2d` event listener.

For internal use only.

openvrml::script_node::sfvec3f_listener `[private]`

`sfvec3f` event listener.

For internal use only.

openvrml::script_node::sfvec3d_listener `[private]`

`sfvec3d` event listener.

For internal use only.

openvrml::script_node::mfbool_listener `[private]`

`mfbool` event listener.

For internal use only.

openvrml::script_node::mfcolor_listener `[private]`

`mfcolor` event listener.

For internal use only.

openvrml::script_node::mfcolorrgba_listener `[private]`

`mfcolorrgba` event listener.

For internal use only.

openvrml::script_node::mffloat_listener `[private]`

`mffloat` event listener.

For internal use only.

openvrml::script_node::mfdouble_listener `[private]`

`mfdouble` event listener.

For internal use only.

openvrml::script_node::mfimage_listener `[private]`

`mfimage` event listener.

For internal use only.

openvrml::script_node::mfint32_listener `[private]`

`mfint32` event listener.

For internal use only.

openvrml::script_node::mfnode_listener `[private]`

`mfnode` event listener.

For internal use only.

openvrml::script_node::mfrotation_listener `[private]`

`mfrotation` event listener.

For internal use only.

openvrml::script_node::mfstring_listener `[private]`

`mfstring` event listener.

For internal use only.

openvrml::script_node::mftime_listener `[private]`

`mftime` event listener.

For internal use only.

openvrml::script_node::mfvec2f_listener `[private]`

`mfvec2f` event listener.

For internal use only.

openvrml::script_node::mfvec2d_listener `[private]`

`mfvec2d` event listener.

For internal use only.

openvrml::script_node::mfvec3f_listener `[private]`

`mfvec3f` event listener.

For internal use only.

openvrml::script_node::mfvec3d_listener `[private]`

`mfvec3d` event listener.

For internal use only.

openvrml::script_node::event_listener_ptr `[private]`

Reference-counted smart pointer to an event_listener.

For internal use only.

openvrml::script_node::event_listener_map_t `[private]`

Map of event listeners.

For internal use only.

## Constructor & Destructor Documentation

openvrml::script_node::script_node | ( | script_node_metatype & | class_,
|  | const boost::shared_ptr< openvrml::scope > & | scope,
|  | const node_interface_set & | interfaces,
|  | const initial_value_map & | initial_values |
| ) |  |  | throw ( unsupported_interface , std::bad_cast , std::bad_alloc , std::invalid_argument )

Construct.

Unlike other concrete node types, which are always instantiated via `node_type::create_node`, the `script_node` constructor is called directly when creating a new `script_node` from scratch. However, a `script_node` can be duplicated (or “cloned”) by calling `node_type::create_node` on `type` of a `script_node` instance. This provides a consistent interface for cloning any node, regardless of its type. OpenVRML uses this internally when instantiating `PROTOs`.

Parameters:

  `[in]` | class_ | the `script_node_metatype`. Typically there is one `script_node_metatype` per browser instance.
  `[in]` | scope | the `scope` to which the node should belong.
  `[in]` | interfaces | a `node_interface_set` containing specifications of user-defined `fields`, `eventIns`, and `eventOuts` particular to the `script_node` instance.
  `[in]` | initial_values | a map of initial values for `fields` of the `script_node`.

Exceptions:

  | unsupported_interface | if `initial_values` specifies a field that is not supported by the `script_node`.
  | std::bad_cast | if `initial_values` includes a field value that is the wrong type for the specified field.
  | std::bad_alloc | if memory allocation fails.

  std::invalid_argument

  if:
  - `interfaces` includes an `exposedField` specification.
  - `interfaces` includes an interface specification that duplicates an existing Script `node` interface.
  - `initial_values` is missing an initial value for a user-defined field in `interfaces`.

openvrml::script_node::~script_node | ( |  | ) | throw ()`[virtual]`

Destroy.

## Member Function Documentation

const boost::shared_ptr< openvrml::event_listener > openvrml::script_node::create_listener | ( | field_value::type_id | type,
|  | const std::string & | id,
|  | script_node & | node |
| ) |  |  | throw ( std::bad_alloc )`[static, private]`

Create a Script node event listener.

For internal use only.

Parameters:

  `[in]` | type | the type of listener to create.
  `[in]` | id | `eventIn` identifier.
  `[in]` | node | the containing script_node.

Returns:
  a Script node event listener.

Exceptions:

  | std::bad_alloc | if memory allocation fails.

std::auto_ptr< openvrml::event_emitter > openvrml::script_node::create_emitter | ( | script_node & | node,
|  | const field_value & | value |
| ) |  |  | throw ( std::bad_alloc )`[static, private]`

Create a Script node event emitter.

For internal use only.

Parameters:

  `[in]` | node | the containing `script_node`.
  `[in]` | value | the node field value associated with the emitter.

Returns:
  a Script node event emitter.

Exceptions:

  | std::bad_alloc | if memory allocation fails.

void openvrml::script_node::update | ( | double | current_time | ) |

Update the script_node for the current time.

Parameters:

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

const script_node::field_value_map_t & openvrml::script_node::field_value_map | ( |  | ) | const throw ()`[inline]`

Field value map accessor.

field value map.

Returns:
  the field value map.

const script_node::eventout_map_t & openvrml::script_node::eventout_map | ( |  | ) | const throw ()`[inline]`

`eventOut` map accessor.

`eventOut` map.

Returns:
  the `eventOut` map.

openvrml::script * openvrml::script_node::create_script | ( |  | ) | `[private]`

Create a script object.

For internal use only.

Returns:
  a new script object.

void openvrml::script_node::assign_with_self_ref_check | ( | const sfnode & | inval,
|  | sfnode & | retval |
| ) |  |  | const throw ()`[private]`

Special assignment function to take into account the fact that Script nodes can be self-referential.

For internal use only.

“Undo” the refcounting appropriately: decrement the refcount on any self-references we acquire ownership of and increment the refcount on any self-references for which ownership is relinquished.

Parameters:

  `[in]` | inval | input `sfnode`.
  `[out]` | retval | output `sfnode`.

void openvrml::script_node::assign_with_self_ref_check | ( | const mfnode & | inval,
|  | mfnode & | retval |
| ) |  |  | const throw ()`[private]`

Special assignment function to take into account the fact that Script nodes can be self referential.

For internal use only.

“Undo” the refcounting appropriately: decrement the refcount on any self-references we acquire ownership of and increment the refcount on any self-references for which ownership is relinquished.

Parameters:

  `[in]` | inval | input `mfnode`.
  `[out]` | retval | output `mfnode`.

openvrml::script_node * openvrml::script_node::to_script | ( |  | ) | throw ()`[private, virtual]`

Return a pointer to this `script_node`.

For internal use only.

Returns:
  a pointer to this `script_node`.

Reimplemented from openvrml::node.

void openvrml::script_node::do_initialize | ( | double | timestamp | ) | throw ( std::bad_alloc )`[private, virtual]`

Initialize.

Parameters:

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

Exceptions:

  | std::bad_alloc | if memory allocation fails.

Reimplemented from openvrml::node.

const openvrml::field_value & openvrml::script_node::do_field | ( | const std::string & | id | ) | const throw ( unsupported_interface )`[private, virtual]`

Get the value of a field.

Parameters:

  `[in]` | id | the name of the field to get.

Returns:
  the value for field `id`.

Exceptions:

  | unsupported_interface | if the node has no field `id`.

Implements openvrml::node.

openvrml::event_listener & openvrml::script_node::do_event_listener | ( | const std::string & | id | ) | throw ( unsupported_interface )`[private, virtual]`

Get an event listener.

This method is called by `node::event_listener`. Subclasses must implement this method.

Parameters:

  `[in]` | id | `eventIn` identifier.

Returns:
  the event listener.

Exceptions:

  | unsupported_interface | if the node has no `eventIn` `id`.

Implements openvrml::node.

openvrml::event_emitter & openvrml::script_node::do_event_emitter | ( | const std::string & | id | ) | throw ( unsupported_interface )`[private, virtual]`

Get an event emitter.

This method is called by `node::event_emitter`.

Parameters:

  `[in]` | id | `eventOut` identifier.

Returns:
  the event emitter.

Exceptions:

  | unsupported_interface | if the `node` has no `eventOut` `id`.

Implements openvrml::node.

void openvrml::script_node::do_shutdown | ( | double | timestamp | ) | throw ()`[private, virtual]`

Called by `node::shutdown`.

Parameters:

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

Reimplemented from openvrml::node.

void openvrml::script_node::do_render_child | ( | viewer & | v,
|  | rendering_context | context |
| ) |  |  | `[private, virtual]`

`node::render_child` implementation.

Parameters:

  `[in,out]` | v | viewer implementation responsible for actually doing the drawing.
  `[in]` | context | generic context argument; holds things like the accumulated modelview transform.

Reimplemented from openvrml::child_node.

## Friends And Related Function Documentation

class openvrml::script_node::script`[friend]`

Abstract base class for script runtimes.

## Member Data Documentation

openvrml::script_node::script_node_type openvrml::script_node::type `[private]`

Type object for the `script_node` instance.

For internal use only.

Script `node` `node_types` are significantly different from other `node_types`. While most `node_types` are shared by the `node` instances they spawn, the `script_node_type` is unique to a `script_node` instance, and it shares the `script_node`'s lifetime. This reflects the fact that Script `nodes` in VRML get their functionality by the addition of `fields`, `eventIns`, and `eventOuts` on a per-instance basis.

For `script_node` instances, `node::node_type` is an alias for the `script_node_type` object.

openvrml::script_node::set_metadata_listener openvrml::script_node::set_metadata_listener_ `[private]`

`set_metadata` `eventIn` handler.

openvrml::sfnode openvrml::script_node::metadata_ `[private]`

`metadata` field value.

openvrml::script_node::metadata_changed_emitter openvrml::script_node::metadata_changed_emitter_ `[private]`

`metadata_changed` `eventOut` emitter.

openvrml::sfbool openvrml::script_node::direct_output `[private]`

`directOutput` field.

For internal use only.

openvrml::sfbool openvrml::script_node::must_evaluate `[private]`

`mustEvaluate` field.

For internal use only.

openvrml::script_node::set_url_listener_t openvrml::script_node::set_url_listener `[private]`

`set_url` `eventIn` handler.

For internal use only.

openvrml::mfstring openvrml::script_node::url_ `[private]`

`url` `exposedField`.

For internal use only.

openvrml::script_node::url_changed_emitter openvrml::script_node::url_changed_emitter_ `[private]`

url_changed eventOut emitter.

For internal use only.

openvrml::script_node::field_value_map_t openvrml::script_node::field_value_map_ `[private]`

Maps user-defined field names to their values.

For internal use only.

openvrml::script_node::event_listener_map_t openvrml::script_node::event_listener_map `[private]`

Map of event listeners.

For internal use only.

openvrml::script_node::eventout_map_t openvrml::script_node::eventout_map_ `[private]`

Map of eventout instances.

For internal use only.

openvrml::script * openvrml::script_node::script_ `[private]`

A pointer to a script object.

For internal use only.

int openvrml::script_node::events_received `[private]`

A count of the number of events received since `update` was called.

For internal use only.