How should important data be passed around a program?

Started by
10 comments, last by Khatharr 6 years, 11 months ago

The idea of the state stack - if you're not familiar - is that the state base class contains a pointer to a state, which is nullptr by default. If the pointer is null then nothing special happens. Otherwise the state logic and drawing delegate to the sub-state indicated there.

I'm familiar with the state stack. However, I'm not using it for my StateMachine in this program. Although this state stack is a little different then what I'm used to. Are you saying that a State would look something like this?


template <typename T>
class State
{
private:
    State<T>* sub_state;

public:
    State() : sub_state{nullptr} {}
    State(State<T>* sub) : sub_state{sub} {}

    void update()=0;
    //...
}
Advertisement

Just a linked list, really. (And please use std::unique_ptr.) The simplest form would be to only process the state at the "tail" of the list, but the structure - as mentioned - allows for elective processing/drawing of the enclosing states.

I'm not sure why you'd have a constructor that takes an existing state object and assigns it to the sub-state.

Why is your state class templated?

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

This topic is closed to new replies.

Advertisement