#include <iostream>
#include <boost/bind.hpp>
#include <boost/signal.hpp>
namespace jc
{
class task
{
public:
task()
{
// ...
}
~task()
{
// ...
}
void done()
{
sig_finished(this);
}
/// signals
boost::signal<void (task *)> sig_finished;
};
class bucket
{
public:
bucket()
{
// ...
}
~bucket()
{
// ...
}
void on_finished(task * t)
{
std::cout << "on_finished:\n";
}
void set_task(task * t)
{
t->sig_finished.connect(boost::bind(
&bucket::on_finished, this, t));
}
};
} // namepace jc
using namespace jc;
int main()
{
task * t = new task;
bucket * b = new bucket;
b->set_task(t);
t->done();
delete t;
delete b;
return 0;
}