I have an object that has an array of pointers to functions as config value like this:
class Object{
public:
bool (*function[2])() = {};
};
bool fooFunc(){return true;}
bool barFunc(){return false;}
Object obj;
void setupObject(){
obj.function[0] = &fooFunc;
obj.function[1] = &barFunc;
}
I am on a µC on would like to store the used functions in EEPROM, so that the object can resume with the same config when the program is restarted. Is there a way to write functions specify the address to which a function is written to?
Alternatively, I could make an array of pointers with all functions that are allowed (couple dozens) and only save the function ID, but I don't know how to do that efficiently and with maintainable code. Would using lambda functions here save me some space? Also, that would mean that my functions are always loaded, wouldn't it?