H3D::LoadSensor Class Reference
[X3D node classes.]

The LoadSensor monitors the progress and success of downloading URL elements over a network. More...

#include <H3D/LoadSensor.h>

Inheritance diagram for H3D::LoadSensor:

Inheritance graph

List of all members.

Public Member Functions

 LoadSensor (Inst< SFBool > _enabled=0, Inst< SFNode > _metadata=0, Inst< SFBool > _isActive=0, Inst< SFTime > _timeOut=0, Inst< MFUrlObject > _watchList=0, Inst< SFBool > isLoaded=0, Inst< SFTime > loadTime=0, Inst< SFFloat > progress=0)
 Constructor.
virtual void traverseSG (TraverseInfo &ti)
 traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph.

Public Attributes

auto_ptr< MFUrlObjectwatchList
 The watchList field contains one or more URL objects to monitor.
auto_ptr< SFTimetimeOut
 The timeOut field specifies the maximum time for which the LoadSensor will monitor loading, starting from when the sensor becomes active.
auto_ptr< SFBoolisLoaded
 The isLoaded field generates events when loading of the LoadSensor's watchList has completed.
auto_ptr< SFTimeloadTime
 The loadTime event is generated when loading of the LoadSensor's watchList has successfully completed.
auto_ptr< SFFloatprogress
 The progress field generates events as loading progresses.

Static Public Attributes

static H3DNodeDatabase database
 The H3DNodeDatabase for this node.


Detailed Description

The LoadSensor monitors the progress and success of downloading URL elements over a network.

Only nodes that contain a valid URL field (i.e., descendants of X3DUrlObject), may be specified in the watchList field. Multiple nodes may be watched with a single LoadSensor.

The timeOut field specifies the maximum time for which the LoadSensor will monitor loading, starting from when the sensor becomes active. A value of 0 for the timeOut field indicates an indefinite time out period; i.e., the LoadSensor will wait until loading has completed either with success or failure.

The watchList field contains one or more URL objects to monitor. Only nodes that contain a valid URL field (i.e., descendants of X3DUrlObject), may be specified as elements of watchList. If multiple values are specified for this field, output events are generated only when all of the children have loaded or at least one has failed. If individual load status information is desired for different nodes, multiple LoadSensor nodes may be used, each with a single watchList element.

The isActive field generates events when loading of the LoadSensor's watchList elements begins and ends. An isActive TRUE event is generated when the first element begins loading. An isActive FALSE event is generated when loading has completed, either with a successful load of all objects or a failed load of one of the objects, or when the timeout period is reached as specified in the timeout field.

The isLoaded field generates events when loading of the LoadSensor's watchList has completed. An isLoaded TRUE event is generated when all of the elements have been loaded. An isLoaded FALSE event is generated when one or more of the elements has failed to load, or when the timeout period is reached as specified in the timeout field. If all elements in the watchlist are already loaded by the time the LoadSensor is processed, the LoadSensor shall generate an isLoaded event with value TRUE and a progress event with value 1 at the next event cascade.

The loadTime event is generated when loading of the LoadSensor's watchList has successfully completed. If loading fails or the timeout period is reached, a loadTime event is not generated.

The progress field generates events as loading progresses. The value of progress is a floating-point number between 0 and 1 inclusive. A value of 1 indicates complete loading of all watchList elements. The exact meaning of all other values (i.e., whether these indicate a percentage of total bytes, a percentage of total number of files, or some other measurement) and the frequency with which progress events are generated are browser-dependent. Regardless, the browser shall in all cases guarantee that a progress value of 1 is generated upon successful load of all URL objects.

The following example defines a LoadSensor that monitors the progress of loading two different ImageTexture nodes:

Shape { appearance Appearance { material Material { texture DEF TEX1 ImageTexture { url "Amypic.png" } } } geometry Sphere {} } Shape { appearance Appearance { material Material { texture DEF TEX2 ImageTexture { url "Bmypic.png" } } } geometry Sphere {} } DEF LS LoadSensor { watchList [ USE TEX1, USE TEX2 ] } ROUTE LS.loadTime TO MYSCRIPT.loadTime

For watchList elements that allow dynamic reloading of their contents, any reload of that element (EXAMPLE changing the url field of an ImageTexture or setting the load field of an Inline), resets the LoadSensor so that it monitors those elements based on the new values and resets its timeout period if one was specified.

For streamed media types, the first frame of data available means successful load of the URL object (i.e., the browser can render one frame of a movie or start playing an audio file).


Member Function Documentation

void LoadSensor::traverseSG ( TraverseInfo ti  )  [virtual]

traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph.

During this traversal things can be updated in the node and HapticObject instances to be rendered should be added to the TraverseInfo object.

Parameters:
ti The TraverseInfo object containing information about the traversal.

Reimplemented from H3D::Node.

References H3D::X3DSensorNode::enabled, H3D::X3DUrlObject::FAILED, H3D::X3DSensorNode::isActive, isLoaded, H3D::X3DUrlObject::LOADED, H3D::X3DUrlObject::LOADING, H3D::X3DUrlObject::loadProgress(), H3D::X3DUrlObject::loadStatus(), loadTime, progress, timeOut, and watchList.


Member Data Documentation

The isLoaded field generates events when loading of the LoadSensor's watchList has completed.

An isLoaded TRUE event is generated when all of the elements have been loaded. An isLoaded FALSE event is generated when one or more of the elements has failed to load, or when the timeout period is reached as specified in the timeout field. If all elements in the watchlist are already loaded by the time the LoadSensor is processed, the LoadSensor shall generate an isLoaded event with value TRUE and a progress event with value 1 at the next event cascade.

Access type: outputOnly

LoadSensor_isLoaded.dot

Referenced by LoadSensor(), and traverseSG().

The loadTime event is generated when loading of the LoadSensor's watchList has successfully completed.

If loading fails or the timeout period is reached, a loadTime event is not generated.

Access type: outputOnly

LoadSensor_loadTime.dot

Referenced by LoadSensor(), and traverseSG().

The progress field generates events as loading progresses.

The value of progress is a floating-point number between 0 and 1 inclusive. A value of 1 indicates complete loading of all watchList elements.

Access type: outputOnly

LoadSensor_progress.dot

Referenced by LoadSensor(), and traverseSG().

The timeOut field specifies the maximum time for which the LoadSensor will monitor loading, starting from when the sensor becomes active.

A value of 0 for the timeOut field indicates an indefinite time out period; i.e., the LoadSensor will wait until loading has completed either with success or failure.

Access type: inputOutput Default value: 0

LoadSensor_timeOut.dot

Referenced by LoadSensor(), and traverseSG().

The watchList field contains one or more URL objects to monitor.

Only nodes that contain a valid URL field (i.e., descendants of X3DUrlObject), may be specified as elements of watchList. If multiple values are specified for this field, output events are generated only when all of the children have loaded or at least one has failed.

Access type: inputOutput

LoadSensor_watchList.dot

Referenced by traverseSG().


The documentation for this class was generated from the following files:

Generated on Fri Nov 7 10:30:33 2008 for H3D API by  doxygen 1.5.7