Imported Upstream version 2.99.2
[platform/upstream/libsigc++.git] / docs / reference / html / classsigc_1_1signal.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
6 <meta name="generator" content="Doxygen 1.8.9.1"/>
7 <title>libsigc++: sigc::signal&lt; T_return, T_arg &gt; Class Template Reference</title>
8 <link href="tabs.css" rel="stylesheet" type="text/css"/>
9 <script type="text/javascript" src="jquery.js"></script>
10 <script type="text/javascript" src="dynsections.js"></script>
11 <link href="doxygen.css" rel="stylesheet" type="text/css" />
12 <link href="doxygen-extra.css" rel="stylesheet" type="text/css"/>
13 </head>
14 <body>
15 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
16 <div id="titlearea">
17 <table cellspacing="0" cellpadding="0">
18  <tbody>
19  <tr style="height: 56px;">
20   <td style="padding-left: 0.5em;">
21    <div id="projectname">libsigc++
22    &#160;<span id="projectnumber">2.99.2</span>
23    </div>
24   </td>
25  </tr>
26  </tbody>
27 </table>
28 </div>
29 <!-- end header part -->
30 <!-- Generated by Doxygen 1.8.9.1 -->
31   <div id="navrow1" class="tabs">
32     <ul class="tablist">
33       <li><a href="index.html"><span>Main&#160;Page</span></a></li>
34       <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
35       <li><a href="modules.html"><span>Modules</span></a></li>
36       <li><a href="namespaces.html"><span>Namespaces</span></a></li>
37       <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
38     </ul>
39   </div>
40   <div id="navrow2" class="tabs2">
41     <ul class="tablist">
42       <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
43       <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
44       <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
45       <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
46     </ul>
47   </div>
48 <div id="nav-path" class="navpath">
49   <ul>
50 <li class="navelem"><a class="el" href="namespacesigc.html">sigc</a></li><li class="navelem"><a class="el" href="classsigc_1_1signal.html">signal</a></li>  </ul>
51 </div>
52 </div><!-- top -->
53 <div class="header">
54   <div class="headertitle">
55 <div class="title">sigc::signal&lt; T_return, T_arg &gt; Class Template Reference<div class="ingroups"><a class="el" href="group__signal.html">Signals</a></div></div>  </div>
56 </div><!--header-->
57 <div class="contents">
58
59 <p>signal can be used to connect() slots that are invoked during subsequent calls to emit().  
60  <a href="classsigc_1_1signal.html#details">More...</a></p>
61
62 <p><code>#include &lt;sigc++/signal.h&gt;</code></p>
63 <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
64 <div class="textblock"><h3>template&lt;class T_return, class... T_arg&gt;<br />
65 class sigc::signal&lt; T_return, T_arg &gt;</h3>
66
67 <p>signal can be used to connect() slots that are invoked during subsequent calls to emit(). </p>
68 <p>Any functor or slot can be passed into connect(). It is converted into a slot implicitly.</p>
69 <p>If you want to connect one signal to another, use make_slot() to retrieve a functor that emits the signal when invoked.</p>
70 <p>Be careful if you directly pass one signal into the connect() method of another: a shallow copy of the signal is made and the signal's slots are not disconnected until both the signal and its clone are destroyed, which is probably not what you want!</p>
71 <p>An STL-style list interface for the signal's list of slots can be retrieved with slots(). This interface supports iteration, insertion and removal of slots.</p>
72 <p>The template arguments determine the function signature of the emit() function:</p><ul>
73 <li><em>T_return</em> The desired return type of the emit() function. * - <em>T_arg</em> Argument types used in the definition of emit().</li>
74 </ul>
75 <p>For instance, to declare a signal whose connected slot returns void and takes two parameters of bool and int: </p><div class="fragment"><div class="line"><a class="code" href="classsigc_1_1signal.html">sigc::signal&lt;void(bool, int)&gt;</a> some_signal;</div>
76 </div><!-- fragment --><p>To specify an accumulator type the nested class signal::accumulated can be used.</p>
77 <dl class="section user"><dt>Example:</dt><dd><div class="fragment"><div class="line"><span class="keywordtype">void</span> foo(<span class="keywordtype">int</span>) {}</div>
78 <div class="line"><a class="code" href="classsigc_1_1signal.html">sigc::signal&lt;void, long&gt;</a> sig;</div>
79 <div class="line">sig.connect(<a class="code" href="group__ptr__fun.html#ga203dd1ac5747cf2f3d2b2d590ad32e82">sigc::ptr_fun</a>(&amp;foo));</div>
80 <div class="line">sig.emit(19);</div>
81 </div><!-- fragment --> </dd></dl>
82 </div></div><!-- contents -->
83 <!-- start footer part -->
84 <hr class="footer"/><address class="footer"><small>
85 Generated on Wed Mar 16 2016 20:53:28 for libsigc++ by &#160;<a href="http://www.doxygen.org/index.html">
86 <img class="footer" src="doxygen.png" alt="doxygen"/>
87 </a> 1.8.9.1
88 </small></address>
89 </body>
90 </html>