From: E. Gladyshev (eegg_at_[hidden])
Date: 2004-03-08 22:46:21


----- Original Message -----
From: "Douglas Gregor" <gregod_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, March 08, 2004 6:42 AM
Subject: Re: [boost] enumeration interface for boost::signals

[...]

> As for the capturing, you can use groups:
>
> const int capture = -100000; // big negative number
> {
> boost::signals::scoped_connected captured =
> sig.connect(capture, slot_to_capture);
> // slot_to_capture always executes first, so it gets all the events.
> } // end of scope, slot_to_capture disappears

Good idea!
However I don't want to require the slot
itself to be aware whether it
is capturing or not.

I guess I can try something like this:

struct server
{
  typedef boost::signals::signal< void (event), until_true > signals;

  signals sig_;

  struct capture_wrapper
  {
     signals::slot_type s_;

     capture_wrapper( slot s ) : s_(s) {}

     bool operator()( event e )
     {
        //how do I make the call?
        s_(e); //is it ok?
        return true; //stop propagation
     }
  }
  
  void capture( typename signals::slot_type s )
  {
     capture_ = sig.connect( capture, capture_wrapper(s) );
  }

  void remove_capture()
  {
    capture_.disconnect();
  }

  boost::signals::scoped_connected capture_;
};

>
> If slots had a well-defined order, everything would be peachy.
>

Yep.

As for the ordering, I think the
SIGNALS_GROUP_TOP/SIGNALS_GROUP_BOTTOM flags should work just fine.
We definitely need this feature.

I also need an efficient way for accessing slots randomly.
For instance some of the Win32 listbox messages
have item indexes. I'd like to implement each
item as a slot, but I need a way to access
the slots based on the item index, so I could call
just the right slot.
listboxes can contain a lot of items so propagating
the messages to all items is not an option.

Eugene