Ejemplo n.º 1
0
	virtual ~Context(){
		cout << "~Context()" << endl;

		// On cleanup: Remove yourself from all Events
		Dispatcher* dsp = Dispatcher::getInstance();
		dsp->remListeners(this, TRANSITION1);
		dsp->remListeners(this, TRANSITION2);
		dsp->remListeners(this, TRANSITION3);

		// Delete Inner Object too!
		if(state_ != NULL){
			delete state_;
			state_ = NULL;
		}
	}
Ejemplo n.º 2
0
void S2::Transition1(void){
	cout << "S2 --T1--> S1" << endl;

	// Stop listen to Event Transmission1 and Event Transmission2
	Dispatcher* dsp = Dispatcher::getInstance();
	dsp->remListeners( this->con_, TRANSITION1);
	dsp->remListeners( this->con_, TRANSITION2);

	// Move to State S1.
	new (this) S1(this->con_);
}