N
nilavya
HI,
I have got a C++ application involving State machine.
Now I have got too many states and too many events which changes the
state of the Staet machine. So my code is somewhat unmanageable. It is
:
switch(nState)
{
case state1:
{
switch(nEvent)
{
case event1:
break;
case event2:
break;
case event3:
default:
break;
}
}
break;
case state2:
break;
default:
break;
}
Now the problem I have is that some of the handling in various
states-events combo is almost same. That makes my code redundant.Also
the function size is toooo large.
Is there any way or design to write this code. I heard about writing a
seperate function for each state. But not sure???
Can Anyone help me in this....
Thanks.
With Regards,
Bhagat Nirav K.
I have got a C++ application involving State machine.
Now I have got too many states and too many events which changes the
state of the Staet machine. So my code is somewhat unmanageable. It is
:
switch(nState)
{
case state1:
{
switch(nEvent)
{
case event1:
break;
case event2:
break;
case event3:
default:
break;
}
}
break;
case state2:
break;
default:
break;
}
Now the problem I have is that some of the handling in various
states-events combo is almost same. That makes my code redundant.Also
the function size is toooo large.
Is there any way or design to write this code. I heard about writing a
seperate function for each state. But not sure???
Can Anyone help me in this....
Thanks.
With Regards,
Bhagat Nirav K.