macros.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef _FY_MACRO_H_
  2. #define _FY_MACRO_H_
  3. #include <stddef.h>
  4. #define DISALLOW_COPY_AND_ASSIGN(classname) \
  5. private: \
  6. classname(const classname &); \
  7. classname &operator=(const classname &);
  8. #define DISALLOW_IMPLICIT_CONSTRUCTORS(classname) \
  9. private: \
  10. classname(); \
  11. DISALLOW_COPY_AND_ASSIGN(classname);
  12. #define DECLARE_SINGLETON(classname) \
  13. public: \
  14. static classname *instance() { \
  15. static classname singleton; \
  16. return &singleton; \
  17. } \
  18. DISALLOW_IMPLICIT_CONSTRUCTORS(classname) \
  19. private:
  20. #define DECLARE_INSTANCE(classname) \
  21. public: \
  22. static classname *instance() { \
  23. static classname singleton; \
  24. return &singleton; \
  25. } \
  26. private:
  27. #endif /* _FY_MACRO_H_ */