examples.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
  3. "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
  4. <!--
  5. Copyright Douglas Gregor 2001-2004
  6. Copyright Frank Mori Hess 2007-2009
  7. Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. -->
  10. <section last-revision="$Date: 2007-06-12 14:01:23 -0400 (Tue, 12 Jun 2007) $" id="signals2.examples">
  11. <title>Example programs</title>
  12. <using-namespace name="boost::signals2"/>
  13. <using-namespace name="boost"/>
  14. <section id="signals2.examples.misc">
  15. <title>Miscellaneous Tutorial Examples</title>
  16. <section id="signals2.examples.tutorial.hello_world_slot">
  17. <title>hello_world_slot</title>
  18. <para>
  19. This example is a basic example of connecting a slot to a signal
  20. and then invoking the signal.
  21. </para>
  22. <para>
  23. Download <ulink url="boost:/libs/signals2/example/hello_world_slot.cpp">hello_world_slot.cpp</ulink>.
  24. </para>
  25. </section>
  26. <section id="signals2.examples.tutorial.hello_world_multi_slot">
  27. <title>hello_world_multi_slot</title>
  28. <para>
  29. This example extends the hello_world_slot example slightly by connecting more than one
  30. slot to the signal before invoking it.
  31. </para>
  32. <para>
  33. Download <ulink url="boost:/libs/signals2/example/hello_world_multi_slot.cpp">hello_world_multi_slot.cpp</ulink>.
  34. </para>
  35. </section>
  36. <section id="signals2.examples.tutorial.ordering_slots">
  37. <title>ordering_slots</title>
  38. <para>
  39. This example extends the hello_world_multi_slot example slightly by
  40. using slot groups to specify
  41. the order slots should be invoked.
  42. </para>
  43. <para>
  44. Download <ulink url="boost:/libs/signals2/example/ordering_slots.cpp">ordering_slots.cpp</ulink>.
  45. </para>
  46. </section>
  47. <section id="signals2.examples.tutorial.slot_arguments">
  48. <title>slot_arguments</title>
  49. <para>
  50. The slot_arguments program shows how to pass arguments from a signal invocation to slots.
  51. </para>
  52. <para>
  53. Download <ulink url="boost:/libs/signals2/example/slot_arguments.cpp">slot_arguments.cpp</ulink>.
  54. </para>
  55. </section>
  56. <section id="signals2.examples.tutorial.signal_return_value">
  57. <title>signal_return_value</title>
  58. <para>
  59. This example shows how to return a value from slots to the signal invocation.
  60. It uses the default <classname>optional_last_value</classname> combiner.
  61. </para>
  62. <para>
  63. Download <ulink url="boost:/libs/signals2/example/signal_return_value.cpp">signal_return_value.cpp</ulink>.
  64. </para>
  65. </section>
  66. <section id="signals2.examples.tutorial.custom_combiners">
  67. <title>custom_combiners</title>
  68. <para>
  69. This example shows more returning of values from slots to the signal invocation.
  70. This time, custom combiners are defined and used.
  71. </para>
  72. <para>
  73. Download <ulink url="boost:/libs/signals2/example/custom_combiners.cpp">custom_combiners.cpp</ulink>.
  74. </para>
  75. </section>
  76. <section id="signals2.examples.tutorial.disconnect_and_block">
  77. <title>disconnect_and_block</title>
  78. <para>
  79. This example demonstrates various means of manually disconnecting slots, as well as temporarily
  80. blocking them via <classname>shared_connection_block</classname>.
  81. </para>
  82. <para>
  83. Download <ulink url="boost:/libs/signals2/example/disconnect_and_block.cpp">disconnect_and_block.cpp</ulink>.
  84. </para>
  85. </section>
  86. <section id="signals2.examples.tutorial.passing_slots">
  87. <title>passing_slots</title>
  88. <para>
  89. This example demonstrates the passing of slot functions to a private signal
  90. through a non-template interface.
  91. </para>
  92. <para>
  93. Download <ulink url="boost:/libs/signals2/example/passing_slots.cpp">passing_slots.cpp</ulink>.
  94. </para>
  95. </section>
  96. <section id="signals2.examples.tutorial.extended_slot">
  97. <title>extended_slot</title>
  98. <para>
  99. This example demonstrates connecting an extended slot to a signal. An extended slot
  100. accepts a reference to its invoking signal-slot connection as an additional argument,
  101. permitting the slot to temporarily block or permanently disconnect itself.
  102. </para>
  103. <para>
  104. Download <ulink url="boost:/libs/signals2/example/extended_slot.cpp">extended_slot.cpp</ulink>.
  105. </para>
  106. </section>
  107. </section>
  108. <section id="signals2.examples.document-view">
  109. <title>Document-View</title>
  110. <section id="signals2.examples.document-view.doc_view">
  111. <title>doc_view</title>
  112. <para>
  113. This is the document-view example program which is described in the
  114. <link linkend="signals2.tutorial.document-view">tutorial</link>. It shows
  115. usage of a signal and slots to implement two different views of
  116. a text document.
  117. </para>
  118. <para>
  119. Download <ulink url="boost:/libs/signals2/example/doc_view.cpp">doc_view.cpp</ulink>.
  120. </para>
  121. </section>
  122. <section id="signals2.examples.document-view.doc_view_acm">
  123. <title>doc_view_acm</title>
  124. <para>
  125. This program modifies the original doc_view.cpp example to employ
  126. automatic connection management.
  127. </para>
  128. <para>
  129. Download <ulink url="boost:/libs/signals2/example/doc_view_acm.cpp">doc_view_acm.cpp</ulink>.
  130. </para>
  131. </section>
  132. <section id="signals2.examples.document-view.doc_view_acm_deconstruct">
  133. <title>doc_view_acm_deconstruct</title>
  134. <para>
  135. This program modifies the doc_view_acm.cpp example to use postconstructors
  136. and the <functionname>deconstruct()</functionname> factory function.
  137. </para>
  138. <para>
  139. Download <ulink url="boost:/libs/signals2/example/doc_view_acm_deconstruct.cpp">doc_view_acm_deconstruct.cpp</ulink>.
  140. </para>
  141. </section>
  142. </section>
  143. <section id="signals2.examples.deconstruct">
  144. <title>Postconstructors and Predestructors with <code>deconstruct()</code></title>
  145. <section id="signals2.examples.deconstruct.postconstructor_ex1">
  146. <title>postconstructor_ex1</title>
  147. <para>
  148. This program is a basic example of how to define a class with a postconstructor which
  149. uses <functionname>deconstruct()</functionname> as its factory function.
  150. </para>
  151. <para>
  152. Download <ulink url="boost:/libs/signals2/example/postconstructor_ex1.cpp">postconstructor_ex1</ulink>.
  153. </para>
  154. </section>
  155. <section id="signals2.examples.deconstruct.postconstructor_ex2">
  156. <title>postconstructor_ex2</title>
  157. <para>
  158. This program extends the postconstructor_ex1 example slightly, by additionally passing arguments from
  159. the <functionname>deconstruct()</functionname> call through to the class' constructor
  160. and postconstructor.
  161. </para>
  162. <para>
  163. Download <ulink url="boost:/libs/signals2/example/postconstructor_ex2.cpp">postconstructor_ex2</ulink>.
  164. </para>
  165. </section>
  166. <section id="signals2.examples.deconstruct.predestructor_example">
  167. <title>predestructor_example</title>
  168. <para>
  169. This program is a basic example of how to define a class with a predestructor which
  170. uses <functionname>deconstruct()</functionname> as its factory function.
  171. </para>
  172. <para>
  173. Download <ulink url="boost:/libs/signals2/example/predestructor_example.cpp">predestructor_example</ulink>.
  174. </para>
  175. </section>
  176. </section>
  177. </section>