
On 13.5.2013. 23:27, samriti katoch wrote:
Hi,
I am using boost msm to design state machines for a relatively large project.
The documentation online is pretty good and I was able to figure out most features by looking at the sample code (thanks!).
My particular application has multiple FSM instances active at any given time, and what I would like to do is to be able to generate events for a particular FSM instance from different translation units. But I'd like to keep the the compile time at a minimum.
I found an answer from Christophe for a similar question sometime back here: http://stackoverflow.com/questions/10899641/boost-msm-class
Since, I have multiple FSM instances it would not help to have a singleton class with the FSM shared_ptr.
There is no singleton in the proposed solution. The proposed solution merely hides MSM guts from public headers to reduce compile time (pimpl idiom). Nothing is stopping you from creating multiple instances of PublicClass. I think shared_ptr is causing the confusion - it is merely an implementation detail, data it points to is not intended to be shared between different PublicClass objects. You could also have use a plain pointer (but then you need to consider copy semantics), or scoped_ptr (which would make this class non-copyable).