Closed hanhao44 closed 4 years ago
You can get the current state in the cur_state variable inside the model. This points to the current state. Note, if you are using parallel states, multiple states can be active, so in this case, cur_state will contain a list of states.
get_state is used to get a pointer to a specific state.
There is also an 'In' method, which can be used to test if the current state is in a specific state.
Here is a modified hello_world.cpp examples, which accesses the current state
template<> void sc::state_actions<sc::state_hello>::enter(sc::data_model &m)
{
cout << "hello" << endl;
cout << "cur_state: " << typeid(*m.cur_state).name() << endl;
}
template<> void sc::state_actions<sc::state_world>::enter(sc::data_model &m)
{
cout << "world" << endl;
}
int main(int argc, char *argv[])
{
sc sc;
sc.init();
return 0;
}
Could you give me a example about get_state,this function has a "public" in class sc, how can i use it to get the current state,thanks