Re: [sigc] How to do selective signal propagation ?



Eric NICOLAS wrote:
> What I need is to filter signal propagation based on a signal's argument. I
> have a signal <void, double value, int kind>. Clients connects to this
> signal saying "I want to receive updates on value of kind 'mykind'".. Now a
> value of kind 'akind' changes, only those clients connected who wants
> values of 'akind' should be notified.

Hmmm, I'm not a master of the libsigc code, but I think that one could solve 
this dilemma. 

template<int filter, class Value>
void adapter( int id, Value val)
{
  if(id==filter)
     real_function(id,value);
}

You might also get away with using only Value as template parameter and then 
using bind() to set the filter-value. This has the additional advantage that 
you would be able to change filter at runtime.

More complex ideas also take the real_function() as parameter and so on. 

Uli




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]