Yes, that example shows how you can put different states in different translation units. In that case, though, the cyclic dependency is worked around by using forward references. This works because everything is in a single component, so the linker can see everything at once. If you link the states separately, though, there's no order that can work: Since MyStatechart.dll requires State2.dll (really its export lib) in order to link, State2 has to be built before MyStatechart. But since State2.dll requires MyStatechart.dll (really its export lib) in order to link, MyStatechart has to be built before State2.

We can work around this by using static libs throughout, but that is much less desirable for our architecture. That's why I'm wondering whether I'm missing some technique for breaking the cyclic dependency at link time.


On Fri, Jul 10, 2009 at 12:43 PM, Commander Pirx <CmdPirx@hotmail.de> wrote:
 
"Bill Clark" <bill@philomellsoftware.com> schrieb im Newsbeitrag news:179b0d0d0907090954v5713336j2a6577f4c354fcde@mail.gmail.com...
Is there any way to partition a state machine using boost::statechart such that the main state machine is in one dll, and its substates (and possibly their substates) are in separate dll's?

It would seem that this would create a cyclic dependency. Suppose you have e.g. a simple statechart called MyStatechart containing an initial state State1 which transitions to State2 in response to some event. Is it possible to implement MyStatechart and State1 in MyStatechart.dll, and State2 in State2.dll?

Since the code for State1 will need to reference State2 (in order to transition to it), MyStatechart.dll will have a dependency on State2.dll. But since State2 is contained in MyStatechart, its type will have to look something like

struct State2: sc::state<State2, MyStatechart>
{
   //...
};

which means that State2.dll will have a dependency on MyStatechart.dll.

Is it possible to avoid this cycle?

Thanks for any help,
Bill
 
 
 
There is a topic in the statechart tutorial http://www.boost.org/doc/libs/1_39_0/libs/statechart/doc/tutorial.html#SpreadingAStateMachineOverMultipleTranslationUnits
 Which covers a similiar topic. Perhaps you can modify your architecture and work with nested state machines.
 
Pirx
 

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users