You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
758 B
32 lines
758 B
//
|
|
// CounterCtrl.h
|
|
//
|
|
// implements the Finite State Machine (FSM) of an up/down-Counter
|
|
//
|
|
// (C) R. Bonderer, HSR Hochschule Rapperswil, Oct. 2017
|
|
//
|
|
|
|
#ifndef COUNTERCTRL_H__
|
|
#define COUNTERCTRL_H__
|
|
#include "Counter.h"
|
|
|
|
class CounterState; // forward declaration
|
|
|
|
class CounterCtrl
|
|
// this is the 'Context' class of the State pattern
|
|
{
|
|
public:
|
|
enum Event{evUp, // count upwards
|
|
evDown, // count downwards
|
|
evCount, // count (up or down)
|
|
evStop}; // stop counting
|
|
CounterCtrl(int initValue = 0);
|
|
void process(Event e);
|
|
// changes the state of the FSM based on the event 'e'
|
|
|
|
private:
|
|
Counter entity;
|
|
CounterState* pState; // holds the current state
|
|
};
|
|
#endif
|