How i can call my method in upgrade() because it apears the error ' Error must use '.' or '->' to call pointer-to-member function'.
I want to have an Machine State, now i have the state monitor but i have a problem inside the upgrade() method.
template <class T>
class StateMonitor {
private:
static const int MAXSTATES;
static const int MAXLISTENERS;
int internalState;
int previousState;
void* (T::*func_table[MAXSTATES_DEF][MAXSTATES_DEF])(int stFrom, int stTo);
void* (T::*func_states[MAXSTATES_DEF])();
public:
StateMonitor();
int addAction(int currentstate, void* (T::*handle)());
void upgrade();
};
template <class T> void StateMonitor<T>::upgrade() {
T::func_states[internalState]();
}
template <class T> void StateMonitor<T>::addAction(int currentstate, void (T::*handle)()) {
func_states[currentstate] = handle;
}
In a son class i call the method father, for example:
class Machine:public StateMonitor<Machine> {
private:
enum States {STATE_0=0,STATE_0=1};
public:
void* AccioSTATE_0(){/*some code to execute in current state*/};
void SetupGrafo(){
addAction(STATE_0, AccioSTATE_0);
}
};
In the main loop, i want to create two objects of Machine class that have the same secuence:
Machine MachineA ;
void loop() {
MachineA.upgrade(); //i want to execute the AccioSTATE_0
}