[signals] making Assignable and CopyConstructable

In my program I need to store a map of signals, with an integer id corresponding to a signal in the map. Objects can request to be informed when another a specific message is emitted by connecting a member function to the signal in this map at the index corresponding to that message type. However, since boost::signal inherits noncopyable, it cannot be stored in a map. What are the reasons for signal being noncopyable, and is there any chance this could be changed in the future?

On Tue, 26 Jul 2005 21:45:06 +0100, Rebooted <rebooted@gmail.com> wrote:
In my program I need to store a map of signals, with an integer id corresponding to a signal in the map.
Objects can request to be informed when another a specific message is emitted by connecting a member function to the signal in this map at the index corresponding to that message type.
However, since boost::signal inherits noncopyable, it cannot be stored in a map. What are the reasons for signal being noncopyable, and is there any chance this could be changed in the future?
Is there any reason you can't let the signals be owned by some other object(s), and just store pointers to the signals in the map? -- Be seeing you.

On Tuesday 26 July 2005 22:45, Rebooted wrote:
In my program I need to store a map of signals, with an integer id corresponding to a signal in the map.
Some kind of map<id_type, signal_type>.
Objects can request to be informed when another a specific message is emitted by connecting a member function to the signal in this map at the index corresponding to that message type.
IOW, objects can subscribe to events.
However, since boost::signal inherits noncopyable, it cannot be stored in a map. What are the reasons for signal being noncopyable, and is there any chance this could be changed in the future?
(I'm walking on unknown grounds here, since I use libsigC++ instead, but last time I looked, they were sufficiently similar - maybe some names are different.) The problem is that when you connect a slot to a signal, you get a reference to that connection. Using that reference, you can also separate the connection again. Now, what would happen when a signal was copyable? You could end up with several connections, so which one would you disconnect? Also, copying is not a trivial operation, so you'd rather avoid it. Ideas: Use Boost's function instead, which is copyable. Using bind, you can achieve almost the same as with slots/signals. The exception is the automatic disconnecting when the target object is destroyed, but that can also be achieved by using weak_ptr and a wrapper function (maybe lambda would eliminate even that). Store a smart pointer instead of the signal itself. This would even speed up operations on the map. Uli

Ulrich Eckhardt <uli <at> doommachine.dyndns.org> writes:
On Tuesday 26 July 2005 22:45, Rebooted wrote:
In my program I need to store a map of signals, with an integer id corresponding to a signal in the map.
Some kind of map<id_type, signal_type>.
Store a smart pointer instead of the signal itself. This would even speed up operations on the map.
Or do boost::ptr_map<id_type,signal_type> map; -Thorsten
participants (4)
-
Rebooted
-
Thore Karlsen
-
Thorsten Ottosen
-
Ulrich Eckhardt