| 1 | <html> |
|---|
| 2 | <head> |
|---|
| 3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
|---|
| 4 | <title>Frequently Asked Questions</title> |
|---|
| 5 | <link rel="stylesheet" href="../boostbook.css" type="text/css"> |
|---|
| 6 | <meta name="generator" content="DocBook XSL Stylesheets V1.69.1"> |
|---|
| 7 | <link rel="start" href="../index.html" title="The Boost C++ Libraries"> |
|---|
| 8 | <link rel="up" href="../signals.html" title="Chapter 9. Boost.Signals"> |
|---|
| 9 | <link rel="prev" href="../id2591657-bb.html" title="Class last_value<void>"> |
|---|
| 10 | <link rel="next" href="s05.html" title="Design Overview"> |
|---|
| 11 | </head> |
|---|
| 12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
|---|
| 13 | <table cellpadding="2" width="100%"> |
|---|
| 14 | <td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../boost.png"></td> |
|---|
| 15 | <td align="center"><a href="../../../index.htm">Home</a></td> |
|---|
| 16 | <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> |
|---|
| 17 | <td align="center"><a href="../../../people/people.htm">People</a></td> |
|---|
| 18 | <td align="center"><a href="../../../more/faq.htm">FAQ</a></td> |
|---|
| 19 | <td align="center"><a href="../../../more/index.htm">More</a></td> |
|---|
| 20 | </table> |
|---|
| 21 | <hr> |
|---|
| 22 | <div class="spirit-nav"> |
|---|
| 23 | <a accesskey="p" href="../id2591657-bb.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../signals.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="s05.html"><img src="../images/next.png" alt="Next"></a> |
|---|
| 24 | </div> |
|---|
| 25 | <div class="section" lang="en"> |
|---|
| 26 | <div class="titlepage"><div><div><h3 class="title"> |
|---|
| 27 | <a name="id2738844"></a>Frequently Asked Questions</h3></div></div></div> |
|---|
| 28 | <div class="qandaset"> |
|---|
| 29 | <dl> |
|---|
| 30 | <dt>1. <a href="s04.html#id2738852">Don't noncopyable signal semantics mean that a class |
|---|
| 31 | with a signal member will be noncopyable as well?</a> |
|---|
| 32 | </dt> |
|---|
| 33 | <dt>2. <a href="s04.html#id2738867">Is Boost.Signals thread-safe?</a> |
|---|
| 34 | </dt> |
|---|
| 35 | <dt>3. <a href="s04.html#id2738878">How do I get Boost.Signals to work with Qt?</a> |
|---|
| 36 | </dt> |
|---|
| 37 | </dl> |
|---|
| 38 | <table border="0" summary="Q and A Set"> |
|---|
| 39 | <col align="left" width="1%"> |
|---|
| 40 | <tbody> |
|---|
| 41 | <tr class="question"> |
|---|
| 42 | <td align="left" valign="top"> |
|---|
| 43 | <a name="id2738852"></a><a name="id2738853"></a><b>1.</b> |
|---|
| 44 | </td> |
|---|
| 45 | <td align="left" valign="top"><p>Don't noncopyable signal semantics mean that a class |
|---|
| 46 | with a signal member will be noncopyable as well?</p></td> |
|---|
| 47 | </tr> |
|---|
| 48 | <tr class="answer"> |
|---|
| 49 | <td align="left" valign="top"><b></b></td> |
|---|
| 50 | <td align="left" valign="top"><p>No. The compiler will not be able to generate a copy |
|---|
| 51 | constructor or copy assignment operator for your class if it |
|---|
| 52 | has a signal as a member, but you are free to write your own |
|---|
| 53 | copy constructor and/or copy assignment operator. Just don't |
|---|
| 54 | try to copy the signal.</p></td> |
|---|
| 55 | </tr> |
|---|
| 56 | <tr class="question"> |
|---|
| 57 | <td align="left" valign="top"> |
|---|
| 58 | <a name="id2738867"></a><a name="id2738868"></a><b>2.</b> |
|---|
| 59 | </td> |
|---|
| 60 | <td align="left" valign="top"><p>Is Boost.Signals thread-safe?</p></td> |
|---|
| 61 | </tr> |
|---|
| 62 | <tr class="answer"> |
|---|
| 63 | <td align="left" valign="top"><b></b></td> |
|---|
| 64 | <td align="left" valign="top"><p>No. Using Boost.Signals in a multithreaded concept is |
|---|
| 65 | very dangerous, and it is very likely that the results will be |
|---|
| 66 | less than satisfying. Boost.Signals will support thread safety |
|---|
| 67 | in the future.</p></td> |
|---|
| 68 | </tr> |
|---|
| 69 | <tr class="question"> |
|---|
| 70 | <td align="left" valign="top"> |
|---|
| 71 | <a name="id2738878"></a><a name="id2738880"></a><b>3.</b> |
|---|
| 72 | </td> |
|---|
| 73 | <td align="left" valign="top"><p>How do I get Boost.Signals to work with Qt?</p></td> |
|---|
| 74 | </tr> |
|---|
| 75 | <tr class="answer"> |
|---|
| 76 | <td align="left" valign="top"><b></b></td> |
|---|
| 77 | <td align="left" valign="top"> |
|---|
| 78 | <p>When building with Qt, the Moc keywords |
|---|
| 79 | <code class="computeroutput">signals</code> and <code class="computeroutput">slots</code> are defined using |
|---|
| 80 | preprocessor macros, causing programs using Boost.Signals and |
|---|
| 81 | Qt together to fail to compile. Although this is a problem |
|---|
| 82 | with Qt and not Boost.Signals, a user can use the two systems |
|---|
| 83 | together with a little extra effort. There are two ways to do |
|---|
| 84 | this:</p> |
|---|
| 85 | <p>The first way involves defining |
|---|
| 86 | the <code class="computeroutput">BOOST_SIGNALS_NAMESPACE</code> |
|---|
| 87 | macro to some other identifier (e.g., <code class="computeroutput">signalslib</code>) |
|---|
| 88 | when building and using the Boost.Signals library. Then the |
|---|
| 89 | namespace of the Boost.Signals library will be |
|---|
| 90 | <code class="computeroutput">boost::BOOST_SIGNALS_NAMESPACE</code> instead of |
|---|
| 91 | <code class="computeroutput">boost::signals</code>. To retain the original namespace |
|---|
| 92 | name in translation units that do not interact with Qt, you |
|---|
| 93 | can use a namespace alias:</p> |
|---|
| 94 | <pre class="programlisting"> |
|---|
| 95 | namespace boost { |
|---|
| 96 | namespace signals = BOOST_SIGNALS_NAMESPACE; |
|---|
| 97 | } |
|---|
| 98 | </pre> |
|---|
| 99 | <p>The second way, provided by Frank Hess, involves |
|---|
| 100 | creating a header <code class="computeroutput">signalslib.hpp</code> that contains |
|---|
| 101 | the following code:</p> |
|---|
| 102 | <pre class="programlisting">#ifdef signals |
|---|
| 103 | #error "signalslib.hpp must be included before any qt header" |
|---|
| 104 | #endif |
|---|
| 105 | |
|---|
| 106 | #include <boost/signal.hpp> |
|---|
| 107 | namespace boost |
|---|
| 108 | { |
|---|
| 109 | namespace signalslib = signals; |
|---|
| 110 | }</pre> |
|---|
| 111 | <p>This header must be included before any Qt headers. Once |
|---|
| 112 | it has been included, you can refer to the Signals library via |
|---|
| 113 | the namespace <code class="computeroutput">boost::signalslib</code>. This option is |
|---|
| 114 | preferable to the first option because it can be used without |
|---|
| 115 | recompiling the Signals library binary. </p> |
|---|
| 116 | </td> |
|---|
| 117 | </tr> |
|---|
| 118 | </tbody> |
|---|
| 119 | </table> |
|---|
| 120 | </div> |
|---|
| 121 | </div> |
|---|
| 122 | <table width="100%"><tr> |
|---|
| 123 | <td align="left"><small><p>Last revised: September 23, 2005 at 11:45:10 GMT</p></small></td> |
|---|
| 124 | <td align="right"><small>Copyright © 2001-2004 Douglas Gregor</small></td> |
|---|
| 125 | </tr></table> |
|---|
| 126 | <hr> |
|---|
| 127 | <div class="spirit-nav"> |
|---|
| 128 | <a accesskey="p" href="../id2591657-bb.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../signals.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="s05.html"><img src="../images/next.png" alt="Next"></a> |
|---|
| 129 | </div> |
|---|
| 130 | </body> |
|---|
| 131 | </html> |
|---|