openvrml::script_node Class Reference

Represents a VRML Script node. More...

#include <openvrml/browser.h>

Inheritance diagram for openvrml::script_node:

Classes

class  eventout
 An event_emitter along with the emitted value. More...

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 event_listener_map_t & event_listener_map () const throw ()
 Event listener map accessor.
const field_value_map_tfield_value_map () const throw ()
 Field value map accessor.
const eventout_map_teventout_map () const throw ()
 eventOut map accessor.
- Public Member Functions inherited from openvrml::child_node
virtual ~child_node ()=0 throw ()
 Destructor.
void relocate () throw ( std::bad_alloc )
 Called when the node is relocated to a new position in the scene graph.
void render_child (viewer &v, rendering_context context)
 Render the node.
- Public Member Functions inherited from openvrml::bounded_volume_node
virtual ~bounded_volume_node () throw ()
 Destroy.
const openvrml::bounding_volumebounding_volume () const
 Get this node's bounding volume.
- Public Member Functions inherited from openvrml::node
virtual ~node ()=0 throw ()
 Destructor.
void add_ref () const throw ()
 Increment the reference count.
void remove_ref () const throw ()
 Decrement the reference count.
void release () const throw ()
 Decrement the reference count; destroy the instance if the count drops to zero.
size_t use_count () const throw ()
 The number of owning references to the instance.
const node_typetype () const throw ()
 The type information object for the node.
const std::string & id () const throw ()
 Retrieve the name of this node.
void id (const std::string &node_id) throw ( std::bad_alloc )
 Set the name of the node.
const openvrml::scopescope () const throw ()
 Get the scope to which the node belongs.
openvrml::scenescene () const throw ()
 Get the scene with which the node is associated.
const std::vector
< boost::intrusive_ptr< node > > & 
impl_nodes () const throw ()
 Get the implementation nodes of a PROTO instance.
std::ostream & print (std::ostream &out, size_t indent) const
 Pretty print.
void initialize (openvrml::scene &scene, double timestamp) throw ( std::bad_alloc )
 Initialize the node.
std::auto_ptr< field_valuefield (const std::string &id) const throw ( unsupported_interface , std::bad_alloc )
 Generalized field accessor.
openvrml::event_listenerevent_listener (const std::string &id) throw ( unsupported_interface )
 Get an event listener.
openvrml::event_emitterevent_emitter (const std::string &id) throw ( unsupported_interface )
 Get an event emitter.
void shutdown (double timestamp) throw ()
 Shut down the node.
bool modified () const throw ( boost::thread_resource_error )
 Determine whether the node has been modified.
void modified (bool value) throw ( boost::thread_resource_error )
 Set the modified flag.

Private Member Functions

virtual void do_initialize (double timestamp) throw ( std::bad_alloc )
 Initialize.
virtual const field_valuedo_field (const std::string &id) const throw ( unsupported_interface )
 Get the value of a field.
virtual openvrml::event_listenerdo_event_listener (const std::string &id) throw ( unsupported_interface )
 Get an event listener.
virtual openvrml::event_emitterdo_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.

Additional Inherited Members

- Static Public Attributes inherited from openvrml::node
static const
boost::intrusive_ptr< node
self_tag
 Special value used when initializing a script_node.
- Protected Member Functions inherited from openvrml::child_node
 child_node (const node_type &type, const boost::shared_ptr< openvrml::scope > &scope) throw ()
 Constructor.
- Static Protected Member Functions inherited from openvrml::node
static void emit_event (openvrml::event_emitter &emitter, double timestamp) throw ( std::bad_alloc )
 Emit an event.

Detailed Description

Represents a VRML Script node.

Member Typedef Documentation

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

Reference-counted smart pointer to an eventout.

Map of eventout instances.

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]scopethe scope to which the node should belong.
[in]interfacesa node_interface_set containing specifications of user-defined fields, eventIns, and eventOuts particular to the script_node instance.
[in]initial_valuesa map of initial values for fields of the script_node.
Exceptions
unsupported_interfaceif initial_values specifies a field that is not supported by the script_node.
std::bad_castif initial_values includes a field value that is the wrong type for the specified field.
std::bad_allocif memory allocation fails.
std::invalid_argumentif:
  • 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

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

Update the script_node for the current time.

Parameters
[in]current_timethe current time.
const openvrml::script_node::event_listener_map_t & openvrml::script_node::event_listener_map ( ) const throw ()

Event listener map accessor.

Returns
the event listener map.
const openvrml::script_node::field_value_map_t & openvrml::script_node::field_value_map ( ) const throw ()

Field value map accessor.

field value map.

Returns
the field value map.
const openvrml::script_node::eventout_map_t & openvrml::script_node::eventout_map ( ) const throw ()

eventOut map accessor.

eventOut map.

Returns
the eventOut map.
void openvrml::script_node::do_initialize ( double  timestamp) throw ( std::bad_alloc )
privatevirtual

Initialize.

Parameters
[in]timestampthe current time.
Exceptions
std::bad_allocif memory allocation fails.
const openvrml::field_value & openvrml::script_node::do_field ( const std::string &  id) const throw ( unsupported_interface )
privatevirtual

Get the value of a field.

Parameters
[in]idthe name of the field to get.
Returns
the value for field id.
Exceptions
unsupported_interfaceif the node has no field id.
openvrml::event_listener & openvrml::script_node::do_event_listener ( const std::string &  id) throw ( unsupported_interface )
privatevirtual

Get an event listener.

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

Parameters
[in]ideventIn identifier.
Returns
the event listener.
Exceptions
unsupported_interfaceif the node has no eventIn id.
openvrml::event_emitter & openvrml::script_node::do_event_emitter ( const std::string &  id) throw ( unsupported_interface )
privatevirtual

Get an event emitter.

This method is called by node::event_emitter.

Parameters
[in]ideventOut identifier.
Returns
the event emitter.
Exceptions
unsupported_interfaceif the node has no eventOut id.
void openvrml::script_node::do_shutdown ( double  timestamp) throw ()
privatevirtual

Called by node::shutdown.

Parameters
[in]timestampthe current time.
void openvrml::script_node::do_render_child ( viewer v,
rendering_context  context 
)
privatevirtual

node::render_child implementation.

Parameters
[in,out]vviewer implementation responsible for actually doing the drawing.
[in]contextgeneric context argument; holds things like the accumulated modelview transform.