aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens/Screen.h
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2021-03-20 11:41:49 +0100
committerJean-François Milants <jf@codingfield.com>2021-03-20 11:41:49 +0100
commit405c85c160b0d72407498a25555677d484b822f1 (patch)
tree71b22af329f7b5ee7a6f37ddca4c738f0e379593 /src/displayapp/screens/Screen.h
parente63596b291f973cdeb01cd0ac276861895bd4489 (diff)
parent9e9bb2085e70a9c8b8c2e74f6027f5392e366158 (diff)
Merge branch 'develop' of github.com:JF002/Pinetime into develop
# Conflicts: # src/main.cpp # src/systemtask/SystemTask.h
Diffstat (limited to 'src/displayapp/screens/Screen.h')
-rw-r--r--src/displayapp/screens/Screen.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h
index 6b1d0eec..638dac99 100644
--- a/src/displayapp/screens/Screen.h
+++ b/src/displayapp/screens/Screen.h
@@ -7,6 +7,26 @@ namespace Pinetime {
namespace Applications {
class DisplayApp;
namespace Screens {
+
+ template <class T>
+ class DirtyValue {
+ public:
+ DirtyValue() = default; // Use NSDMI
+ explicit DirtyValue(T const& v):value{v}{} // Use MIL and const-lvalue-ref
+ bool IsUpdated() const { return isUpdated; }
+ T const& Get() { this->isUpdated = false; return value; } // never expose a non-const lvalue-ref
+ DirtyValue& operator=(const T& other) {
+ if (this->value != other) {
+ this->value = other;
+ this->isUpdated = true;
+ }
+ return *this;
+ }
+ private:
+ T value{}; // NSDMI - default initialise type
+ bool isUpdated{true}; // NSDMI - use brace initilisation
+ };
+
class Screen {
public:
explicit Screen(DisplayApp* app) : app{app} {}