Question

I'm trying to make a state machine DcuClientMachine, having two states - StandBy (the default one) and Operating. StandBy is just a simple state, while Operating is a nested one, having Parsing state as it's default. EvConnecting event supposes to StandBy -> Operating (Parsing)

#include <boost/statechart/event.hpp>
#include <boost/statechart/state_machine.hpp>
#include <boost/statechart/simple_state.hpp>
#include <boost/statechart/transition.hpp>
#include <boost/statechart/custom_reaction.hpp>

namespace sc = boost::statechart;

struct EvConnecting : sc::event<EvConnecting>{};

struct StandBy;
struct DcuClientMachine : sc::state_machine<DcuClientMachine, StandBy>{};

struct Operating;
struct Parsing;

struct StandBy : sc::simple_state<StandBy, DcuClientMachine >
{
    //typedef sc::transition<EvConnecting, Operating> reactions; //(*1)

    typedef sc::custom_reaction<EvConnecting> reactions; //(*2)
    sc::result react( const EvConnecting & )
    {
        return transit< Operating >();

        //return forward_event(  ); //(*3)
    }

};
struct Operating : sc::simple_state<Operating, DcuClientMachine, Parsing>{};
struct Parsing : sc::simple_state<Parsing, DcuClientMachine>{};

int main()
{
    return 0;
}

(*1) and (*2) produce boost\statechart\simple_state.hpp(887): error C2039: 'inner_initial_list' : is not a member of 'DcuClientMachine'

If i use (*3), then it's ok, the code is compiled.

What's wrong with this code?

Thank you.

Was it helpful?

Solution

Your definition of Parsing is wrong. It should be :

struct Parsing : sc::simple_state<Parsing, Operating>{};

since Parsing is a sub-state of Operating.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top