Archon::X3D::UrlObject Struct Reference

Server side representation of the equally named X3D node type. More...

#include <archon/x3d/server/network.H>

Inheritance diagram for Archon::X3D::UrlObject:

Inheritance graph
[legend]
Collaboration diagram for Archon::X3D::UrlObject:

Collaboration graph
[legend]
List of all members.

Public Member Functions

Ref< const Loader::ContentsgetContents () const
 Returns the currently loaded URI contents if any.

Static Public Attributes

static const NodeTypetype = 0

Protected Member Functions

 UrlObject ()
virtual ~UrlObject ()
void addUri (string, Time stamp)
virtual void clear ()
 Override this method if you want a chance to clean up any data produced from old URI contents such as OpenGL textures and script engines when the URI is reassigned.
virtual void onLoaded ()
 Override this method to get a notification of when the URI contents is loaded.
virtual bool mayStartLoading () const
 This method is called whenever a new value is assigned to the 'url' filed to determine if the loading should start immediatly.
void startLoading ()
 If loading of the contents corresponding to the current value of the 'url' field is not yet startet, then start it now.

Friends

void initializeNetworkComponent ()

Classes

struct  LoaderJob
 Apart from being a Loader::Job this class is responsible for communicating with the UrlObject which created it.

Detailed Description

Server side representation of the equally named X3D node type.

The base class for all X3D nodes with a single URI field such as ImageTexture and Inline.

Asynchronious download of URI contents is automatically initiated (and aborted) as a result of assignment to the URI field. Descendants of this class may choose to override the 'clear' method to get a notification of when the URI contents is deleted as a consequence of assignment to the URI field.

See also:
UrlObject::getContents

UrlObject::clear

Todo:
It would proberbly be a good idea to utilize the new RefObjectBase::dispose method instead of the rather complex use of Utilities::Ref<T>::getSafeRef.

Definition at line 56 of file network.H.


Member Function Documentation

void Archon::X3D::UrlObject::addUri string  ,
Time  stamp
[protected]
 

Contents loading is dealt with though.

Definition at line 113 of file network.C.

References Archon::X3D::NodeBase::context, Archon::X3D::NodeBase::isRealizedNoLock(), Archon::X3D::NodeType::lookupField(), Archon::X3D::NodeBase::mutex, Archon::X3D::FieldBase::set(), and Archon::X3D::MFString::type.

virtual void Archon::X3D::UrlObject::clear  )  [inline, protected, virtual]
 

Override this method if you want a chance to clean up any data produced from old URI contents such as OpenGL textures and script engines when the URI is reassigned.

Will be called with a scenegraph write lock or a Node lock.

Definition at line 87 of file network.H.

Ref< const Loader::Contents > Archon::X3D::UrlObject::getContents  )  const
 

Returns the currently loaded URI contents if any.

This method will return the null reference if either the URI field is empty or the download is not yet complete or the download has failed.

Definition at line 102 of file network.C.

Referenced by Archon::Raytracer::SceneLoader::doShape(), and Archon::X3D::Viewer::ShapeCache::updateTexture().

virtual bool Archon::X3D::UrlObject::mayStartLoading  )  const [inline, protected, virtual]
 

This method is called whenever a new value is assigned to the 'url' filed to determine if the loading should start immediatly.

The default is that loading will start immediately.

You may override this method if you want to change the default.

Note:
This method is called with either a scenegraph write lock or a Node lock.

Definition at line 124 of file network.H.

virtual void Archon::X3D::UrlObject::onLoaded  )  [inline, protected, virtual]
 

Override this method to get a notification of when the URI contents is loaded.

BEWARE though, that this method is called asynchroniously by the loader thread. this means that you generally cannot access anything which is changed by other threads without locking a mutex. This includes everything which may be updated during an event cascade (all X3D fields).

You should not do too much work from this method since the UrlObject may get orphaned at any time, meaning that the only reference to it will be the one held by the loader thread. This means that the performed work will be in vain. You may try to detect the orphaned condition with 'RefObjectBaseuse_count() == 1'.

Note:
Neither the scenegraph nor the node is locked when this method is called.

Definition at line 109 of file network.H.

void Archon::X3D::UrlObject::startLoading  )  [protected]
 

If loading of the contents corresponding to the current value of the 'url' field is not yet startet, then start it now.

Note:
You must always call this method with either a scenegraph write lock or a Node lock.

This method is automatically called when a new value is assigned to the 'url' field if 'mayStartLoading' returns true.

Definition at line 228 of file network.C.

References Archon::X3D::NodeBase::context, and Archon::Utilities::BackRef< T >::getRef().


Friends And Related Function Documentation

void initializeNetworkComponent  )  [friend]
 

Todo:
I think the AplicationLink node is defined in a way that allows defining them in X3D files.
If so, this should be prevented. Well, does it even need to be defined as a type here? And, could it not be moved to X3D::SAI?.

Reimplemented in Archon::X3D::Inline.

Definition at line 49 of file network.C.


The documentation for this struct was generated from the following files:
Generated on Sun Jul 30 23:00:46 2006 for Archon by  doxygen 1.4.4