|
Boost Users : |
From: Tim Crews (boost2_at_[hidden])
Date: 2008-08-06 12:55:10
Hello:
I posted last week about a project in which I am creating two instances
of the same state machine class, with the two instances running in
separate boost threads.
I have the threading issues resolved, but now I am having some other
trouble. The two instances of the state machine class are
differentiated by slightly different constructor parameter values, which
are then stored in some state machine member variables. The contained
states then access these member variables.
Unfortunately, at least for the initial state, the state constructor is
unable to access these member variables. (This may also be true of
states other than the initial state, but I haven't been able to get that
far yet.)
Here is some example code that demonstrates the problem:
################################################################
#include <iostream>
using namespace std;
#include <boost/statechart/state_machine.hpp>
#include <boost/statechart/simple_state.hpp>
using boost::statechart::state_machine;
using boost::statechart::simple_state;
struct TopState;
struct Machine : state_machine< Machine, TopState >
{
Machine (int u):
unique(u) {}
int unique;
};
struct TopState : simple_state< TopState, Machine >
{
TopState(void)
{
int z = outermost_context().unique;
cout << z << endl;
}
};
int main (int argc, char *argv[])
{
Machine machine1(1);
Machine machine2(2);
machine1.initiate();
}
################################################################
When I run this code, I get the following error message when machine1 is
initiated:
app: /usr/include/boost/statechart/simple_state.hpp:217: typename
Context::inner_context_type::outermost_context_type&
boost::statechart::simple_state<MostDerived, Context, InnerInitial,
historyMode>::outermost_context() [with MostDerived = TopState, Context
= Machine, InnerInitial = boost::mpl::list<mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na>, boost::statechart::history_mode
historyMode = has_no_history]: Assertion `get_pointer( pContext_ ) != 0'
failed.
It is as if the outermost context doesn't exist yet (or hasn't been
fully initialized yet?) when the initial state is entered.
Am I doing something wrong?
Thank you for your time,
Tim Crews
GECO, Inc.
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