I'm using signals2. I'm trying to setup a viewstate/view relationship with a view having a subscribed slot. I can't seem to trigger the handler function though. Is there something wrong with the binding? I'm new to c++ so maybe there's a misuse of const/reference/dereferencer.
In My State Machine:
void State::setAppState( State::AppState pNewState )
{
mCurrentState = pNewState;
// this prints fine
ci::app::console() <<"\nState::setState " << pNewState << "\n";
(*mSignal)();
}
In my view base class:
BaseView::BaseView( State& pState ): mState(pState)
{
// register connection to state
mConnection = mState.connect(boost::bind(&BaseView::stateChange, this));
}
// the use of const is right from their example in the doc.
// but i found i had to const_cast to get it to compile
// can i get rid of the 'this' and do it without const method?
// edit: no (boost compile errors)
void BaseView::stateChange() const
{
int s = const_cast<State&>(mState).getAppState();
// this does not print
ci::app::console() << "\n>>>>> View Slot registered change " << s << "\n" ;
}
In my view subclass:
AttractView::AttractView(State pState):BaseView(pState)
{
// to pass the constructor param
}
Main App:
mAttract = AttractView( mStateMachine );
mStateMachine.setAppState(State::AppState::Attract); //AppState is just an enum