H3D API  2.4.1
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
H3D::X3DUrlObject Class Reference

This abstract interface is inherited by all nodes that contain data located on the World Wide Web, such as AudioClip, ImageTexture and Inline. More...

#include <H3D/X3DUrlObject.h>

Inheritance diagram for H3D::X3DUrlObject:
Inheritance graph

Public Types

enum  LoadStatus { INIT , LOADED , LOADING , FAILED }
 The load status of the given url. More...
 

Public Member Functions

 X3DUrlObject (Inst< MFString > _url=0)
 Constructor.
 
virtual LoadStatus loadStatus ()
 The loadStatus function returns the status of the loading of the current urls in order to be used with the LoadSensor node.
 
virtual H3DFloat loadProgress ()
 The loadProgress() functions returns a value between 0 and 1 indicating how much of the current url has been loaded. More...
 
void setURLUsed (const string &_url_used)
 Set the url that is currently loaded.
 
const string & getURLUsed ()
 Get the url that is currently loaded.
 
void setURLBase (const string &_url_base)
 Set the url base address.
 
const string & getURLBase ()
 Get the current url base address.
 
string resolveURLAsFile (const string &url, bool *is_tmp_file=NULL)
 Get the url as a local file.
 
string resolveURLAsString (const string &url)
 Get the content of the URL as a string.
 
bool removeTmpFile (const string &file)
 Remove a tmpfile with the given name. More...
 

Public Attributes

H3DUniquePtr< MFStringurl
 The urls in decreasing order of preference.
 

Protected Member Functions

string resolveURL (const string &_url, bool return_contents, bool *is_tmp_file=NULL)
 Helper function for resolveURLAs*() functions.
 
void addInlinePrefix (const string &s)
 Add a inline prefix that this node supports.
 
int getInlinedContentOffset (const std::string &url)
 If the URL contains any inline prefix, return the index of the start of the inlined content. More...
 

Protected Attributes

string url_used
 If loadStatus() returns LOADED this string should contain the url that is loaded. More...
 
string url_base
 The base URL for urls in this url object. More...
 
list< string > supported_inline_prefixes
 A list of inline prefixes that are supported by this url object. More...
 

Detailed Description

This abstract interface is inherited by all nodes that contain data located on the World Wide Web, such as AudioClip, ImageTexture and Inline.

All url fields can hold multiple string values. The strings in these fields indicate multiple locations to search for data in decreasing order of preference. If the browser cannot locate or interpret the data specified by the first location, it shall try the second and subsequent locations in order until a location containing interpretable data is encountered. X3D browsers only have to interpret a single string. If no interpretable locations are found, the node type defines the resultant default behaviour.

Member Enumeration Documentation

◆ LoadStatus

The load status of the given url.

Enumerator
INIT 

The url has not been tried to load yet.

LOADED 

The url has been successfully loaded.

LOADING 

The url is currently loading.

FAILED 

The loading of the url failed.

Member Function Documentation

◆ getInlinedContentOffset()

int X3DUrlObject::getInlinedContentOffset ( const std::string &  url)
protected

If the URL contains any inline prefix, return the index of the start of the inlined content.

Otherwise (if there is no inline prefix) return 0

Referenced by resolveURL().

◆ loadProgress()

virtual H3DFloat H3D::X3DUrlObject::loadProgress ( )
inlinevirtual

The loadProgress() functions returns a value between 0 and 1 indicating how much of the current url has been loaded.

1 means that the file has been sucessfully loaded. The only requirement of this function is that if the url has been successfully loaded the function returns 1.

Referenced by H3D::LoadSensor::traverseSG().

◆ removeTmpFile()

bool X3DUrlObject::removeTmpFile ( const string &  file)

Remove a tmpfile with the given name.

Returns true on success, or false if no such file exists or the removal failed.

References H3DUtil::ResourceResolver::releaseTmpFileName().

Member Data Documentation

◆ supported_inline_prefixes

list< string > H3D::X3DUrlObject::supported_inline_prefixes
protected

A list of inline prefixes that are supported by this url object.

E.g. "glsl", "python", etc

Referenced by addInlinePrefix().

◆ url_base

string H3D::X3DUrlObject::url_base
protected

The base URL for urls in this url object.

All relative paths will start from this. Will be set to ResourceResolver::getBaseURL() when created.

Referenced by resolveURL().

◆ url_used

string H3D::X3DUrlObject::url_used
protected

If loadStatus() returns LOADED this string should contain the url that is loaded.

All subclasses of X3DUrlObject should set this when successfully loaded a file.

Referenced by H3D::ShaderPart::loadStatus().


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