Hi Philippe
I have a method in which I want to post/process an event. The thing is, this method can be called from outside the state machine (so I need to call process_event), or indirectly by a reaction of the state machine (in this case I must call post_event since process_event is not reentrant).
I don't want to write 2 distinct methods to do this (one that calls post, and the other process), I would much rather prefer adding a 'if' in my method that tells me if I have to call process_event or post_event (if I'm being called indirectly by the state machine or not). Is there a way to do this with statechart ?
No, not currently. How about implementing two functions and having them delegate to the same implementation: class MyMachine : ... { public: void DoX() { DoXImpl(false); } void DoXPost() { DoXImpl(true); } private: void DoXImpl(bool post) { ... if (post) { ... } else { ... } ... } }; Yes, it is slightly more work than if there was a state_machine::is_processing() function. I'm just not sure whether your use case is sufficiently common to justify adding such a function. Maybe you could provide more details so that I understand it better? Thanks & Regards, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.