首页 > 代码库 > sigslot,一个开源的c++signal slot库
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.
https://github.com/arvidsson/sigslot
使用方式很简单,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;}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。