[MSM] Get state name as string
Hello, For debugging purposes, I want to get the current state name as a string. For this purpose I found the class get_state_name in the tools section of the backend. Unfortunately there is no example on how to use this method in the documentation nor anywhere else; and the extensive use of templates makes it very difficult for me to infer this. I am especially confused about the argument boost::msm::wrap<StateType> const& of the call operator. What do I have to provide her? Could anybody please post a short example how to this? Kind regards, Stefan Wiehler
Hi Stefan,
Hello,
For debugging purposes, I want to get the current state name as a string. For this purpose I found the class get_state_name in the tools section of the backend.
Unfortunately there is no example on how to use this method in the documentation nor anywhere else; and the extensive use of templates makes it very difficult for me to infer this.
I am especially confused about the argument boost::msm::wrap<StateType> const& of the call operator. What do I have to provide her? Could anybody please post a short example how to this?
Kind regards,
Stefan Wiehler
It is documented
(http://svn.boost.org/svn/boost/trunk/libs/msm/doc/HTML/re02.html), but it's
clearly insufficient.
Please allow me to correct it (and add to the doc). Admittedly, as a
metaprogramming debugging tool it's a bit hard to read (it's ok if you don't
get, it just has to fill the string name_of_open). I just tried this unsing
VC10 and boost 1.52.
I suppose you already have your state id (for ex. using current_state()) and
it has id 1:
// we need a fsm's table
typedef player::stt Stt;
typedef msm::back::generate_state_set<Stt>::type all_states; //all states
std::string name_of_open; // id of Open is 1
// fill name_of_open for state of id 1
boost::mpl::for_each
participants (2)
-
Christophe Henry
-
Stefan Wiehler