From c6e6333f9ad7c9008ba211798af05888edf7126e Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Fri, 23 Oct 2020 13:55:57 +0200 Subject: [PATCH] added namespaces --- SDLImageWrapper.cpp | 2 ++ SDLImageWrapper.hpp | 22 +++++++++++++--------- SDLWrapper.cpp | 2 ++ SDLWrapper.hpp | 22 +++++++++++++--------- Window.cpp | 2 ++ Window.hpp | 30 +++++++++++++++++------------- 6 files changed, 49 insertions(+), 31 deletions(-) diff --git a/SDLImageWrapper.cpp b/SDLImageWrapper.cpp index 413c09d..cae9c75 100644 --- a/SDLImageWrapper.cpp +++ b/SDLImageWrapper.cpp @@ -10,6 +10,8 @@ #include #include "SDLImageWrapper.hpp" +using namespace sc::gui; + SDLImageWrapper::SDLImageWrapper() { int flags = IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_TIF; int result = IMG_Init(flags); diff --git a/SDLImageWrapper.hpp b/SDLImageWrapper.hpp index 5c1924a..b03079d 100644 --- a/SDLImageWrapper.hpp +++ b/SDLImageWrapper.hpp @@ -9,15 +9,19 @@ #ifndef __SDLIMAGEWRAPPER_H_ #define __SDLIMAGEWRAPPER_H_ -struct SDLImageWrapper { - SDLImageWrapper(); - ~SDLImageWrapper(); +namespace sc { + namespace gui { + struct SDLImageWrapper { + SDLImageWrapper(); + ~SDLImageWrapper(); - // prohibit copy and move - SDLImageWrapper(const SDLImageWrapper&) = delete; - SDLImageWrapper& operator=(const SDLImageWrapper&) = delete; - SDLImageWrapper(SDLImageWrapper&&) = delete; - SDLImageWrapper& operator=(SDLImageWrapper&&) = delete; -}; + // prohibit copy and move + SDLImageWrapper(const SDLImageWrapper&) = delete; + SDLImageWrapper& operator=(const SDLImageWrapper&) = delete; + SDLImageWrapper(SDLImageWrapper&&) = delete; + SDLImageWrapper& operator=(SDLImageWrapper&&) = delete; + }; + } +} #endif // __SDLIMAGEWRAPPER_H_ diff --git a/SDLWrapper.cpp b/SDLWrapper.cpp index 4e696b2..4701e78 100644 --- a/SDLWrapper.cpp +++ b/SDLWrapper.cpp @@ -9,6 +9,8 @@ #include #include "SDLWrapper.hpp" +using namespace sc::gui; + SDLWrapper::SDLWrapper() { SDL_Init(SDL_INIT_VIDEO); } diff --git a/SDLWrapper.hpp b/SDLWrapper.hpp index a9433e1..717b10d 100644 --- a/SDLWrapper.hpp +++ b/SDLWrapper.hpp @@ -9,15 +9,19 @@ #ifndef __SDLWRAPPER_H_ #define __SDLWRAPPER_H_ -struct SDLWrapper { - SDLWrapper(); - ~SDLWrapper(); +namespace sc { + namespace gui { + struct SDLWrapper { + SDLWrapper(); + ~SDLWrapper(); - // prohibit copy and move - SDLWrapper(const SDLWrapper&) = delete; - SDLWrapper& operator=(const SDLWrapper&) = delete; - SDLWrapper(SDLWrapper&&) = delete; - SDLWrapper& operator=(SDLWrapper&&) = delete; -}; + // prohibit copy and move + SDLWrapper(const SDLWrapper&) = delete; + SDLWrapper& operator=(const SDLWrapper&) = delete; + SDLWrapper(SDLWrapper&&) = delete; + SDLWrapper& operator=(SDLWrapper&&) = delete; + }; + } +} #endif // __SDLWRAPPER_H_ diff --git a/Window.cpp b/Window.cpp index 8264632..af6bc85 100644 --- a/Window.cpp +++ b/Window.cpp @@ -10,6 +10,8 @@ #include #include "Window.hpp" +using namespace sc::gui; + Window::Window(const char* title) : _path {title} { SDL_Window* win = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, diff --git a/Window.hpp b/Window.hpp index 79b53bf..0388232 100644 --- a/Window.hpp +++ b/Window.hpp @@ -14,21 +14,25 @@ #include #include -class Window { - public: - Window(const char* title); +namespace sc { + namespace gui { + class Window { + public: + Window(const char* title); - SDL_Window* get_window() const { return _w.get(); } - void set_size(int w, int h); + SDL_Window* get_window() const { return _w.get(); } + void set_size(int w, int h); - void update() const; - void load_image(); + void update() const; + void load_image(); - private: - std::string _path; - std::unique_ptr _w {nullptr, SDL_DestroyWindow}; - std::unique_ptr _r {nullptr, SDL_DestroyRenderer}; - std::unique_ptr _t {nullptr, SDL_DestroyTexture}; -}; + private: + std::string _path; + std::unique_ptr _w {nullptr, SDL_DestroyWindow}; + std::unique_ptr _r {nullptr, SDL_DestroyRenderer}; + std::unique_ptr _t {nullptr, SDL_DestroyTexture}; + }; + } +} #endif // __WINDOW_H_