`

sigslot for c++

阅读更多

#include "stdafx.h"
//http://sigslot.sourceforge.net/
//#include "..\sigslot\sigslot.h"
#include "libjingle\libjingle-0.4.0\talk\base\sigslot.h"
//使用从sourceforge下载的sigslot.h编译不过,使用libjingle中修改过的sigslot.h可以

class Receiver : public sigslot::has_slots<>{
public:
	Receiver(std::string s){
		msg = s;
	}

	void Ondone(int a, std::string s){
		printf("\n%s: %s", msg.c_str(), s.c_str());
	}
private:
	std::string msg;
};


int main(int argc, char* argv[])
{
	Receiver r1("111");
	Receiver r2("2222");

	sigslot::signal2<int, std::string> signal1;

	signal1.connect(&r1, &Receiver::Ondone);
	signal1.connect(&r2, &Receiver::Ondone);

	//signal1.emit(1, "hello");
	signal1(1, "hello");

	return 0;
}





还有一个
http://libsigc.sourceforge.net/
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics