I'm very new to C++ so I'm curious if this is possible. I'm building a little module to control some lights of mine. I have an enum called "ControllerTypes". It holds three types "CONTROLLER_FASTLED", "CONTROLLER_ADAFRUIT_NEOPIXEL", "CONTROLLER_CALLBACK".
I have a class "CMagicLight" which has a static member "setup" with a template, like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
typedef enum {
CONTROLLER_FASTLED,
CONTROLLER_ADAFRUIT_NEOPIXEL,
CONTROLLER_CALLBACK,
} ControllerType;
class CMagicLight
{
public:
CMagicLight();
static CLightController &setup();
template<ControllerType cT> CLightController &setup() {
return setup();
}
};
|
Currently setup has no arguments but that is what my question is. Depending on what the user choses the controller type to be is it possible to get the arguments of setup to change? For example:
If the user selects: CONTROLLER_FASTLED, "setup" should accept either:
- pin
- numLeds
- type
- leds
OR
- (arguments of type) CLEDController
If the user selects: CONTROLLER_ADAFRUIT_NEOPIXEL, "setup" should accept either:
- pin
- numLeds
- type
OR
- (arguments of type) Adafruit_Neopixel
and so on for the callback and others in the future.
Thanks, Dream.