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

# openvrml::script Class Reference

Abstract class implemented by scripting language bindings. More...

`#include <openvrml/script.h>`

List of all members.

## Public Member Functions

virtual | ~script ()=0
| Destroy.
void | initialize (double timestamp)
| Initialize the Script node.
void | process_event (const std::string &id, const field_value &value, double timestamp)
| Process an event.
void | events_processed (double timestamp)
| Execute script code after processing events.
void | shutdown (double timestamp)
| Shut down the Script node.

## Protected Member Functions

| script (script_node &node)
| Construct.
bool | direct_output () const throw ()
| Whether direct output is enabled for the Script node.
bool | must_evaluate () const throw ()
| Whether the `browser` may delay sending input events to the `script` until its outputs are needed by the browser.
void | field (const std::string &id, const field_value &value) throw ( unsupported_interface , std::bad_cast , std::bad_alloc )
| Set the value of a field.
void | direct_output (event_listener &listener, const boost::shared_ptr< field_value > &value) throw ( field_value_type_mismatch , std::bad_alloc )
| Add an event for direct output processing at the end of script execution.

## Protected Attributes

script_node & | node
| A reference to the `script_node` that uses this `script` object.

## Private Types

typedef std::map < openvrml::event_listener *, boost::shared_ptr < field_value > > | direct_output_map_t
| Map of direct outputs.

## Private Member Functions

virtual void | do_initialize (double timestamp)=0
| Initialize the Script node.
virtual void | do_process_event (const std::string &id, const field_value &value, double timestamp)=0
| Process an event.
virtual void | do_events_processed (double timestamp)=0
| Execute script code after processing events.
virtual void | do_shutdown (double timestamp)=0
| Shut down the Script node.
void | process_direct_output (double timestamp)
| Process direct outputs in direct_output_map_.

## Private Attributes

direct_output_map_t | direct_output_map_
| Map of direct outputs.

## Detailed Description

Abstract class implemented by scripting language bindings.

The runtime instantiates subclasses of script for each VRML97 Script node; and calls its methods appropriately to execute script code.

## Member Typedef Documentation

openvrml::script::direct_output_map_t`[private]`

Map of direct outputs.

For internal use only.

## Constructor & Destructor Documentation

openvrml::script::~script | ( |  | ) | `[pure virtual]`

Destroy.

openvrml::script::script | ( | script_node & | node | ) | `[explicit, protected]`

Construct.

Parameters:

  `[in]` | node | a reference to the `script_node` that uses this `script` object.

## Member Function Documentation

void openvrml::script::initialize | ( | double | timestamp | ) |

Initialize the Script node.

Delegates to `do_initialize`.

Parameters:

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

void openvrml::script::process_event | ( | const std::string & | id,
|  | const field_value & | value,
|  | double | timestamp |
| ) |  |  |

Process an event.

Delegates to `do_process_event`.

Parameters:

  `[in]` | id | eventIn identifier.
  `[in]` | value | event value.
  `[in]` | timestamp | the current time.

void openvrml::script::events_processed | ( | double | timestamp | ) |

Execute script code after processing events.

Delegates to `do_events_processed`.

Parameters:

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

void openvrml::script::shutdown | ( | double | timestamp | ) |

Shut down the Script node.

Delegates to `do_shutdown`.

Parameters:

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

bool openvrml::script::direct_output | ( |  | ) | const throw ()`[protected]`

Whether direct output is enabled for the Script node.

Returns:
  `true` if direct output is enabled for the Script node; `false` otherwise.

bool openvrml::script::must_evaluate | ( |  | ) | const throw ()`[protected]`

Whether the `browser` may delay sending input events to the `script` until its outputs are needed by the browser.

Returns:
  `true` if the `browser` may delay sending input events to the `script` until its outputs are needed by the `browser`; `false` otherwise.

void openvrml::script::field | ( | const std::string & | id,
|  | const field_value & | value |
| ) |  |  | throw ( unsupported_interface , std::bad_cast , std::bad_alloc )`[protected]`

Set the value of a field.

Parameters:

  `[in]` | id | field identifier.
  `[in]` | value | new value.

Exceptions:

  | unsupported_interface | if the Script node has no field `id`.
  | std::bad_cast | if `value` is the wrong type.
  | std::bad_alloc | if memory allocation fails.

void openvrml::script::direct_output | ( | event_listener & | listener,
|  | const boost::shared_ptr< field_value > & | value |
| ) |  |  | throw ( field_value_type_mismatch , std::bad_alloc )`[protected]`

Add an event for direct output processing at the end of script execution.

Parameters:

  `[in]` | listener | the `event_listener` to which the event should be sent.
  `[in]` | value | the value to send.

Exceptions:

  | field_value_type_mismatch | if `listener` is not the correct type to process events of `value's` type.
  | std::bad_alloc | if memory allocation fails.

void openvrml::script::do_initialize | ( | double | timestamp | ) | `[private, pure virtual]`

Initialize the Script node.

Parameters:

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

void openvrml::script::do_process_event | ( | const std::string & | id,
|  | const field_value & | value,
|  | double | timestamp |
| ) |  |  | `[private, pure virtual]`

Process an event.

Parameters:

  `[in]` | id | `eventIn` identifier.
  `[in]` | value | event value.
  `[in]` | timestamp | the current time.

void openvrml::script::do_events_processed | ( | double | timestamp | ) | `[private, pure virtual]`

Execute script code after processing events.

Parameters:

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

void openvrml::script::do_shutdown | ( | double | timestamp | ) | `[private, pure virtual]`

Shut down the Script node.

Parameters:

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

void openvrml::script::process_direct_output | ( | double | timestamp | ) | `[private]`

Process direct outputs in direct_output_map_.

For internal use only.

This function is called at the end of initialization and processing normal events.

Postcondition:
  `script::direct_output_map_.empty()` is `true`.

## Member Data Documentation

openvrml::script::direct_output_map_t openvrml::script::direct_output_map_`[private]`

Map of direct outputs.

For internal use only.

openvrml::script_node & openvrml::script::node`[protected]`

A reference to the `script_node` that uses this `script` object.