|
Boost Users : |
Subject: Re: [Boost-users] [msm] Injecting events to FSMs from different translation units
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2013-05-14 15:46:37
> 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.
Exact.
> 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).
It's just safer than a pointer, which I avoid giving as example ;-) and
easier to use than a scoped_ptr.
Juraj is right, all these ways are correct. Only plain values or references
would not help you as they'd force all the template instantiations into
every TU including your header.
Furthermore, it's considered bad style to give access to the internals of
your fsm, populate instead PublicClass with public members processing events
in the .cpp file.
Thanks,
Christophe
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net