palacaze / sigslot

A simple C++14 signal-slots implementation
MIT License
709 stars 97 forks source link

signal_view proposition #36

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hello @palacaze

I was in need of a way to limit user access to the signal class and I've wrapped it in a class I named signal_view. Basically, it calls the signal's correspondent methods, but only some of them are available:

signal_view methods

By making sigslot::signal_view public, users can call the methods above, but only by the private sigslot::signal it can emit, block, disconnect_all, etc.

class Class
{
private:
    sigslot::signal<> _updated;

public:
    sigslot::signal_view<> updated{&_updated};
};

The wrapper is enough for me, but I bring it here as a proposition to maybe implement inside sigslot.

Thank you.