
On 8/10/09 12:48 AM, Andreas Huber wrote:
The machine is effectively a timer and wraps another internal timer class that can be stopped/started and suspended/resumed. This is all the machine does. The internal timer class can get/set its interval and can also get/set a delegate, that is called (if set) when the timer fires. These internal timer management interfaces are "passed through" to the state machine interface, such that application/test code is as follows:
[snip code]
Where I have run into a problem is that my machine "pass through" setter methods allowing the delegate to be set or the timer interval to be changed (neither of which materially alter the state of the machine) cannot be called as they are non-const qualified whereas their corresponding getters work fine since they are const qualified.
So both the values of the delegate and the interval are orthogonal to the state the machine has? If so, I'm wondering why they're not members of struct Timer? This would make ITimerManagement unnecessary and also save quite a bit of code?
Andreas:
Making the internal timer a member of the state_machine was precisely my
initial implementation; however, initially, I'd found a destruction ordering
problem with that approach. Basically, on destruction of the running state,
I ensure the timer is stopped:
struct Running :
Interfaces::IRunning,
Interfaces::ISuspended,
state
What is the purpose of the IRunning & ISuspended structs?
They are application-level pseudo-state queries. Thanks for the tips! Regards, Grant