Wt::WResource Class Reference

An object which can be rendered in the HTTP protocol. More...

#include <WResource>

Inherits Wt::WObject.

Inherited by Wt::WFileResource, Wt::WMemoryResource, and Wt::WWidget.

Inheritance diagram for Wt::WResource:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 WResource (WObject *parent=0)
 Create a new resource.
 ~WResource ()
 Destroy the resource.
void suggestFilename (const std::string name)
 Suggest a filename to the user for the data streamed by this resource.
const std::string generateUrl () const
 Generate an URL for this resource.
bool reentrant () const
 Can this resource be streamed reentrantly ?
void setReentrant (bool reentrant)
 Specify if this resource may be streamed reentrantly.

Public Attributes

Signal< void > dataChanged
 Emit this signal if the data presented in this resource has changed.

Protected Member Functions

virtual const std::string resourceMimeType () const =0
 Return the mimetype.
virtual bool streamResourceData (std::ostream &stream)=0
 Stream the data for this resource.
void flush ()
 Flush data for this resource.

Detailed Description

An object which can be rendered in the HTTP protocol.

Besides the main page, other objects may be rendered as additional resources, such as frames or dynamic images.


Constructor & Destructor Documentation

Wt::WResource::~WResource (  ) 

Destroy the resource.

It is up to the user to make sure that the resource is nog longer in use.


Member Function Documentation

void Wt::WResource::flush (  )  [protected]

Flush data for this resource.

This is only valid when a previous call to streamResourceData() returned false.

This will trigger a call to streamResourceData() to retrieve more data to be transmitted.

See also:
streamResourceData()

const std::string Wt::WResource::generateUrl (  )  const

Generate an URL for this resource.

For every call, a new url is generated that refers to this resource. The url is unique to assure that it is not cached by the web browser. Therefore, when the signal dataChanged() is emitted, the widget that uses this resource should call generateUrl() to refer to the changed version of this resource.

bool Wt::WResource::reentrant (  )  const [inline]

Can this resource be streamed reentrantly ?

Reentrant resources may be streamed concurrently to the user. Thus, its resourceMimeType() and streamResourceData() functions must be implemented in a thread-safe way.

See also:
setReentrant()

virtual const std::string Wt::WResource::resourceMimeType (  )  const [protected, pure virtual]

Return the mimetype.

Implement this method to return the correct mime type for your resource, e.g. "text/html".

Implemented in Wt::WFileResource, Wt::WMemoryResource, and Wt::WWidget.

void Wt::WResource::setReentrant ( bool  reentrant  ) 

Specify if this resource may be streamed reentrantly.

A reentrant resource may stream its data concurrently with other resources (and with the main event handling ? perhaps this is not necessary...)

See also:
reentrant()

virtual bool Wt::WResource::streamResourceData ( std::ostream &  stream  )  [protected, pure virtual]

Stream the data for this resource.

Implement this method to output the data for this resource.

Returns whether all data has been streamed. If not, call flush() from outside the mean event loop to indicate that more data is available. This is how "server-push" is implemented. The stream is not closed until this function returns true.

See also:
flush()

Implemented in Wt::WFileResource, Wt::WMemoryResource, and Wt::WWidget.

void Wt::WResource::suggestFilename ( const std::string  name  ) 

Suggest a filename to the user for the data streamed by this resource.

For resources, intended to be downloaded by the user, suggest a name used for saving. The extension will help the browser to identify the correct program for opening the resource as well.


The documentation for this class was generated from the following files:
Generated on Sun Jul 1 19:37:18 2007 for Wt by doxygen 1.4.7