|
Boost Users : |
From: Andreas Huber (ahd6974-spamboostorgtrap_at_[hidden])
Date: 2007-04-07 13:52:12
Hi JD
[snip rest of code]
> struct MyMachine : sc::state_machine< MyMachine, Whatever >
> {
> void unconsumed_event( const sc::event_base & evt )
> {
> // How can I display a message here with the event name?
> }
> };
There are two options to do this:
1) Use C++ RTTI, i.e. type_info::name(). This is the easiest option as
it necessitates the least amount of work but of course requires that you
compile your program with C++ RTTI enabled.
2) Use event_base::custom_static_type_ptr
and event_base::custom_dynamic_type_ptr
as demonstrated for states in
<http://www.boost-consulting.com/boost/libs/statechart/doc/tutorial.html#StateTypeInformation>.
This requires slightly more work than 1) but works even if you compile
your program with C++ RTTI disabled.
> So the objective is to display the event name returned by the 'name'
> function when an event is unconsumed. I have tried some way like using
> dynamic_type and static_type but no luck...
See above, that should solve the event name problem quite nicely.
HTH,
-- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net