Class DefaultRouteManager
- All Implemented Interfaces:
RouteManager
Does not perform direct routing itself, but manages the execution space and delegates the routing to individual router instances, one per execution space. The idea of this is to allow multi-threaded route handlers if required. Each execution space can provide a routing mechanism that operates in its own thread or they all live in one thread.
The implementation provides a one-shot route processing mechanism. It does not continuously evaluate routes. That is left to the caller code. Once the processRoutes() method is called, it will loop through all available routes until none of them have any changed values to send. At this point it will return and wait until the next time it is called.
Routes are added to a particular execution space. Each space represents an encapsulated world, such as a proto or inline. The route manager is expected to be able to deal with these individual spaces, and keep them separate. Thus, when the execution space is no longer referenced, the associated routes and scripts are to be removed and their outputs no longer processed.
Implementation is not particularly efficient in this version...
- Version:
- $Revision: 1.2 $
- Author:
- Justin Couch
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance of the execution space manager to run all the routing. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRoute
(VRMLExecutionSpace space, ROUTE route) Add a route object to the system.void
addRoute
(VRMLExecutionSpace space, VRMLNodeType srcNode, int srcIndex, VRMLNodeType destNode, int destIndex) Add a route to the system.void
addSpace
(VRMLExecutionSpace space) Add an execution space to the system.void
clear()
Clear all the routes currently being managed here.boolean
processRoutes
(double timestamp) Process all of the available routes until there are no more to process.void
removeRoute
(VRMLExecutionSpace space, ROUTE route) Remove a route object from the system.void
removeRoute
(VRMLExecutionSpace space, VRMLNodeType srcNode, int srcIndex, VRMLNodeType destNode, int destIndex) Remove a route from the system.void
removeSpace
(VRMLExecutionSpace space) Remove an execution space to the system.void
setErrorReporter
(org.j3d.util.ErrorReporter reporter) Register an error reporter with the manager so that any errors generated by the loading of script code can be reported in a nice, pretty fashion.void
Set the factory needed to create new router instances for a new execution space.void
Notification that the route manager should now propagate all added and removed routes from this list into the core evaluatable space.void
Notification that the route manager should now propagate all added and removed routes and spaces from this list into the core evaluatable system.
-
Constructor Details
-
DefaultRouteManager
public DefaultRouteManager()Create a new instance of the execution space manager to run all the routing.
-
-
Method Details
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter reporter) Register an error reporter with the manager so that any errors generated by the loading of script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.- Specified by:
setErrorReporter
in interfaceRouteManager
- Parameters:
reporter
- The instance to use or null
-
setRouterFactory
Set the factory needed to create new router instances for a new execution space. If the reference is null, then this clears the current factory so that we don't accept sub-space handling.- Specified by:
setRouterFactory
in interfaceRouteManager
- Parameters:
fac
- The factory instance to use
-
processRoutes
public boolean processRoutes(double timestamp) Process all of the available routes until there are no more to process. This method will not return until all routes have been processed.- Specified by:
processRoutes
in interfaceRouteManager
- Parameters:
timestamp
- The timestamp for when these routes should be executed- Returns:
- false No event outs needed processing this call
-
addRoute
public void addRoute(VRMLExecutionSpace space, VRMLNodeType srcNode, int srcIndex, VRMLNodeType destNode, int destIndex) Add a route to the system. If the route exists in the system, this silently ignores the request. If the space reference is null then- Specified by:
addRoute
in interfaceRouteManager
- Parameters:
space
- The execution space for the routesrcNode
- The source node of the routesrcIndex
- The index of the source fielddestNode
- The destination node of the routedestIndex
- The index of the destination field
-
addRoute
Add a route object to the system. If the route exists in the system, this silently ignores the request.- Specified by:
addRoute
in interfaceRouteManager
- Parameters:
space
- The execution space for the routeroute
- The object to add
-
removeRoute
public void removeRoute(VRMLExecutionSpace space, VRMLNodeType srcNode, int srcIndex, VRMLNodeType destNode, int destIndex) Remove a route from the system. If the route does not exist in the system, this silently ignores the request.- Specified by:
removeRoute
in interfaceRouteManager
- Parameters:
space
- The execution space for the routesrcNode
- The source node of the routesrcIndex
- The index of the source fielddestNode
- The destination node of the routedestIndex
- The index of the destination field
-
removeRoute
Remove a route object from the system. If the route does not exist in the system, this silently ignores the request.- Specified by:
removeRoute
in interfaceRouteManager
- Parameters:
space
- The execution space for the routeroute
- The object to remove
-
addSpace
Add an execution space to the system. This will add all its routes and any contained spaces such as protos and inlines. If this space has already been added, the request will be ignored.- Specified by:
addSpace
in interfaceRouteManager
- Parameters:
space
- The execution space to add
-
removeSpace
Remove an execution space to the system. This will add all its routes and any contained spaces such as protos and inlines. If this request has not been added it will be ignored.- Specified by:
removeSpace
in interfaceRouteManager
- Parameters:
space
- The execution space to add
-
updateSpaces
public void updateSpaces()Notification that the route manager should now propagate all added and removed routes and spaces from this list into the core evaluatable system.- Specified by:
updateSpaces
in interfaceRouteManager
-
updateRoutes
public void updateRoutes()Notification that the route manager should now propagate all added and removed routes from this list into the core evaluatable space.- Specified by:
updateRoutes
in interfaceRouteManager
-
clear
public void clear()Clear all the routes currently being managed here. The space this router represents is being deleted.- Specified by:
clear
in interfaceRouteManager
-