-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Why not registering the keypad as part of the constructor?
I see the following advantages:
- The semantic necessity (the engine needs the keypad to operate) would be represented technically.
The user of the engine can not forget to register the keypad. IKeypad &myKeypadcould then be a member ofGuiEnginewhich is initialized by the member initializer list ofGuiEngine(). Declaring the functionskeypad_read_*()as members ofGuiEnginewould eliminate the need to check for NULL pointer in those functions. Also because a reference would be used instead of a pointer. Using member functions as callback would require to define a private static member function, which would act as relay and use the callback argument to call the actual member as for exampleor (requires to definereinterpret_cast<GuiEngine *>(indev_drv->disp->driver->user_data)->keypad_read_enter(...)indev_drv->user_data)reinterpret_cast<GuiEngine *>(indev_drv->user_data)->keypad_read_enter(...)
GuiEngine(const Configuration &configuration, TwoWire &i2c, IKeypad &keypad);
Did we already talk about it? I have a vague memory 🤔
Originally posted by @dhebbeker in #123 (comment)
Metadata
Metadata
Assignees
Labels
No labels