Boost logo

Boost Users :

Subject: [Boost-users] [StateChart] pass objectpointer to FSM?
From: Bernt-Johan Bergshaven (bbergshaven_at_[hidden])
Date: 2011-03-14 16:24:33


Hello,

first; thank you for an excellent library collection. I recently discovered
it, and I'm impressed!

My question:
How can I pass a pointer to an object into the state machine?

I want to use my state machine to control a real-life elevator. All the
functions for controlling this elevator is inside class Elevator;
I.e: myElevator->startEngine(UP);

I've tried different approaches as you might see in my attached code, but I
keep getting this error:
statemachine: ../boost/boost/cast.hpp:97: Target
boost::polymorphic_downcast(Source*) [with Target = ElevatorSM*, Source =
boost::statechart::state_machine<ElevatorSM, ElevatorActive>]: Assertion
`dynamic_cast<Target>(x) == x' failed.
Aborted

h-file: http://codepad.org/i3rAjT1p
cpp-file: http://codepad.org/TpaWluCz

Appreciate your help,
Bernt-Johan Bergshaven, Norway



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