Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc. http://www.blynk.cc/
Dependents: Blynk_RBL_BLE_Nano Blynk_MicroBit Blynk_Serial Blynk_RBL_BLE_Nano
Diff: Blynk/BlynkTemplates.h
- Revision:
- 3:31e4b850b126
- Child:
- 9:7369ec77a3ea
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Blynk/BlynkTemplates.h Fri Jun 24 01:10:02 2016 +0300 @@ -0,0 +1,43 @@ +class BlynkStackOnly +{ +protected: + BlynkStackOnly() {} + ~BlynkStackOnly() {} +private: + void* operator new(size_t size); + void operator delete(void *p); +}; + +class BlynkNonCopyable +{ +protected: + BlynkNonCopyable(){} + ~BlynkNonCopyable(){} + +private: + /// @brief Declared as private to prevent usage of copy constructor + BlynkNonCopyable(const BlynkNonCopyable&); + /// @brief Declared as private to prevent usage of assignment operator + BlynkNonCopyable& operator=(const BlynkNonCopyable&); +}; + +template<typename T> +class BlynkSingleton: public BlynkNonCopyable +{ +public: + /** @brief Returns the instance of the singleton type + When called for the first time, the singleton instance will be + created. All subsequent calls will return a reference to the + previously created instance. + @return The singleton instance + */ + static T* instance() + { + static T instance; + return &instance; + } +protected: + BlynkSingleton() {} + ~BlynkSingleton() {} +}; +