Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Chapter 16. Boost.Signals

Douglas Gregor

Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Table of Contents

Introduction
Tutorial
How to Read this Tutorial
Compatibility Note
Hello, World! (Beginner)
Calling multiple slots
Passing values to and from slots
Connection Management
Example: Document-View
Linking against the Signals library
Reference
Header <boost/signal.hpp>
Header <boost/signals/slot.hpp>
Header <boost/signals/trackable.hpp>
Header <boost/signals/connection.hpp>
Header <boost/visit_each.hpp>
Header <boost/last_value.hpp>
Design Overview
Type Erasure
connection class
Slot Call Iterator
visit_each function template
Design Rationale
Choice of Slot Definitions
User-level Connection Management
Combiner Interface
Connection Interfaces: += operator
trackable rationale
Comparison with other Signal/Slot implementations
Testsuite
Acceptance tests

Ŀ¼

ܼ/a>
팳̼/a>
ȧꎔĶq㌼/a>
捍賊儗⊍
Hello, World! 㨳弶㩼/a>
巔oึ⥲ۼ/a>
䫖嵽⥲ۼ໘䫼/a>
l퓹܀a>
=ד㺎ĵ靡Ӎ켯a>
t퓐źſ⼯a>
⎿켯a>
ͷ΄쾠<boost/signal.hpp>
ͷ΄쾠<boost/signals/slot.hpp>
ͷ΄쾠<boost/signals/trackable.hpp>
ͷ΄쾠<boost/signals/connection.hpp>
ͷ΄쾠<boost/visit_each.hpp>
ͷ΄쾠<boost/last_value.hpp>
ɨ솸ŀ
Ѝɾ㽼/a>
connection
⥲۵瓃弴ꆷ
visit_each ꯊ턣ॼ/a>
ɨ솔퀭
⥲۶蒥儑ᔱ
Ӄ맲퓹܀a>
ꏲ↷퓿ڼ/a>
l퓵Ľӿڣ꫽ ԋˣ綜/a>
trackable 儔퀭
ӫƤ˻Ѕꅯ⥲ۊ取儱Ƚϼ/a>
⢊Ԍ׼a>
ѩʕ⢊Լ/a>

Introduction

The Boost.Signals library is an implementation of a managed signals and slots system. Signals represent callbacks with multiple targets, and are also called publishers or events in similar systems. Signals are connected to some set of slots, which are callback receivers (also called event targets or subscribers), which are called when the signal is "emitted."

Boost.Signals ǒ븶صĐźŲ島㨳ignals and slots㩏即儊取ᣍ Ѕꅴ걭KึĿ᪵Ļص磬 Ԛ ˆ粲即֐Ҳㆎ귢⼕ߣ譫blisher㩻⊂쾣襶ent㩡㍊ Ѕꅓ넳ש⥲ۏl퓣첥⛼付卮ĽӊՕߍ 㨒ⳆΪʂ쾄ﱪ㬥vent target㬻ⶩԄ՟㬳ubscriber㩣썊˼CԚЅꅡ෢㶡኱ỵ瓃ᣍ

Signals and slots are managed, in that signals and slots (or, more properly, objects that occur as part of the slots) track all connections and are capable of automatically disconnecting signal/slot connections when either is destroyed. This enables the user to make signal/slot connections without expending a great effort to manage the lifetimes of those connections with regard to the lifetimes of all objects involved.

ЅꅺͲ島ʇصģ쒲ΪЅꅺͲ島㨻⑏豵؋劇׷Ϊ⥲۳揖攜ԏ㣩 躗ً銬俊콓㬲ℜ黔ڐźŻⲥ⛏껙ʱה毿Ͽꐅꅯ⥲۵ā콓ᣍ բȃʹӃ՟Ĝ黔ڽ聢Ѕꅯ⥲ہ콓傻슱㬍 ⻱ط浘蹲ݏ๘攏㵄ɺuƚȥ需턇l퓵ĉꃼƚᣍ

When signals are connected to multiple slots, there is a question regarding the relationship between the return values of the slots and the return value of the signals. Boost.Signals allows the user to specify the manner in which multiple return values are combined.

屐źŁ콓核瀝⛊ᣬ 闠ڲ島儷廘ֵꍐźŵķ廘ֵ֮줵Ĺ؏匡趎ʌ⡣ Boost.Signals ԊӃ맖趨ꏲⶠ趷廘ֵ儷튽ᣍ

Last revised: May 04, 2004 at 14:17:23 -0400

筒룺켯a>

ҫ΄輐£결08.7.10


PrevUpHomeNext