I am building a Boost state machine. My state has a pointer to its own backend (fsm
) to process events. All events of my state machine are children of an MySatetMachineEvent
class (with an example child like EventChild
). State transitions are only defined for children like EventChild
of MySTateMachineEvent
.
To clean up my code I want to create a function processEvent(MySatetMachineEvent event)
taking all possible events. This class should then call the process_event()
function with the passed event.
For example:
processEvent(MyStateMachineEvent event)
{
fsm.process_event(event);
}
processEvent(EventCild());
should case a call of
fsm.process_event(EventChild());
Creating such a function causes the error that fsm.process_event()
is called with an instance of MyStateMachineEvent
. As written above there are no state transitions defined for this case.
This hinders my state machine from working in a proper manner, obviously.
So my question is if there is a way to pass any EventChild
or other child of MyStateMachineEvent
to my processEvent(MySTateMachineEvent event)
function without casting the passed Object to MyStateMachineEvent
.
I am aware of the solution to overlode my function like
processEvent(EventChild event) {
fsm.process_event(event);
}
This would cause may functions (with the exact same line of code inside) in my case, thus i am looking for a cleaner and more fancy solution.