root/trunk/luigi/doc/signalobj.html

Revision 36, 13.6 kB (checked in by baxissimo, 2 years ago)

First cut at docs using Candydoc.

Line 
1 <html><head>
2 <meta http-equiv="content-type" content="text/html; charset=utf-8">
3 <meta content="text/javascript" http-equiv="content-script-type">
4 <title>luigi.signalobj</title>
5 <link rel="stylesheet" type="text/css" href="candydoc/style.css">
6 <!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]-->
7 <script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script>
8 <script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script>
9 <script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script>
10 </head><body>
11 <div id="tabarea"></div><div id="explorerclient"></div>
12 <div id="content"><script>explorer.initialize("luigi.signalobj");</script>
13     <table class="content">
14         <tr><td id="docbody"><h1>luigi.signalobj</h1><!-- Generated by Ddoc from signalobj.d -->
15
16 <span class="currsymbol">signalobj</span>
17 <script>explorer.outline.addDecl('signalobj');</script>
18
19 .d - a few utilities for creating signal objects for more flexible
20    signals and slots.
21 <br><br>
22 Written by Bill Baxter, November 9, 2006.
23  This code is released to the public domain
24  
25 <br><br>
26
27
28 <script>explorer.outline.incSymbolLevel();</script>
29 <dl>
30 <script>explorer.outline.writeEnabled = true;</script>
31 <dt><span class="decl">class
32 <span class="currsymbol">SignalObj</span>
33 <script>explorer.outline.addDecl('SignalObj');</script>
34
35 (T...);
36 </span></dt>
37 <script>explorer.outline.writeEnabled = false;</script>
38
39
40 <dd>A simple object that wraps a std.signal.  This allows creating signals at
41   global scope, returning them from functions, etc.
42   In terms of what can be connected, this has the same restrictions as
43   the std.signal.Signal mixin, namely the slot delegate signature must
44   match the signal's signature exactly.
45  
46 <br><br>
47
48
49 <script>explorer.outline.incSymbolLevel();</script>
50 <dl></dl>
51 <script>explorer.outline.decSymbolLevel();</script>
52
53
54 </dd>
55
56 <script>explorer.outline.writeEnabled = true;</script>
57 <dt><span class="decl">class
58 <span class="currsymbol">DelegateSlot</span>
59 <script>explorer.outline.addDecl('DelegateSlot');</script>
60
61 (T...);
62 </span></dt>
63 <script>explorer.outline.writeEnabled = false;</script>
64
65
66 <dd>A wrapper for a delegate.  This lets one use delegate literals
67  as a slot in some situations where they would cause access errors.
68  
69 <br><br>
70
71
72 <script>explorer.outline.incSymbolLevel();</script>
73 <dl></dl>
74 <script>explorer.outline.decSymbolLevel();</script>
75
76
77 </dd>
78
79 <script>explorer.outline.writeEnabled = true;</script>
80 <dt><span class="decl">struct
81 <span class="currsymbol">slot_key</span>
82 <script>explorer.outline.addDecl('slot_key');</script>
83
84 ;
85 </span></dt>
86 <script>explorer.outline.writeEnabled = false;</script>
87
88
89 <dd>A simple opaque datatype which serves as a key for FlexSignal.fdisconnect.
90   The primary use is internal, for keeping a mapping between user slots
91   and their wrappers.  However, they can also be used as a key to a delegate
92   literal for later disconnecting.
93  
94 <br><br>
95
96
97 <script>explorer.outline.incSymbolLevel();</script>
98 <dl></dl>
99 <script>explorer.outline.decSymbolLevel();</script>
100
101
102 </dd>
103
104 <script>explorer.outline.writeEnabled = true;</script>
105 <dt><span class="decl">class
106 <span class="currsymbol">FlexSignal</span>
107 <script>explorer.outline.addDecl('FlexSignal');</script>
108
109 (T...);
110 </span></dt>
111 <script>explorer.outline.writeEnabled = false;</script>
112
113
114 <dd>
115 <span class="currsymbol">FlexSignal</span>
116 <script>explorer.outline.addDecl('FlexSignal');</script>
117
118  is a more flexible version of a signal object wrapper.
119 <br><br>
120 Using the connect/disconnect methods it is possible to connect the
121   signal to most any callable entity with a signature that is 'compatible'.
122   with the signal's signature.
123 <br><br>
124
125   Specifically one can connect
126   - functions and delegate literals.
127   - slots that return values (the return value is simply ignored by the signal)
128   - slots that take fewer parameters than the signal supplies
129     (trailing paramters from signal simply aren't passed to the slot).
130   - delegates with fewer arguments
131   than the signal supplies are allowed, and any argument which can
132   be implicitly converted by D is allowed as well.
133  
134 <br><br>
135
136
137 <script>explorer.outline.incSymbolLevel();</script>
138 <dl>
139 <script>explorer.outline.writeEnabled = true;</script>
140 <dt><span class="decl">void
141 <span class="currsymbol">emit</span>
142 <script>explorer.outline.addDecl('emit');</script>
143
144 (T <span class="funcparam">v</span>);
145 </span></dt>
146 <script>explorer.outline.writeEnabled = false;</script>
147
148
149 <dd>Emit the signal with the given arguments.
150      
151 <br><br>
152
153 </dd>
154
155 <script>explorer.outline.writeEnabled = true;</script>
156 <dt><span class="decl">slot_t
157 <span class="currsymbol">connect_exact</span>
158 <script>explorer.outline.addDecl('connect_exact');</script>
159
160 (slot_t <span class="funcparam">f</span>);
161 </span></dt>
162 <script>explorer.outline.writeEnabled = false;</script>
163
164
165 <dd>Connect a slot to the signal using a class delegate exactly
166   matching the signature of the signal.
167 <br><br>
168 <b>Returns:</b><br>
169 the slot passed in.
170      
171 <br><br>
172
173 </dd>
174
175 <script>explorer.outline.writeEnabled = true;</script>
176 <dt><span class="decl">slot_t
177 <span class="currsymbol">disconnect_exact</span>
178 <script>explorer.outline.addDecl('disconnect_exact');</script>
179
180 (slot_t <span class="funcparam">f</span>);
181 </span></dt>
182 <script>explorer.outline.writeEnabled = false;</script>
183
184
185 <dd>Disconnect a slot from the signal using a class delegate exactly
186   matching the signature of the signal.
187 <br><br>
188 <b>Returns:</b><br>
189 the slot passed in.
190      
191 <br><br>
192
193 </dd>
194
195 <script>explorer.outline.writeEnabled = true;</script>
196 <dt><span class="decl">template
197 <span class="currsymbol">connect</span>
198 <script>explorer.outline.addDecl('connect');</script>
199
200 (DT,int arg_offset = 0)</span></dt>
201 <script>explorer.outline.writeEnabled = false;</script>
202
203
204 <dd>A flexible version of
205 <span class="currsymbol">connect</span>
206 <script>explorer.outline.addDecl('connect');</script>
207
208 .  Works for delegates to classes
209  or structs, plain functions, delegate literals.  Also works for
210  things with or without return values, and with fewer
211  arguments than the signal supplies.
212 <br><br>
213 So for example, an (int,char[]) FlexSignal can be connected to an
214  int funciton that returns a float.
215 <br><br>
216
217  Also it can convert compatible argument types, any thing that can
218  be implicitly converted at runtime is allowed.
219 <br><br>
220
221  So for example, the (int, char[]) FlexSigal can be connected to a
222  method taking a (double,char[]) because int is automatically
223  promoted to double.
224
225 <br><br>
226 <b>Returns:</b><br>
227 a slot key which can be used to disconnect the item
228  later.  (You can also use the original slot to disconnect if you
229  have it.)
230      
231 <br><br>
232
233
234 <script>explorer.outline.incSymbolLevel();</script>
235 <dl>
236 <script>explorer.outline.writeEnabled = true;</script>
237 <dt><span class="decl">slot_key
238 <span class="currsymbol">connect</span>
239 <script>explorer.outline.addDecl('connect');</script>
240
241 (DT <span class="funcparam">f</span>);
242 </span></dt>
243 <script>explorer.outline.writeEnabled = false;</script>
244
245
246 <dd>A flexible version of
247 <span class="currsymbol">connect</span>
248 <script>explorer.outline.addDecl('connect');</script>
249
250 .  Works for delegates to classes
251  or structs, plain functions, delegate literals.  Also works for
252  things with or without return values, and with fewer
253  arguments than the signal supplies.
254 <br><br>
255 So for example, an (int,char[]) FlexSignal can be connected to an
256  int funciton that returns a float.
257 <br><br>
258
259  Also it can convert compatible argument types, any thing that can
260  be implicitly converted at runtime is allowed.
261 <br><br>
262
263  So for example, the (int, char[]) FlexSigal can be connected to a
264  method taking a (double,char[]) because int is automatically
265  promoted to double.
266
267 <br><br>
268 <b>Returns:</b><br>
269 a slot key which can be used to disconnect the item
270  later.  (You can also use the original slot to disconnect if you
271  have it.)
272      
273 <br><br>
274
275 </dd>
276 </dl>
277 <script>explorer.outline.decSymbolLevel();</script>
278
279
280 </dd>
281
282 <script>explorer.outline.writeEnabled = true;</script>
283 <dt><span class="decl">alias
284 <span class="currsymbol">opCatAssign</span>
285 <script>explorer.outline.addDecl('opCatAssign');</script>
286
287 ;
288 </span></dt>
289 <script>explorer.outline.writeEnabled = false;</script>
290
291
292 <dd>Provides an alternate signal for connect() using the ~= operator.
293         This can allow for somewhat cleaner syntax when using delegate literals.
294         (One set of parentheses is eliminated)
295         For example:
296             theSignal ~= (Widget w, bool onoff) {
297                 writefln(onoff?"checked!":"unchecked!");};
298         Versus
299             theSignal.connect( (Widget w, bool onoff) {
300                 writefln(onoff?"checked!":"unchecked!");});
301         The downside is that it is not possible to specify template
302         arguments for ~= explicitly if needed.
303      
304 <br><br>
305
306 </dd>
307
308 <script>explorer.outline.writeEnabled = true;</script>
309 <dt><span class="decl">template
310 <span class="currsymbol">connect1st</span>
311 <script>explorer.outline.addDecl('connect1st');</script>
312
313 (DT)</span></dt>
314 <script>explorer.outline.writeEnabled = false;</script>
315
316
317 <dd>Some simple wrappers for the most comment skipped argument
318   versions of connect.  These work well with implicit instatiation.
319      
320 <br><br>
321
322
323 <script>explorer.outline.incSymbolLevel();</script>
324 <dl>
325 <script>explorer.outline.writeEnabled = true;</script>
326 <dt><span class="decl">slot_key
327 <span class="currsymbol">connect1st</span>
328 <script>explorer.outline.addDecl('connect1st');</script>
329
330 (DT <span class="funcparam">f</span>);
331 </span></dt>
332 <script>explorer.outline.writeEnabled = false;</script>
333
334
335 <dd>Some simple wrappers for the most comment skipped argument
336   versions of connect.  These work well with implicit instatiation.
337      
338 <br><br>
339
340 </dd>
341 </dl>
342 <script>explorer.outline.decSymbolLevel();</script>
343
344
345 </dd>
346
347 <script>explorer.outline.writeEnabled = true;</script>
348 <dt><span class="decl">template
349 <span class="currsymbol">disconnect</span>
350 <script>explorer.outline.addDecl('disconnect');</script>
351
352 (DT)</span></dt>
353 <script>explorer.outline.writeEnabled = false;</script>
354
355
356 <dd>Disconnect a slot of any type
357 <br><br>
358
359
360 <script>explorer.outline.incSymbolLevel();</script>
361 <dl>
362 <script>explorer.outline.writeEnabled = true;</script>
363 <dt><span class="decl">void
364 <span class="currsymbol">disconnect</span>
365 <script>explorer.outline.addDecl('disconnect');</script>
366
367 (DT <span class="funcparam">f</span>);
368 </span></dt>
369 <script>explorer.outline.writeEnabled = false;</script>
370
371
372 <dd>Disconnect a slot of any type
373 <br><br>
374
375 </dd>
376 </dl>
377 <script>explorer.outline.decSymbolLevel();</script>
378
379
380 </dd>
381 </dl>
382 <script>explorer.outline.decSymbolLevel();</script>
383
384
385 </dd>
386
387 <script>explorer.outline.writeEnabled = true;</script>
388 <dt><span class="decl">template
389 <span class="currsymbol">SlotAdapter</span>
390 <script>explorer.outline.addDecl('SlotAdapter');</script>
391
392 (slot_t)</span></dt>
393 <script>explorer.outline.writeEnabled = false;</script>
394
395
396 <dd>
397 <span class="currsymbol">SlotAdapter</span>
398 <script>explorer.outline.addDecl('SlotAdapter');</script>
399
400  is a template that takes a signal's 'slot_t' delegate type.
401  It contains two functions, wrap() and adapt().
402 <br><br>
403 wrap() returns a slot_t delegate to object that wraps a passed in
404  delegate or function which may have a signature that differs from
405  'slot_t'.  As long as the callable entity passed in has argument
406  types compatible with 'slot_t' then the operation should succeed.  In
407  particular exact matching with slot_t's parameter types is not
408  necessary, any type implicitly convertable from the slot_t's argument
409  type is ok.
410 <br><br>
411
412  adapt() is the same as wrap(), except it will return the original
413  delegate without creating a wrapper if that delegate's matches the
414  slot_t exactly.
415
416 <br><br>
417 <b>Usage:</b><br>
418 auto wrapped =
419 <span class="currsymbol">SlotAdapter</span>
420 <script>explorer.outline.addDecl('SlotAdapter');</script>
421
422 !(Signals_SlotType).wrap(target_slot)
423    auto adapted =
424 <span class="currsymbol">SlotAdapter</span>
425 <script>explorer.outline.addDecl('SlotAdapter');</script>
426
427 !(Signals_SlotType).adapt(target_slot)
428 <br><br>
429
430
431 <script>explorer.outline.incSymbolLevel();</script>
432 <dl></dl>
433 <script>explorer.outline.decSymbolLevel();</script>
434
435
436 </dd>
437 </dl>
438 <script>explorer.outline.decSymbolLevel();</script>
439
440
441 </td></tr>
442         <tr><td id="docfooter">
443             Page was generated with
444             <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px">
445             on Wed Dec  6 09:51:44 2006
446
447         </td></tr>
448     </table>
449 </div>
450 <script>
451     explorer.packageExplorer.addModule("luigi.base");
452     explorer.packageExplorer.addModule("luigi.arranger");
453     explorer.packageExplorer.addModule("luigi.adapter");
454     explorer.packageExplorer.addModule("luigi.adapters.gld");
455     explorer.packageExplorer.addModule("luigi.adapters.glfw");
456     explorer.packageExplorer.addModule("luigi.event");
457     explorer.packageExplorer.addModule("luigi.font");
458     explorer.packageExplorer.addModule("luigi.gldraw");
459     explorer.packageExplorer.addModule("luigi.gui");
460     explorer.packageExplorer.addModule("luigi.theme");
461     explorer.packageExplorer.addModule("luigi.themes.std");
462     explorer.packageExplorer.addModule("luigi.themes.dxut");
463     explorer.packageExplorer.addModule("luigi.opengl");
464     explorer.packageExplorer.addModule("luigi.signalobj");
465     explorer.packageExplorer.addModule("wrapres");</script>
466 </body></html>
Note: See TracBrowser for help on using the browser.