sigslot,一个开源的c++signal slot库

sigslot is a head only signal slot lib,written by Sarah Thompson.

 

原始仓库是 http://sourceforge.net/projects/sigslot/

文档是 http://sigslot.sourceforge.net/sigslot.pdf

a Patched version of Sarah Thompson‘s sigslot implementation. Works with VS 2013 on Windows 7 using C++11.
 
使用方式很简单,include头文件siglslot.h, 所有类在sigslot namespace中。
 
#include <iostream>
#include "sigslot.h"
using namespace std;
using namespace sigslot;

class window
{
public:
    signal0<> _lclicksig;
    signal1<int> _paintsig;
};

class foo : public has_slots<>
{
public:
    void lbuttondown()
    {
        cout<<"left button clicked"<<endl;
    }
    void paint(int i)
    {
        cout<<"i = "<<i<<endl;
    }
};

int main()
{
    window w;
    foo f;
    w._lclicksig.connect(&f, &foo::lbuttondown);
    w._paintsig.connect(&f, &foo::paint);
    w._lclicksig();
    w._paintsig(100);

    return 0;
}

 

sigslot,一个开源的c++signal slot库,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。