The problem I'm trying to solve is that I will have several device classes. For code re-usability I want to have a base class that has a few private methods.
// sends a command to a serial device and sends each received byte from the output to _processIncomingByte
void _processCommand(const char * commandName, const int longestLine, int linesToRead);
// this takes each received byte and constructs character arrays to be processed. The method to process the
// character array is determined by the mapping of the commandName
void _processIncomingByte(const byte c, char * buffer, const char * commandName, const int lineLength);
So each class that extends the base class will have a different set of commands to run and methods to process those commands. Once class could have:
struct {
const char *name;
void (*func)(char *);
} function_map [] = {
{ "status", processStatusLine },
{ "update", processUpdateLine },
};
and another class could have:
struct {
const char *name;
void (*func)(char *);
} function_map [] = {
{ "config", processConfigLine },
{ "reset", processRestLine },
};
Each process function should also be private to each class. I hope that makes sense.
