JSONSingleton.h 513 B

1234567891011121314151617181920212223
  1. #ifndef JSONSINGLETON_H
  2. #define JSONSINGLETON_H
  3. template <typename T> class JSONSingleton {
  4. public:
  5. static inline T get(void){
  6. return get_singleton() -> ptr;
  7. }
  8. static inline void set(T p){
  9. get_singleton() -> ptr = p;
  10. }
  11. private:
  12. inline JSONSingleton() : ptr(NULL) { }
  13. JSONSingleton(const JSONSingleton<T> &);
  14. JSONSingleton<T> operator = (const JSONSingleton<T> &);
  15. static inline JSONSingleton<T> * get_singleton(void){
  16. static JSONSingleton<T> instance;
  17. return &instance;
  18. }
  19. T ptr;
  20. };
  21. #endif