I have a class which needs more callbacks.. I am trying to implement them with an interface:
class CallbacksInterface
{
public:
virtual bool mycallback1() = 0;
virtual bool mycallback2() = 0;
virtual bool mycallback3() = 0;
};
Class BusImplementation{
public:
addRequest(bool (CallbacksInterface::*callback)());
}
Callback is parameter for addRequest() method and is defined as pointer to interface method. So I want to add request..
//class with callbacks
class Main:CallbacksInterface{
public:
bool mycallback1(){..};
bool mycallback2(){..};
bool mycallback3(){..};
//..
}
BusImplemantation bus;
Main main;
bus.addRequest(main.mycallback1);
bus.addRequest(main.mycallback2);
bus.addRequest(main.mycallback3);
But I cant pass a callback into my BusImplemantation class
error: argument of type 'bool (Main::)()' does not match 'bool (CallbacksInterface::*)()'
I think there is a solution with templates, but I am programming embedded devices and my compiler is limited.
std::functions
?class Main: public CallbacksInterface
?BusImplemantation
.