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

ScriptNode Class Reference

Represents a VRML Script node. More...

Inheritance diagram for ScriptNode:

ChildNode Node List of all members.

Public Types

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

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


Public Methods

 ScriptNode (ScriptNodeClass &nodeClass, const ScopePtr &scope)
 Constructor.

virtual ~ScriptNode () throw ()
 Destructor.

void setUrl (const MFString &value, double timestamp)
const MFStringgetUrl () const
void addEventIn (FieldValue::Type type, const std::string &id) throw (std::invalid_argument, std::bad_alloc)
void addEventOut (FieldValue::Type type, const std::string &id) throw (std::invalid_argument, std::bad_alloc)
void addField (const std::string &id, const FieldValuePtr &defaultValue) throw (std::invalid_argument, std::bad_alloc)
void initialize (double timestamp)
void update (double timestamp)
void shutdown (double timestamp)
void setEventOut (const std::string &id, const FieldValue &value) throw (UnsupportedInterface, std::bad_cast, std::bad_alloc)
 Set the value of one of the node's eventOuts.

const FieldValueMapgetFieldValueMap () const throw ()
const EventOutValueMapgetEventOutValueMap () const throw ()
virtual const ScriptNode * toScript () const throw ()
 Return a pointer to this ScriptNode.

virtual ScriptNode * toScript () throw ()
 Return a pointer to this ScriptNode.


Private Methods

ScriptcreateScript ()
void assignWithSelfRefCheck (const SFNode &, SFNode &) const throw ()
void assignWithSelfRefCheck (const MFNode &, MFNode &) const throw ()
virtual void initializeImpl (double timestamp) throw (std::bad_alloc)
 Initialize.

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

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

virtual void processEventImpl (const std::string &id, const FieldValue &value, double timestamp) throw (UnsupportedInterface, std::bad_cast, std::bad_alloc)
virtual const FieldValuegetEventOutImpl (const std::string &id) const throw (UnsupportedInterface)

Private Attributes

ScriptNodeType scriptNodeType
 Type object for the ScriptNode instance.

SFBool directOutput
 directOutput field.

SFBool mustEvaluate
 mustEvaluate field.

MFString url
 url exposedField.

FieldValueMap fieldValueMap
 Maps user-defined field names to their values.

EventOutValueMap eventOutValueMap
 Maps user-defined eventOut names to their values.

Scriptscript
 A pointer to a Script object.

int eventsReceived
 A count of the number of events received since ScriptNode::update was called.


Friends

class ScriptNodeType

Detailed Description

Represents a VRML Script node.


Member Typedef Documentation

EventOutValueMap
 

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

FieldValueMap
 

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


Constructor & Destructor Documentation

ScriptNode ScriptNodeClass   nodeClass,
const ScopePtr   scope
 

Constructor.

~ScriptNode   throw () [virtual]
 

Destructor.


Member Function Documentation

const FieldValue & getFieldImpl const std::string &    id const throw (UnsupportedInterface) [private, virtual]
 

Get the value of a field.

Parameters:
id the name of the field to get.
Returns:
the value for field id.
Exceptions:
UnsupportedInterface if the node has no field id.

Implements Node.

void initializeImpl double    timestamp throw (std::bad_alloc) [private, virtual]
 

Initialize.

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

Reimplemented from Node.

void setEventOut const std::string &    id,
const FieldValue   value
throw (UnsupportedInterface, 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.

void setFieldImpl const std::string &    id,
const FieldValue   value
throw (UnsupportedInterface, 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:
UnsupportedInterface if the node has no field id.
std::bad_cast if value is the wrong type.
std::bad_alloc if memory allocation fails.

Implements Node.

ScriptNode * toScript   throw () [virtual]
 

Return a pointer to this ScriptNode.

Returns:
a pointer to this ScriptNode.

Reimplemented from Node.

const ScriptNode * toScript   const throw () [virtual]
 

Return a pointer to this ScriptNode.

Returns:
a pointer to this ScriptNode.

Reimplemented from Node.


Member Data Documentation

SFBool directOutput [private]
 

directOutput field.

ScriptNode::EventOutValueMap eventOutValueMap [private]
 

Maps user-defined eventOut names to their values.

int eventsReceived [private]
 

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

ScriptNode::FieldValueMap fieldValueMap [private]
 

Maps user-defined field names to their values.

SFBool mustEvaluate [private]
 

mustEvaluate field.

Script * script [private]
 

A pointer to a Script object.

ScriptNode::ScriptNodeType scriptNodeType [private]
 

Type object for the ScriptNode instance.

Script node NodeTypes are significantly different from other NodeTypes. While most NodeTypes are shared by the Node instances they spawn, the ScriptNodeType is unique to a ScriptNode instance, and it shares the ScriptNodeInstance'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 ScriptNode instances, Node::nodeType is an alias for the scriptNodeType object.

MFString url [private]
 

url exposedField.