SolderedElectronics / Inkplate-Arduino-library

Inkplate family Arduino library. The easiest way to add e-paper to your project.
https://inkplate.readthedocs.io/en/latest/arduino.html
GNU Lesser General Public License v3.0
251 stars 78 forks source link

Replace extern definitions by Singleton pattern #216

Closed tost11 closed 1 year ago

tost11 commented 1 year ago

use something like that:

ifndef SRC_CORE_SINGLETONHPP

define SRC_CORE_SINGLETONHPP

template class Singleton { public: static T& get();

protected:
    Singleton() {}

private:
    Singleton(const Singleton&);
};

template <class T>
T& Singleton<T>::get()
{
    static T instanz;
    return instanz;
}

}

rsoric commented 1 year ago

Hi @tost11

Out of all the issues you opened today, this one we might implement sometime but I can't guarantee it, it all depends on the best course of action we decide as a team.

I'll close the issue for now as there are some plans for a revision to the Inkplate library and I'm sure this design pattern will be thrown into the discussion, but it all has to go through the team. Thanks for your input!