首页 > 编程语言 > 详细

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

时间:2014-08-09 23:09:59      阅读:731      评论:0      收藏:0      [点我收藏+]

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库,布布扣,bubuko.com

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

原文:http://www.cnblogs.com/venid/p/3901716.html

(0)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!