1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Wt: Wt::WMemoryResource Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
<div class="navpath"><a class="el" href="namespaceWt.html">Wt</a>::<a class="el" href="classWt_1_1WMemoryResource.html">WMemoryResource</a>
</div>
</div>
<div class="contents">
<h1>Wt::WMemoryResource Class Reference</h1><!-- doxytag: class="Wt::WMemoryResource" --><!-- doxytag: inherits="Wt::WResource" -->A resource which streams data from memory.
<a href="#_details">More...</a>
<p>
<code>#include <Wt/WMemoryResource></code>
<p>
<div class="dynheader">
Inheritance diagram for Wt::WMemoryResource:</div>
<div class="dynsection">
<p><center><img src="classWt_1_1WMemoryResource__inherit__graph.png" border="0" usemap="#Wt_1_1WMemoryResource__inherit__map" alt="Inheritance graph"></center>
<map name="Wt_1_1WMemoryResource__inherit__map">
<area shape="rect" href="classWt_1_1WResource.html" title="An object which can be rendered in the HTTP protocol." alt="" coords="29,80,141,107"><area shape="rect" href="classWt_1_1WObject.html" title="A base class for objects that participate in the signal/slot system." alt="" coords="37,5,133,32"></map>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center></div>
<p>
<a href="classWt_1_1WMemoryResource-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WMemoryResource.html#70c4b30cfef23b4a1ae692a4c90ead2b">WMemoryResource</a> (<a class="el" href="classWt_1_1WObject.html">WObject</a> *parent=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Creates a new resource. <a href="#70c4b30cfef23b4a1ae692a4c90ead2b"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WMemoryResource.html#8e72d3dae82e6c1a417bdc8a0439ab34">WMemoryResource</a> (const std::string &mimeType, <a class="el" href="classWt_1_1WObject.html">WObject</a> *parent=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Creates a new resource with given mime-type. <a href="#8e72d3dae82e6c1a417bdc8a0439ab34"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="2060c05ef2cb27ef6d7a5cf204a053f5"></a><!-- doxytag: member="Wt::WMemoryResource::WMemoryResource" ref="2060c05ef2cb27ef6d7a5cf204a053f5" args="(const std::string &mimeType, const std::vector< unsigned char > &data, WObject *parent=0)" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WMemoryResource.html#2060c05ef2cb27ef6d7a5cf204a053f5">WMemoryResource</a> (const std::string &mimeType, const std::vector< unsigned char > &data, <a class="el" href="classWt_1_1WObject.html">WObject</a> *parent=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Creates a new resource with given mime-type and data. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="330bf924bd2d01de7dfce15778b56d48"></a><!-- doxytag: member="Wt::WMemoryResource::setData" ref="330bf924bd2d01de7dfce15778b56d48" args="(const std::vector< unsigned char > &data)" -->
void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WMemoryResource.html#330bf924bd2d01de7dfce15778b56d48">setData</a> (const std::vector< unsigned char > &data)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Sets new data for the resource to serve. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WMemoryResource.html#9ad4324110014390132405e941c9c87c">setData</a> (const unsigned char *data, int count)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Sets new data for the resource to serve. <a href="#9ad4324110014390132405e941c9c87c"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="00b0908ba8be1c51ba964a31d6d43712"></a><!-- doxytag: member="Wt::WMemoryResource::mimeType" ref="00b0908ba8be1c51ba964a31d6d43712" args="() const " -->
const std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WMemoryResource.html#00b0908ba8be1c51ba964a31d6d43712">mimeType</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the mime-type. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="057ea5ac18daacf2894c28e5bfbbde60"></a><!-- doxytag: member="Wt::WMemoryResource::setMimeType" ref="057ea5ac18daacf2894c28e5bfbbde60" args="(const std::string &mimeType)" -->
void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WMemoryResource.html#057ea5ac18daacf2894c28e5bfbbde60">setMimeType</a> (const std::string &mimeType)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Sets the mime-type. <br></td></tr>
<tr><td colspan="2"><br><h2>Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WMemoryResource.html#7800a19988ddf5af4e4ffe0f323316ae">handleRequest</a> (const <a class="el" href="classWt_1_1Http_1_1Request.html">Http::Request</a> &request, <a class="el" href="classWt_1_1Http_1_1Response.html">Http::Response</a> &response)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Handles a request. <a href="#7800a19988ddf5af4e4ffe0f323316ae"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A resource which streams data from memory.
<p>
Use this resource if you want to serve resource data from memory. This is suitable for relatively small resources, which still require some computation.<p>
If creating the data requires computation which you would like to post-pone until the resource is served, then you may want to directly reimplement <a class="el" href="classWt_1_1WResource.html" title="An object which can be rendered in the HTTP protocol.">WResource</a> instead and compute the data on the fly while streaming.<p>
Usage examples: <div class="fragment"><pre class="fragment"> <a class="code" href="classWt_1_1WMemoryResource.html" title="A resource which streams data from memory.">Wt::WMemoryResource</a> *imageResource = <span class="keyword">new</span> <a class="code" href="classWt_1_1WMemoryResource.html" title="A resource which streams data from memory.">Wt::WMemoryResource</a>(<span class="stringliteral">"image/gif"</span>, <span class="keyword">this</span>);
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> gifData[]
= { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00,
0x80, 0x00, 0x00, 0xdb, 0xdf, 0xef, 0x00, 0x00, 0x00, 0x21,
0xf9, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00,
0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44,
0x01, 0x00, 0x3b };
imageResource-><a class="code" href="classWt_1_1WMemoryResource.html#330bf924bd2d01de7dfce15778b56d48" title="Sets new data for the resource to serve.">setData</a>(gifData, 43);
<a class="code" href="classWt_1_1WImage.html" title="A widget that displays an image.">Wt::WImage</a> *image = <span class="keyword">new</span> <a class="code" href="classWt_1_1WImage.html" title="A widget that displays an image.">Wt::WImage</a>(imageResource, <span class="stringliteral">"1 transparent pixel"</span>);
</pre></div><p>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1WFileResource.html" title="A resource which streams data from a local file.">WFileResource</a>. </dd></dl>
<hr><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" name="70c4b30cfef23b4a1ae692a4c90ead2b"></a><!-- doxytag: member="Wt::WMemoryResource::WMemoryResource" ref="70c4b30cfef23b4a1ae692a4c90ead2b" args="(WObject *parent=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Wt::WMemoryResource::WMemoryResource </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classWt_1_1WObject.html">WObject</a> * </td>
<td class="paramname"> <em>parent</em> = <code>0</code> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Creates a new resource.
<p>
You must call <a class="el" href="classWt_1_1WMemoryResource.html#057ea5ac18daacf2894c28e5bfbbde60" title="Sets the mime-type.">setMimeType()</a> and <a class="el" href="classWt_1_1WMemoryResource.html#330bf924bd2d01de7dfce15778b56d48" title="Sets new data for the resource to serve.">setData()</a> before using the resource.
</div>
</div><p>
<a class="anchor" name="8e72d3dae82e6c1a417bdc8a0439ab34"></a><!-- doxytag: member="Wt::WMemoryResource::WMemoryResource" ref="8e72d3dae82e6c1a417bdc8a0439ab34" args="(const std::string &mimeType, WObject *parent=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Wt::WMemoryResource::WMemoryResource </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"> <em>mimeType</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="classWt_1_1WObject.html">WObject</a> * </td>
<td class="paramname"> <em>parent</em> = <code>0</code></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Creates a new resource with given mime-type.
<p>
You must call <a class="el" href="classWt_1_1WMemoryResource.html#330bf924bd2d01de7dfce15778b56d48" title="Sets new data for the resource to serve.">setData()</a> before using the resource.
</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="9ad4324110014390132405e941c9c87c"></a><!-- doxytag: member="Wt::WMemoryResource::setData" ref="9ad4324110014390132405e941c9c87c" args="(const unsigned char *data, int count)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Wt::WMemoryResource::setData </td>
<td>(</td>
<td class="paramtype">const unsigned char * </td>
<td class="paramname"> <em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>count</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Sets new data for the resource to serve.
<p>
Sets the data from using the first <code>count</code> bytes from the C-style <code>data</code> array.
</div>
</div><p>
<a class="anchor" name="7800a19988ddf5af4e4ffe0f323316ae"></a><!-- doxytag: member="Wt::WMemoryResource::handleRequest" ref="7800a19988ddf5af4e4ffe0f323316ae" args="(const Http::Request &request, Http::Response &response)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Wt::WMemoryResource::handleRequest </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classWt_1_1Http_1_1Request.html">Http::Request</a> & </td>
<td class="paramname"> <em>request</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="classWt_1_1Http_1_1Response.html">Http::Response</a> & </td>
<td class="paramname"> <em>response</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [protected, virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Handles a request.
<p>
Reimplement this method so that a proper response is generated for the given request. From the <code>request</code> object you can access request parameters and whether the request is a continuation request. In the <code>response</code> object, you should set the mime type and stream the output data.<p>
A request may also concern a continuation, indicated in <a class="el" href="classWt_1_1Http_1_1Request.html#2d4f88961a222be846460a8238823ae0" title="Returns a continuation object.">Http::Request::continuation()</a>, in which case the next part for a previously created continuation should be served.<p>
While handling a request, which may happen at any time together with event handling, the library makes sure that the resource is not being concurrently deleted, but multiple requests may happend simultaneously for a single resource.
<p>Implements <a class="el" href="classWt_1_1WResource.html#3a740f8cc29e2e6e4e58defc9c88b8b6">Wt::WResource</a>.</p>
</div>
</div><p>
</div>
<hr size="1"><address style="align: right;"><small>
Generated on Fri Mar 26 17:12:07 2010 for <a href="http://www.webtoolkit.eu/wt/">Wt</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6</small></address>
</body>
</html>
|