From a196661d761fee970f9d743494811800dcf51908 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Sat, 20 Feb 2016 21:47:59 +0100 Subject: [PATCH] Add `Settings` singleton --- example/src/Settings.cpp | 22 ++++++++++++++++++++++ example/src/Settings.h | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 example/src/Settings.cpp create mode 100644 example/src/Settings.h diff --git a/example/src/Settings.cpp b/example/src/Settings.cpp new file mode 100644 index 0000000..509371e --- /dev/null +++ b/example/src/Settings.cpp @@ -0,0 +1,22 @@ +#include "Settings.h" + +Settings * Settings::_instance = 0; + +Settings * Settings::instance(){ + if(_instance == 0){ + _instance = new Settings(); + } + return _instance; +} + +Settings::Settings(){ + _fullscreen = false; +} + +void Settings::setFullscreen(bool f){ + _fullscreen = f; +} + +bool Settings::getFullscreen(){ + return _fullscreen; +} \ No newline at end of file diff --git a/example/src/Settings.h b/example/src/Settings.h new file mode 100644 index 0000000..db3db66 --- /dev/null +++ b/example/src/Settings.h @@ -0,0 +1,18 @@ +#pragma once + +#include "ofMain.h" + +class Settings { + public: + static Settings * instance(); + + void setFullscreen(bool f); + bool getFullscreen(); + + private: + static Settings * _instance; + + Settings(); + + bool _fullscreen; +};