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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
|
<!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::WSignalMapper< T, A1 > Class Template 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_1WSignalMapper.html">WSignalMapper</a>
</div>
</div>
<div class="contents">
<h1>Wt::WSignalMapper< T, A1 > Class Template Reference<br>
<small>
[<a class="el" href="group__signalslot.html">Signal/slot system</a>]</small>
</h1><!-- doxytag: class="Wt::WSignalMapper" --><!-- doxytag: inherits="Wt::WObject" -->A utility class to connect multiple senders to a single slot.
<a href="#_details">More...</a>
<p>
<code>#include <Wt/WSignalMapper></code>
<p>
<div class="dynheader">
Inheritance diagram for Wt::WSignalMapper< T, A1 >:</div>
<div class="dynsection">
<p><center><img src="classWt_1_1WSignalMapper__inherit__graph.png" border="0" usemap="#Wt_1_1WSignalMapper_3_01T_00_01A1_01_4__inherit__map" alt="Inheritance graph"></center>
<map name="Wt_1_1WSignalMapper_3_01T_00_01A1_01_4__inherit__map">
<area shape="rect" href="classWt_1_1WObject.html" title="A base class for objects that participate in the signal/slot system." alt="" coords="53,5,149,32"></map>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center></div>
<p>
<a href="classWt_1_1WSignalMapper-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"><a class="anchor" name="5c23094be042e549bb54a09c14fd5bd2"></a><!-- doxytag: member="Wt::WSignalMapper::WSignalMapper" ref="5c23094be042e549bb54a09c14fd5bd2" args="(WObject *parent=0)" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WSignalMapper.html#5c23094be042e549bb54a09c14fd5bd2">WSignalMapper</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 WSignalMapper. <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_1WSignalMapper.html#89ccb4bde41e6e326072077214756ccc">setMapping</a> (<a class="el" href="classWt_1_1WObject.html">WObject</a> *sender, const T &data)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Associates data with a sender. <a href="#89ccb4bde41e6e326072077214756ccc"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">boost::signals::connection </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WSignalMapper.html#1d2c6572bf0b8dbd21e2f0d0b19dfc30">mapConnect</a> (SignalBase &signal, const T &data)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Maps a signal without arguments. <a href="#1d2c6572bf0b8dbd21e2f0d0b19dfc30"></a><br></td></tr>
<tr><td class="memTemplParams" nowrap colspan="2">template<typename S> </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">boost::signals::connection </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classWt_1_1WSignalMapper.html#b5ecc06f3bbd26be127027b058bfbadf">mapConnect1</a> (S &signal, const T &data)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Maps a signal with one argument. <a href="#b5ecc06f3bbd26be127027b058bfbadf"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classWt_1_1Signal.html">Signal</a>< T, A1 > & </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WSignalMapper.html#bd2fae2a26c9f89928d32f6e209671eb">mapped</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Signal emitted in response to a signal sent to <a class="el" href="classWt_1_1WSignalMapper.html#f4bc239e4f47ae25e6544be3dd1676de" title="Slot to which to connect the source signal.">map()</a> or <a class="el" href="classWt_1_1WSignalMapper.html#236a9f2bfa71fd1f990f04e105782976" title="Slot to which to connect the source signal, passing the argument to the receiver...">map1()</a>. <a href="#bd2fae2a26c9f89928d32f6e209671eb"></a><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_1WSignalMapper.html#f4bc239e4f47ae25e6544be3dd1676de">map</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Slot to which to connect the source signal. <a href="#f4bc239e4f47ae25e6544be3dd1676de"></a><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_1WSignalMapper.html#236a9f2bfa71fd1f990f04e105782976">map1</a> (A1 a)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Slot to which to connect the source signal, passing the argument to the receiver. <a href="#236a9f2bfa71fd1f990f04e105782976"></a><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_1WSignalMapper.html#395e321c3c545225a3669608044b2454">removeMapping</a> (<a class="el" href="classWt_1_1WObject.html">WObject</a> *sender)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Removes the mapping of an object. <a href="#395e321c3c545225a3669608044b2454"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<h3>template<typename T, typename A1 = NoClass><br>
class Wt::WSignalMapper< T, A1 ></h3>
A utility class to connect multiple senders to a single slot.
<p>
This class is useful if you would like to respond to signals of many objects or widgets within a single slot, but need to identify the particular sender through some property.<p>
Usage example: <div class="fragment"><pre class="fragment"> <span class="keywordtype">void</span> Test::createWidgets()
{
<a class="code" href="classWt_1_1WSignalMapper.html" title="A utility class to connect multiple senders to a single slot.">Wt::WSignalMapper<WText *></a> *MyMap = <span class="keyword">new</span> <a class="code" href="classWt_1_1WSignalMapper.html" title="A utility class to connect multiple senders to a single slot.">Wt::WSignalMapper<Wt::WText *></a>(<span class="keyword">this</span>);
<span class="comment">// connect mapped() to our target slot</span>
MyMap-><a class="code" href="classWt_1_1WSignalMapper.html#bd2fae2a26c9f89928d32f6e209671eb" title="Signal emitted in response to a signal sent to map() or map1().">mapped</a>().connect(SLOT(<span class="keyword">this</span>, Test::onClick));
<span class="comment">// connect and map every source signal to the mapper</span>
MyMap-><a class="code" href="classWt_1_1WSignalMapper.html#1d2c6572bf0b8dbd21e2f0d0b19dfc30" title="Maps a signal without arguments.">mapConnect</a>(text1->clicked(), text1);
MyMap-><a class="code" href="classWt_1_1WSignalMapper.html#1d2c6572bf0b8dbd21e2f0d0b19dfc30" title="Maps a signal without arguments.">mapConnect</a>(text2->clicked(), text2);
MyMap-><a class="code" href="classWt_1_1WSignalMapper.html#1d2c6572bf0b8dbd21e2f0d0b19dfc30" title="Maps a signal without arguments.">mapConnect</a>(text3->clicked(), text3);
}
<span class="keywordtype">void</span> Test::onClick(WText* source)
{
<span class="comment">// source is where it is coming from</span>
<span class="comment">// ...</span>
}
</pre></div><p>
The type <em>T</em> may be any type that has proper copy semantics and a default constructor. The mapper may pass one extra argument (type <em>A1</em>) from the original signal to the <a class="el" href="classWt_1_1WSignalMapper.html#bd2fae2a26c9f89928d32f6e209671eb" title="Signal emitted in response to a signal sent to map() or map1().">mapped()</a> signal. In that case, you must connect the original signal to the <a class="el" href="classWt_1_1WSignalMapper.html#236a9f2bfa71fd1f990f04e105782976" title="Slot to which to connect the source signal, passing the argument to the receiver...">map1()</a> slot, or use <a class="el" href="classWt_1_1WSignalMapper.html#b5ecc06f3bbd26be127027b058bfbadf" title="Maps a signal with one argument.">mapConnect1()</a>. <hr><h2>Member Function Documentation</h2>
<a class="anchor" name="89ccb4bde41e6e326072077214756ccc"></a><!-- doxytag: member="Wt::WSignalMapper::setMapping" ref="89ccb4bde41e6e326072077214756ccc" args="(WObject *sender, const T &data)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T, typename A1> </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classWt_1_1WSignalMapper.html">Wt::WSignalMapper</a>< T, A1 >::setMapping </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classWt_1_1WObject.html">WObject</a> * </td>
<td class="paramname"> <em>sender</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const T & </td>
<td class="paramname"> <em>data</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Associates data with a sender.
<p>
Associate data with a sender, which wel emitted by the <a class="el" href="classWt_1_1WSignalMapper.html#bd2fae2a26c9f89928d32f6e209671eb" title="Signal emitted in response to a signal sent to map() or map1().">mapped()</a> signal, when the corresponding sender signal triggers <a class="el" href="classWt_1_1WSignalMapper.html#f4bc239e4f47ae25e6544be3dd1676de" title="Slot to which to connect the source signal.">map()</a> or <a class="el" href="classWt_1_1WSignalMapper.html#236a9f2bfa71fd1f990f04e105782976" title="Slot to which to connect the source signal, passing the argument to the receiver...">map1()</a>.
</div>
</div><p>
<a class="anchor" name="1d2c6572bf0b8dbd21e2f0d0b19dfc30"></a><!-- doxytag: member="Wt::WSignalMapper::mapConnect" ref="1d2c6572bf0b8dbd21e2f0d0b19dfc30" args="(SignalBase &signal, const T &data)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T, typename A1> </div>
<table class="memname">
<tr>
<td class="memname">boost::signals::connection <a class="el" href="classWt_1_1WSignalMapper.html">Wt::WSignalMapper</a>< T, A1 >::mapConnect </td>
<td>(</td>
<td class="paramtype">SignalBase & </td>
<td class="paramname"> <em>signal</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const T & </td>
<td class="paramname"> <em>data</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Maps a signal without arguments.
<p>
Connect the given signal with the slot, and associate the data when it is triggered.<p>
<div class="fragment"><pre class="fragment"> <a class="code" href="classWt_1_1WSignalMapper.html" title="A utility class to connect multiple senders to a single slot.">Wt::WSignalMapper<T></a> *mapper = ...
mapper-><a class="code" href="classWt_1_1WSignalMapper.html#1d2c6572bf0b8dbd21e2f0d0b19dfc30" title="Maps a signal without arguments.">mapConnect</a>(widget->clicked(), data);
</pre></div> is equivalent to: <div class="fragment"><pre class="fragment"> <a class="code" href="classWt_1_1WSignalMapper.html" title="A utility class to connect multiple senders to a single slot.">Wt::WSignalMapper<T></a> *mapper = ...
widget->clicked().connect(SLOT(mapper, <a class="code" href="classWt_1_1WSignalMapper.html" title="A utility class to connect multiple senders to a single slot.">Wt::WSignalMapper<T>::map</a>));
mapper-><a class="code" href="classWt_1_1WSignalMapper.html#89ccb4bde41e6e326072077214756ccc" title="Associates data with a sender.">setMapping</a>(widget, data);
</pre></div>
</div>
</div><p>
<a class="anchor" name="b5ecc06f3bbd26be127027b058bfbadf"></a><!-- doxytag: member="Wt::WSignalMapper::mapConnect1" ref="b5ecc06f3bbd26be127027b058bfbadf" args="(S &signal, const T &data)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T, typename A1> </div>
<div class="memtemplate">
template<typename S> </div>
<table class="memname">
<tr>
<td class="memname">boost::signals::connection <a class="el" href="classWt_1_1WSignalMapper.html">Wt::WSignalMapper</a>< T, A1 >::mapConnect1 </td>
<td>(</td>
<td class="paramtype">S & </td>
<td class="paramname"> <em>signal</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const T & </td>
<td class="paramname"> <em>data</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Maps a signal with one argument.
<p>
Connect the given signal with the slot, and associate the data when it is triggered. The signal argument will be passed to the <a class="el" href="classWt_1_1WSignalMapper.html#bd2fae2a26c9f89928d32f6e209671eb" title="Signal emitted in response to a signal sent to map() or map1().">mapped()</a> signal.<p>
<div class="fragment"><pre class="fragment"> <a class="code" href="classWt_1_1WSignalMapper.html" title="A utility class to connect multiple senders to a single slot.">Wt::WSignalMapper<T, Wt::WMouseEvent></a> *mapper = ...
mapper-><a class="code" href="classWt_1_1WSignalMapper.html#1d2c6572bf0b8dbd21e2f0d0b19dfc30" title="Maps a signal without arguments.">mapConnect</a>(widget->clicked(), data);
</pre></div> is equivalent to: <div class="fragment"><pre class="fragment"> <a class="code" href="classWt_1_1WSignalMapper.html" title="A utility class to connect multiple senders to a single slot.">Wt::WSignalMapper<T, Wt::WMouseEvent></a> *mapper = ...
widget->clicked().connect(SLOT(mapper, <a class="code" href="classWt_1_1WSignalMapper.html" title="A utility class to connect multiple senders to a single slot.">Wt::WSignalMapper<T, Wt::WMouseEvent>::map1</a>));
mapper-><a class="code" href="classWt_1_1WSignalMapper.html#89ccb4bde41e6e326072077214756ccc" title="Associates data with a sender.">setMapping</a>(widget, data);
</pre></div>
</div>
</div><p>
<a class="anchor" name="bd2fae2a26c9f89928d32f6e209671eb"></a><!-- doxytag: member="Wt::WSignalMapper::mapped" ref="bd2fae2a26c9f89928d32f6e209671eb" args="()" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T, typename A1 = NoClass> </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classWt_1_1Signal.html">Signal</a><T, A1>& <a class="el" href="classWt_1_1WSignalMapper.html">Wt::WSignalMapper</a>< T, A1 >::mapped </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Signal emitted in response to a signal sent to <a class="el" href="classWt_1_1WSignalMapper.html#f4bc239e4f47ae25e6544be3dd1676de" title="Slot to which to connect the source signal.">map()</a> or <a class="el" href="classWt_1_1WSignalMapper.html#236a9f2bfa71fd1f990f04e105782976" title="Slot to which to connect the source signal, passing the argument to the receiver...">map1()</a>.
<p>
The first argument propagated is the data that is associated with the specific sender, set in <a class="el" href="classWt_1_1WSignalMapper.html#89ccb4bde41e6e326072077214756ccc" title="Associates data with a sender.">setMapping()</a> or <a class="el" href="classWt_1_1WSignalMapper.html#1d2c6572bf0b8dbd21e2f0d0b19dfc30" title="Maps a signal without arguments.">mapConnect()</a>. The second argument is an argument passed from the originating signal.
</div>
</div><p>
<a class="anchor" name="f4bc239e4f47ae25e6544be3dd1676de"></a><!-- doxytag: member="Wt::WSignalMapper::map" ref="f4bc239e4f47ae25e6544be3dd1676de" args="()" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T, typename A1> </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classWt_1_1WSignalMapper.html">Wt::WSignalMapper</a>< T, A1 >::map </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Slot to which to connect the source signal.
<p>
When a signal triggers the slot, the sender is identified and used to find corresponding data set with <a class="el" href="classWt_1_1WSignalMapper.html#89ccb4bde41e6e326072077214756ccc" title="Associates data with a sender.">setMapping()</a>, which is then use to propagate further in the <a class="el" href="classWt_1_1WSignalMapper.html#bd2fae2a26c9f89928d32f6e209671eb" title="Signal emitted in response to a signal sent to map() or map1().">mapped()</a> signal.
</div>
</div><p>
<a class="anchor" name="236a9f2bfa71fd1f990f04e105782976"></a><!-- doxytag: member="Wt::WSignalMapper::map1" ref="236a9f2bfa71fd1f990f04e105782976" args="(A1 a)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T, typename A1> </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classWt_1_1WSignalMapper.html">Wt::WSignalMapper</a>< T, A1 >::map1 </td>
<td>(</td>
<td class="paramtype">A1 </td>
<td class="paramname"> <em>a</em> </td>
<td> ) </td>
<td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Slot to which to connect the source signal, passing the argument to the receiver.
<p>
When a signal triggers the slot, the sender is identified and used to find corresponding data set with <a class="el" href="classWt_1_1WSignalMapper.html#89ccb4bde41e6e326072077214756ccc" title="Associates data with a sender.">setMapping()</a>, which is then use to propagate further in the <a class="el" href="classWt_1_1WSignalMapper.html#bd2fae2a26c9f89928d32f6e209671eb" title="Signal emitted in response to a signal sent to map() or map1().">mapped()</a> signal. The additional argument <code>a</code> is passed as the second argument to the <a class="el" href="classWt_1_1WSignalMapper.html#bd2fae2a26c9f89928d32f6e209671eb" title="Signal emitted in response to a signal sent to map() or map1().">mapped()</a> signal.
</div>
</div><p>
<a class="anchor" name="395e321c3c545225a3669608044b2454"></a><!-- doxytag: member="Wt::WSignalMapper::removeMapping" ref="395e321c3c545225a3669608044b2454" args="(WObject *sender)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T, typename A1> </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classWt_1_1WSignalMapper.html">Wt::WSignalMapper</a>< T, A1 >::removeMapping </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classWt_1_1WObject.html">WObject</a> * </td>
<td class="paramname"> <em>sender</em> </td>
<td> ) </td>
<td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Removes the mapping of an object.
<p>
This method does not disconnect any signals; that is the responsability of the user of <a class="el" href="classWt_1_1WSignalMapper.html" title="A utility class to connect multiple senders to a single slot.">WSignalMapper</a>. If no mapping of for an object exits, the mapper will ignore the signal, and not emit the mapped signal.
</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>
|