"Andreas Huber" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > After posting I realized that the current interface already allows you to > hide states. E.g. you often want to ensure that a machine is initiated > during construction: > > *StopWatch.hpp*: > > struct Active; // the only visible forward > struct StopWatch : fsm::state_machine< StopWatch, Active > > { > StopWatch(); > }; > > *StopWatch.cpp*: > > struct Stopped; > struct Active : fsm::simple_state< Active, StopWatch, > fsm::transition< EvReset, Active >, Stopped > {}; > struct Running : fsm::simple_state< Running, Active, > fsm::transition< EvStartStop, Stopped > > {}; > struct Stopped : fsm::simple_state< Stopped, Active, > fsm::transition< EvStartStop, Running > > {}; > > StopWatch::StopWatch() > { > initiate(); > } > > The trick is to place the initiate(); call in a location where all states > are known. > > So, clients see only one forward declaration of the initial state while all > the other states are hidden in the .cpp file. However, this approach still > exposes the whole state_machine interface to the clients (StopWatch *must* > derive publicly from state_machine), which is often not what you want. In > real-world code you'd probably more often have the state_machine subclass as > a data member, maybe even more hidden with a pimpl. > > I therefore think that it is not necessary to change the current interface > for information hiding purposes. Granted, it's not perfect, but the > alternative I've outlined in my previous post isn't either, as Reece has > pointed out. I might support both interfaces if there are other use cases > that don't work with the current interface. > > Regards, > > Andreas
I vote for both interfaces. If feature is easy to implement and if it allows to avoid even forward state declaration than why not ? I think you are right and initial state template parameter will simpify code, but allowing default "InnerInitial = detail::empty_list" as you did it for state template will allow complete removing of initial state from interface. BTW what about run-time selection of initial states ? : StopWatch::StopWatch() { if( ... ) initiate<MyInitialState1>(); else { initiate<MyInitialState2>(); initiate<MyOrthohonalInitialState2>(); } } ... regards, bohdan _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost