#include <jem/base/System.h>
#include <jem/util/Event.h>
void printValue ( int i )
{
}
class Listener :
public Object
{
public:
Listener ();
void printValue
( double f );
void printHello ();
protected:
virtual ~Listener ();
};
Listener::Listener ()
{}
Listener::~Listener ()
{}
void Listener::printValue ( double f )
{
}
void Listener::printHello ()
{
}
class Signaller :
public Object
{
public:
Signaller ();
void setAndDecr
( int i );
void destroy ();
static
protected:
virtual ~Signaller ();
private:
int value_;
};
Signaller::Signaller () : value_ ( 0 )
{}
Signaller::~Signaller ()
{
print ( System::out(),
"Bye Bye ...\n" );
}
void Signaller::setAndDecr ( int i )
{
int oldValue = value_;
value_ = (--i);
if ( value_ <= 0 )
{
zeroReached.emit ();
}
else
{
newValue.emit ( value_, oldValue );
}
}
void Signaller::destroy ()
{
}
int run()
{
Signaller::instance = newInstance<Signaller> ();
{
connect ( s->zeroReached, listener, & Listener::printHello );
connect ( s->zeroReached, s, & Signaller::destroy );
connect ( s->newValue, s, & Signaller::setAndDecr );
connect ( s->newValue, listener, & Listener::printValue );
connect ( s->newValue, & printValue );
}
Signaller::instance->setAndDecr ( 10 );
return 0;
}
int main ()
{
return System::exec ( & run );
}