That's interesting. What this does is to move the knowledge that "State1 transitions to State2 in response to EvWhatever" into a separate binary from the one where State1 is implemented. This does seem to address the basic problem. What would happen if we wanted this to scale to more states, so that e.g. there's a State3 that we transition to in response to EvAnother? And so on with more states and events, where we'd like each of State3, State4, etc. to be implemented in their own dll. It would seem that we'd have to build up a hierarchy where we have one inheritance level for each state. This could get cumbersome, but it would probably work.<br> <br>In any case, for our application, we may not actually require all this. We may be able to accomplish what we need by splitting out the functionality into independent state machines, rather than independent states within a single state machine. We'll need to analyze the kinds of coordination that would have to happen between machines, but at this point I believe we could use this approach.<br> <br>Thanks very much for your help. I have another (I hope simpler) question, which I'll put in a separate message.<br><br>Bill<br><br><br><div class="gmail_quote">On Mon, Jul 13, 2009 at 2:54 AM, Andreas Huber <span dir="ltr"><<a href="mailto:ahd6974-spamboostorgtrap@yahoo.com" target="_blank">ahd6974-spamboostorgtrap@yahoo.com</a>></span> wrote:<br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> So taking the TuTest code as an starting point, here's what I would like<br> to<br> be able to do:<br> <br> - Put TuTest.cpp and TuTest.hpp in a dll, TuTest.dll, called by the main<br> program. Keep the initial transition in the cpp file, as in the test code.<br> - Make the Initial state react to EvX by transitioning to a new state,<br> call<br> it MyState, defined in MyState.dll. MyState, in turn, would have its own<br> internal transitions and states, which it hides from clients by putting<br> them<br> in its own cpp files.<br> </blockquote> <br></div> Ok.<div><br> <br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> In your reply you had said that the state dll, MyState.dll in this case,<br> won't have a link-time dependency on the state machine; it need only<br> include<br> its header. This would be true if the state machine were implemented<br> entirely in the header. However, the header won't be enough if its initial<br> transition is hidden in a cpp file; the state would need to link with the<br> state machine.<br> </blockquote> <br></div> Right, my bad. After some reflection, it seems that your assessment is correct. You simply cannot push only some states of a state machine into dlls without introducing a circular dependency between binaries. However, it seems you can circumvent this relatively easily, as follows (UNTESTED):<br> <br> *** MyStatechartBase.hpp (included from cpps compiled into both dlls) ***<br> <br> // Depending on your platform, types/functions in this header might need<br> // to be properly exported/imported<br> <br> // ...<br> <br> struct EvWhatever : sc::event< EvWhatever > {};<br> <br> struct State1;<br> struct MyStatechartBase : sc::state_machine< MyStatechartBase, State1 ><br> {<br> �virtual sc::result react( State1 & state1, const EvWhatever & ev ) = 0;<br> };<br> <br> struct State1 : sc::simple_state< State1, MyStatechartBase ><br> {<br> �typedef sc::custom_reaction< EvWhatever > reactions;<br> <br> �sc::result react( const EvWhatever & ev )<br> �{<br> � return outermost_context().react( this, ev );<br> �}<br> };<br> <br> *** MyStatechartBase.cpp (compiled into MyStatechartBase.dll) ***<br> <br> #include "MyStatechartBase.hpp"<br> // ...<br> <br> *** MyStatechart.cpp (compiled into MyStatechart.dll) ***<br> <br> // This might have to be split into hpp/cpp<br> <br> #include "MyStatechartBase.hpp"<br> // ...<br> <br> struct State2 : sc::simple_state< State2, MyStatechartBase > {};<br> <br> struct MyStatechart : MyStatechartBase<br> {<br> �virtual sc::result react( State1 & state1, const EvWhatever & ev )<br> �{<br> � return state1.transit< State2 >();<br> �}<br> };<br> <br> Of course, this has two (IMO minor) problems:<br> 1) You cannot hide State1, it must be publicly visible<br> 2) You have to subclass the state machine<br> <br> It seems this should do pretty much what you want? If not, please let me know.<br> <br> Regards,<div><div></div><div><br> <br> -- <br> Andreas Huber<br> <br> When replying by private email, please remove the words spam and trap<br> from the address shown in the header. <br> <br> _______________________________________________<br> Boost-users mailing list<br> <a href="mailto:Boost-users@lists.boost.org" target="_blank">Boost-users@lists.boost.org</a><br> <a href="http://lists.boost.org/mailman/listinfo.cgi/boost-users" target="_blank">http://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br> </div></div></blockquote></div><br><br clear="all"><br><br>