开发者

How to prevent removal of slots from a certain signal?

Is it possible to block 开发者_如何学JAVAthe removal of certain slots from a signal in the boost.signals library?

If so how should a code that does such a thing will look like? Do I need to create a derived class just for that specific signal to do so?


Supply your own slot connection function that fails to return the connection. Without the connection the client can't break it.

Edit: code example:

struct my_class
{
  boost::signals::connection listen_event1(boost::function<void (my_class const&)> const& f)
  {
    return signal1.connect(f);
  }
  void listen_event2(boost::function<void my_class const&)> const& f)
  {
    signal2.connect(f);
  }

private:
  typedef boost::signals::signal<void(my_class const&)> sig_t;
  sig_t signal1;
  sig_t signal2;
};

signal2 connections cannot be disconnected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜