|
Boost Users : |
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2007-02-23 17:52:00
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 23 February 2007 17:26 pm, Timmo Stange wrote:
> You can look at random_signal_system.cpp for a real example, but it's
> quite simple: A class can provide a predefined function class and
> an overload for visit_each. The connecting code creates an instance
> of that class to connect to the signal and doesn't need to care about
> tracking, because it is set up by the slot and visit_each.
>
> struct some_observer
> {
> signals::tracked ptr_to_some_secret_object;
> some_observer(); // Sets up ptr_to_some_secret_object
> void operator()(); // Uses ptr_to_some_secret_object
> };
>
> ...
>
> signal0<void> sig;
> sig.connect(some_observer());
>
> The advantage is that the party establishing the connection does
> not need to know what objects have to be tracked. It's not such a
> big asset, but it's something you cannot do with the explicit
> track().
Ah, I see. Couldn't you achieve the same thing by deriving some_observer
from the slot class? Then the some_observer constructor could call
slot::track() to set up its own tracking.
- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFF33AR5vihyNWuA4URAuBEAKDZHKwRKBdIW/xsBTkt8SHrphb+JwCgjQWk
Hxs/2P3ulFzNPnl/PVdTZR0=
=K/GW
-----END PGP SIGNATURE-----
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net