Home | Download | Screen shots | Discussion | Documentation |
---|
#include <openvrml/script.h>
The runtime instantiates subclasses of script for each VRML97 Script node; and calls its methods appropriately to execute script code.
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 script::direct_output_map_. | |
Private Attributes | |
direct_output_map_t | direct_output_map_ |
Map of direct outputs. |
openvrml::script::direct_output_map_t [private] |
Map of direct outputs.
For internal use only.
openvrml::script::~script | ( | ) | [pure virtual] |
Destroy.
openvrml::script::script | ( | script_node & | node | ) | [explicit, protected] |
void openvrml::script::initialize | ( | double | timestamp | ) |
Initialize the Script node.
Delegates to script::do_initialize
.
[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 script::do_process_event
.
[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 script::do_events_processed
.
[in] | timestamp | the current time. |
void openvrml::script::shutdown | ( | double | timestamp | ) |
Shut down the Script node.
Delegates to script::do_shutdown
.
[in] | timestamp | the current time. |
bool openvrml::script::direct_output | ( | ) | const throw () [protected] |
Whether direct output is enabled for the Script node.
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.
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.
[in] | id | field identifier. |
[in] | value | new value. |
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.
[in] | listener | the event_listener to which the event should be sent. |
[in] | value | the value to send. |
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.
[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.
[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.
[in] | timestamp | the current time. |
void openvrml::script::do_shutdown | ( | double | timestamp | ) | [private, pure virtual] |
Shut down the Script node.
[in] | timestamp | the current time. |
void openvrml::script::process_direct_output | ( | double | timestamp | ) | [private] |
Process direct outputs in script::direct_output_map_.
For internal use only.
This function is called at the end of initialization and processing normal events.
script::direct_output_map_.empty()
is true
.
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.