yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
notify.h
Go to the documentation of this file.
1#ifndef YAZE_UTIL_NOTIFY_H
2#define YAZE_UTIL_NOTIFY_H
3
4namespace yaze {
5namespace util {
6
12template <typename T>
14 public:
16 NotifyValue(const T &value)
17 : value_(value), modified_(false), temp_value_() {}
18
19 void set(const T &value) {
20 if (value != value_) {
21 value_ = value;
22 modified_ = true;
23 }
24 }
25
26 void set(T &&value) {
27 if (value != value_) {
28 value_ = std::move(value);
29 modified_ = true;
30 }
31 }
32
33 const T &get() {
34 modified_ = false;
35 return value_;
36 }
37
38 T &edit() {
39 modified_ = false;
41 return temp_value_;
42 }
43
44 void commit() {
45 if (temp_value_ != value_) {
47 modified_ = true;
48 }
49 }
50
52 bool modified = modified_;
53 modified_ = false;
54 return modified;
55 }
56
57 operator T() { return get(); }
58 void operator=(const T &value) { set(value); }
59 bool modified() const { return modified_; }
60
61 private:
65};
66
67} // namespace util
68} // namespace yaze
69
70#endif
NotifyValue(const T &value)
Definition notify.h:16
void operator=(const T &value)
Definition notify.h:58
const T & get()
Definition notify.h:33
bool modified() const
Definition notify.h:59
void set(T &&value)
Definition notify.h:26
void set(const T &value)
Definition notify.h:19
Main namespace for the application.
Definition controller.cc:18