| 1 | /* |
| 2 | * LegacyClonk |
| 3 | * |
| 4 | * Copyright (c) 2017-2020, The LegacyClonk Team and contributors |
| 5 | * |
| 6 | * Distributed under the terms of the ISC license; see accompanying file |
| 7 | * "COPYING" for details. |
| 8 | * |
| 9 | * "Clonk" is a registered trademark of Matthes Bender, used with permission. |
| 10 | * See accompanying file "TRADEMARK" for details. |
| 11 | * |
| 12 | * To redistribute this file separately, substitute the full license texts |
| 13 | * for the above references. |
| 14 | */ |
| 15 | |
| 16 | // RAII wrapper class for SDL_InitSubSystem/SDL_QuitSubSystem. |
| 17 | |
| 18 | #pragma once |
| 19 | |
| 20 | #include <SDL.h> |
| 21 | |
| 22 | #include <utility> |
| 23 | |
| 24 | class StdSdlSubSystem |
| 25 | { |
| 26 | public: |
| 27 | StdSdlSubSystem(Uint32 flags); |
| 28 | StdSdlSubSystem(const StdSdlSubSystem &) = delete; |
| 29 | StdSdlSubSystem(StdSdlSubSystem &&o) noexcept : flags{std::exchange(obj&: o.flags, new_val: 0)} {} |
| 30 | ~StdSdlSubSystem() { SDL_QuitSubSystem(flags); } |
| 31 | StdSdlSubSystem &operator=(const StdSdlSubSystem &) = delete; |
| 32 | |
| 33 | private: |
| 34 | Uint32 flags; |
| 35 | }; |
| 36 | |