Main Page   Modules   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

openvrml::script_node Class Reference

Represents a VRML Script node. More...

Inheritance diagram for openvrml::script_node:

Inheritance graph
[legend]
Collaboration diagram for openvrml::script_node:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::map< std::string,
field_value_ptr
field_value_map_t
 A std::map that keys field values on their field name.

typedef std::map< std::string,
polled_eventout_value > 
eventout_value_map_t
 A std::map that keys eventOut values on their eventOut name.


Public Member Functions

 script_node (script_node_class &class_, const scope_ptr &scope) throw ()
 Construct.

virtual ~script_node () throw ()
 Destroy.

void url (const mfstring &value, double timestamp)
 set_url eventIn handler.

const mfstringurl () const
 url exposedField.

void add_eventin (field_value::type_id type, const std::string &id) throw (std::invalid_argument, std::bad_alloc)
 Add an eventIn.

void add_eventout (field_value::type_id type, const std::string &id) throw (std::invalid_argument, std::bad_alloc)
 Add an eventOut.

void add_field (const std::string &id, const field_value_ptr &default_val) throw (std::invalid_argument, std::bad_alloc)
 Add a field.

void update (double current_time)
 Update the script_node for the current time.

void eventout (const std::string &id, const field_value &value) throw (unsupported_interface, std::bad_cast, std::bad_alloc)
 Set the value of one of the node's eventOuts.

const field_value_map_tfield_value_map () const throw ()
 field value map.

const eventout_value_map_teventout_value_map () const throw ()
 eventOut value map.

virtual const script_node * to_script () const throw ()
 Return a pointer to this script_node.

virtual script_node * to_script () throw ()
 Return a pointer to this script_node.


Private Member Functions

scriptcreate_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 void do_initialize (double timestamp) throw (std::bad_alloc)
 Initialize.

virtual void do_field (const std::string &id, const field_value &value) throw (unsupported_interface, std::bad_cast, std::bad_alloc)
 Set the value of one of the node's fields.

virtual const field_valuedo_field (const std::string &id) const throw (unsupported_interface)
 Get the value of a field.

virtual void do_process_event (const std::string &id, const field_value &value, double timestamp) throw (unsupported_interface, std::bad_cast, std::bad_alloc)
 Process an event.

virtual const field_valuedo_eventout (const std::string &id) const throw (unsupported_interface)
 Called by node::eventout to get an eventOut value.

virtual void do_shutdown (double timestamp) throw ()
 Called by node::shutdown.


Private Attributes

script_node_type type
 Type object for the script_node instance.

sfbool direct_output
 directOutput field.

sfbool must_evaluate
 mustEvaluate field.

mfstring url_
 url exposedField.

field_value_map_t field_value_map_
 Maps user-defined field names to their values.

eventout_value_map_t eventout_value_map_
 Maps user-defined eventOut names to their values.

scriptscript_
 A pointer to a script object.

int events_received
 A count of the number of events received since script_node::update was called.


Friends

class script_node_type
 Type information object.


Detailed Description

Represents a VRML Script node.


Member Typedef Documentation

openvrml::script_node::eventout_value_map_t
 

A std::map that keys eventOut values on their eventOut name.

openvrml::script_node::field_value_map_t
 

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


Constructor & Destructor Documentation

openvrml::script_node::script_node script_node_class class_,
const scope_ptr scope
throw ()
 

Construct.

Parameters:
class_ 
scope 

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

Destroy.


Member Function Documentation

void openvrml::script_node::add_eventin field_value::type_id  type,
const std::string &  id
throw (std::invalid_argument, std::bad_alloc)
 

Add an eventIn.

Parameters:
type value type.
id identifier.

void openvrml::script_node::add_eventout field_value::type_id  type,
const std::string &  id
throw (std::invalid_argument, std::bad_alloc)
 

Add an eventOut.

Parameters:
type value type.
id identifier.

void openvrml::script_node::add_field const std::string &  id,
const field_value_ptr default_val
throw (std::invalid_argument, std::bad_alloc)
 

Add a field.

Parameters:
id identifier.
default_val default value.

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.

"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:
inval input mfnode.
Return values:
retval output mfnode.

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.

"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:
inval input sfnode.
Return values:
retval output sfnode.

script * openvrml::script_node::create_script  )  [private]
 

Create a script object.

Returns:
a new script object.

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

Called by node::eventout to get an eventOut value.

Parameters:
id eventOut identifier.
Returns:
the eventOut value.
Exceptions:
unsupported_interface if the script_node has no eventOut id.

Implements openvrml::node.

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

Get the value of a field.

Parameters:
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.

void openvrml::script_node::do_field const std::string &  id,
const field_value value
throw (unsupported_interface, std::bad_cast, std::bad_alloc) [private, virtual]
 

Set the value of one of the node's fields.

Parameters:
id the name of the field to set.
value the new value.
Exceptions:
unsupported_interface if the node has no field id.
std::bad_cast if value is the wrong type.
std::bad_alloc if memory allocation fails.

Implements openvrml::node.

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

Initialize.

Parameters:
timestamp the current time.
Exceptions:
std::bad_alloc if memory allocation fails.

Reimplemented from openvrml::node.

void openvrml::script_node::do_process_event const std::string &  id,
const field_value value,
double  timestamp
throw (unsupported_interface, std::bad_cast, std::bad_alloc) [private, virtual]
 

Process an event.

Parameters:
id eventIn identifier.
value event value.
timestamp current time.
Exceptions:
unsupported_interface if the Script node has no eventIn id.
std::bad_cast if value is not the correct type.
std::bad_alloc if memory allocation fails.

Implements openvrml::node.

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

Called by node::shutdown.

Parameters:
timestamp the current time.

Reimplemented from openvrml::node.

void openvrml::script_node::eventout const std::string &  id,
const field_value value
throw (unsupported_interface, std::bad_cast, std::bad_alloc)
 

Set the value of one of the node's eventOuts.

This method is intended to be used by scripting language bindings to set the value of eventOuts in response to script code.

Parameters:
id eventOut identifier.
value value.
Exceptions:
unsupported_interface if the script_node has no eventOut id.
std::bad_cast if value is the wrong type.
std::bad_alloc if memory allocation fails.

const script_node::eventout_value_map_t & openvrml::script_node::eventout_value_map  )  const throw () [inline]
 

eventOut value map.

Returns:
the eventOut value map.

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

field value map.

Returns:
the field value map.

script_node * openvrml::script_node::to_script  )  throw () [virtual]
 

Return a pointer to this script_node.

Returns:
a pointer to this script_node.

Reimplemented from openvrml::node.

const script_node * openvrml::script_node::to_script  )  const throw () [virtual]
 

Return a pointer to this script_node.

Returns:
a pointer to this script_node.

Reimplemented from openvrml::node.

void openvrml::script_node::update double  current_time  ) 
 

Update the script_node for the current time.

Parameters:
current_time the current time.

const mfstring & openvrml::script_node::url  )  const
 

url exposedField.

Returns:
the current value of the url exposedField.

void openvrml::script_node::url const mfstring value,
double  timestamp
 

set_url eventIn handler.

Parameters:
value new value.
timestamp the current time.

Friends And Related Function Documentation

script_node::script_node_type openvrml::script_node::script_node_type [friend]
 

Type information object.


Member Data Documentation

sfbool openvrml::script_node::direct_output [private]
 

directOutput field.

script_node::eventout_value_map_t openvrml::script_node::eventout_value_map_ [private]
 

Maps user-defined eventOut names to their values.

int openvrml::script_node::events_received [private]
 

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

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

Maps user-defined field names to their values.

sfbool openvrml::script_node::must_evaluate [private]
 

mustEvaluate field.

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

A pointer to a script object.

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

Type object for the script_node instance.

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.

Reimplemented from openvrml::node.

mfstring openvrml::script_node::url_ [private]
 

url exposedField.