Make Kaleidoscope_ a friend class, so that it can access .begin. The
reason behind this is that .begin is an interface towards
Kaleidoscope.use(), and that function should be the only user. To
discourage its use, make it protected.

This does not break any existing - and valid - code, but allows us to
slowly migrate the plugins to a protected begin() method.

Fixes #177.
pull/213/merge
Gergely Nagy 7 years ago committed by Jesse Vincent
parent b591c887cd
commit 8741c68f7b

@ -36,9 +36,28 @@ extern HARDWARE_IMPLEMENTATION KeyboardHardware;
const uint8_t KEYMAP_SIZE const uint8_t KEYMAP_SIZE
__attribute__((deprecated("Kaleidoscope.setup() does not require KEYMAP_SIZE anymore."))) = 0; __attribute__((deprecated("Kaleidoscope.setup() does not require KEYMAP_SIZE anymore."))) = 0;
class Kaleidoscope_;
class KaleidoscopePlugin { class KaleidoscopePlugin {
public: friend class Kaleidoscope_;
virtual void begin(void) = 0;
protected:
/** Initial plugin setup hook.
* All plugins are supposed to provide a singleton object, statically
* initialized at compile-time (with few exceptions). Because of this, the
* order in which they are instantiated is unspecified, and cannot be relied
* upon. For this reason, one's expected to explicitly initialize, "use" the
* plugins one wishes to, by calling `Kaleidoscope.use()` with a list of plugin
* object pointers.
*
* This function will in turn call the `begin` function of each plugin,
* so that they can perform any initial setup they wish, such as registering
* event handler or loop hooks. This is the only time this function will be
* called. It is intentionally protected, and accessible by the `Kaleidoscope`
* class only.
*/
virtual void begin(void) { };
}; };
class Kaleidoscope_ { class Kaleidoscope_ {

Loading…
Cancel
Save