initializer.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef SIMPLE_SDLCORE_INITIALIZER_H
  2. #define SIMPLE_SDLCORE_INITIALIZER_H
  3. #include <SDL2/SDL.h>
  4. #include "simple/support/enum_flags_operators.hpp"
  5. namespace simple::sdlcore
  6. {
  7. enum class system_flag : uint32_t
  8. {
  9. nothing = 0,
  10. video = SDL_INIT_VIDEO,
  11. audio = SDL_INIT_AUDIO,
  12. event = SDL_INIT_EVENTS,
  13. haptic = SDL_INIT_HAPTIC,
  14. joystick = SDL_INIT_JOYSTICK,
  15. game_controller = SDL_INIT_GAMECONTROLLER,
  16. everything = SDL_INIT_EVERYTHING,
  17. };
  18. using ::operator|;
  19. using ::operator&;
  20. using ::operator^;
  21. using ::operator&&;
  22. // NOTE: wanted to use unique_ptr here, but couldn't find an easy way
  23. class initializer
  24. {
  25. public:
  26. static bool exists(system_flag) noexcept;
  27. initializer(system_flag = system_flag::everything);
  28. virtual ~initializer() noexcept;
  29. initializer(const initializer& other) = delete;
  30. initializer & operator=(const initializer& other) = delete;
  31. initializer(initializer&& other) noexcept;
  32. initializer & operator=(initializer&& other) noexcept;
  33. private:
  34. system_flag system;
  35. };
  36. } // namespace simple::sdlcore
  37. namespace simple::support
  38. {
  39. template <>
  40. struct define_enum_flags_operators<simple::sdlcore::system_flag> : public std::true_type {};
  41. } // namespace simple::support
  42. #endif /* end of include guard */