Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.scripting.external.buffer
Class ExternalEventQueue

java.lang.Object
  extended by org.web3d.vrml.scripting.external.buffer.ExternalEventQueue
All Implemented Interfaces:
NodeRealizationProcessor, ExternalView

public class ExternalEventQueue
extends java.lang.Object
implements ExternalView, NodeRealizationProcessor

The ExternalEventQueue provides the update batching functionality for the EAI browser and the external SAI browser. This class handles the buffering of event setValue calls and the various browser requests.

This queue handles all of the event types, including the replaceWorld methods. Because I do not fully understand the intention of the beginUpdate/endUpdate queue system for handling browser requests, it is possible to change between queued and unqueued behavior by modifying the appropriate static constants.

Amalgamation of distinct set1Value events into single setValue events is the responsibility of the event buffers/field wrapper classes. The only functionality that this class exposes is the ability to locate the appropriate previous buffers, and exposing the synchronization lock for thread safety.

This class was previously named the EAIEventQueue, which became a misnomer when it was repurposed for both EAI and external SAI support. It has not been seen as sufficiently useful to split this queue into an EAI and an SAI version, thus the compilation dependencies from the VRML and X3D systems.

The responsibility for registering the event queue with the appropriate triggering mechanisms (current the EventModelEvaluator) is external to this class.


Field Summary
protected  ErrorReporter errorReporter
          The ErrorReporter to send messages to
 java.lang.Object eventLock
          External lock for the event list.
 
Constructor Summary
ExternalEventQueue(ErrorReporter reporter)
          Basic constructor.
 
Method Summary
 void beginUpdate()
          Start queueing updates.
 void endUpdate()
          End queueing of updates, and send the current set to be processed.
 ExternalEvent getLast(ExternalEvent type)
          Return the ExternalEvent which is equal to the sent type.
 boolean isNodeRealized(VRMLNodeType node)
          Methods for NodeRealizationProcessor
 void markNodeRealized(VRMLNodeType node)
          Mark a node as undergoing realization
 void markRealizationComplete(VRMLNodeType node)
          Complete the realization of a node.
 void postAddRoute(VRML97CommonBrowser theBrowser, BrowserCore theCore, VRMLNodeType fromNode, java.lang.String eventOut, VRMLNodeType toNode, java.lang.String eventIn)
          Process a Browser.addRoute request.
 void postCreateVrmlFromURL(VRML97CommonBrowser theBrowser, java.lang.String[] url, VRMLNodeType node, java.lang.String eventIn)
          Process a Browser.createVrmlFromURL request
 void postLoadURL(VRML97CommonBrowser browser, java.lang.String[] url, java.lang.String[] param)
          Process a browser.loadURL request.
 void postRealizeNode(VRMLNodeType nodeToRealize)
          Process a node realization request
 void postRemoveRoute(VRML97CommonBrowser browser, BrowserCore core, VRMLNodeType from, java.lang.String eventOut, VRMLNodeType to, java.lang.String eventIn)
          Process a browser.deleteRoute request.
 void postReplaceWorld(VRML97CommonBrowser browser, VRMLNodeType[] value)
          Process a browser.replaceWorld request
 void processEvent(ExternalEvent event)
          Process an addition to the event queue.
 void processEvents()
          Process all waiting events.
 void setErrorReporter(ErrorReporter reporter)
          Change the ErrorReporter this instance is using
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventLock

public java.lang.Object eventLock
External lock for the event list. This has to be public because the logic for merging set1Value calls isn't thread safe otherwise.


errorReporter

protected ErrorReporter errorReporter
The ErrorReporter to send messages to

Constructor Detail

ExternalEventQueue

public ExternalEventQueue(ErrorReporter reporter)
Basic constructor.

Parameters:
reporter - The ErrorReporter to use.
Method Detail

beginUpdate

public void beginUpdate()
Start queueing updates. It isn't an error to call this multiple times, but extra calls are ignored.


endUpdate

public void endUpdate()
End queueing of updates, and send the current set to be processed. It isn't an error to call this multiple times, but extra calls are ignored.


getLast

public ExternalEvent getLast(ExternalEvent type)
Return the ExternalEvent which is equal to the sent type. This relies on the trick that EventIn instances are equal based on node and field ID properties.


postAddRoute

public void postAddRoute(VRML97CommonBrowser theBrowser,
                         BrowserCore theCore,
                         VRMLNodeType fromNode,
                         java.lang.String eventOut,
                         VRMLNodeType toNode,
                         java.lang.String eventIn)
Process a Browser.addRoute request.


postCreateVrmlFromURL

public void postCreateVrmlFromURL(VRML97CommonBrowser theBrowser,
                                  java.lang.String[] url,
                                  VRMLNodeType node,
                                  java.lang.String eventIn)
Process a Browser.createVrmlFromURL request


postLoadURL

public void postLoadURL(VRML97CommonBrowser browser,
                        java.lang.String[] url,
                        java.lang.String[] param)
Process a browser.loadURL request.


postRealizeNode

public void postRealizeNode(VRMLNodeType nodeToRealize)
Process a node realization request


postRemoveRoute

public void postRemoveRoute(VRML97CommonBrowser browser,
                            BrowserCore core,
                            VRMLNodeType from,
                            java.lang.String eventOut,
                            VRMLNodeType to,
                            java.lang.String eventIn)
Process a browser.deleteRoute request. The EAI specification doesn't specifically state that this should be buffered, but it is a world state modification.


postReplaceWorld

public void postReplaceWorld(VRML97CommonBrowser browser,
                             VRMLNodeType[] value)
Process a browser.replaceWorld request


processEvent

public void processEvent(ExternalEvent event)
Process an addition to the event queue. This will either add the event to the queue, or execute it immediately depending on the queueing state


processEvents

public void processEvents()
Process all waiting events.

Specified by:
processEvents in interface ExternalView
See Also:
ExternalView.processEvents()

setErrorReporter

public void setErrorReporter(ErrorReporter reporter)
Change the ErrorReporter this instance is using

Specified by:
setErrorReporter in interface ExternalView
Parameters:
reporter - The instance to use or null
See Also:
org.xj3d.core.eventmodel

isNodeRealized

public boolean isNodeRealized(VRMLNodeType node)
Methods for NodeRealizationProcessor

Specified by:
isNodeRealized in interface NodeRealizationProcessor
Parameters:
node - The node in question
Returns:
The current status

markNodeRealized

public void markNodeRealized(VRMLNodeType node)
Description copied from interface: NodeRealizationProcessor
Mark a node as undergoing realization

Specified by:
markNodeRealized in interface NodeRealizationProcessor

markRealizationComplete

public void markRealizationComplete(VRMLNodeType node)
Description copied from interface: NodeRealizationProcessor
Complete the realization of a node. Removes the realization processing record to free up memory.

Specified by:
markRealizationComplete in interface NodeRealizationProcessor

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium