Thrive
touchable.h
1 #pragma once
2 
3 namespace luabind {
4  class scope;
5 }
6 
7 namespace thrive {
8 
18 class Touchable {
19 
20 public:
21 
22 
33  static luabind::scope
34  luaBindings();
35 
39  bool
40  hasChanges() const;
41 
45  void
46  touch();
47 
51  void
52  untouch();
53 
54 private:
55 
56  bool m_hasChanges = true;
57 };
58 
65 template<typename T>
66 class TouchableValue : public Touchable {
67 
68 public:
69 
77  const T& value = T()
78  ) : m_value(value)
79  {
80  }
81 
94  const T& value
95  ) {
96  m_value = value;
97  this->touch();
98  return *this;
99  }
100 
106  operator T() const {
107  return this->get();
108  }
109 
115  T
116  get() const {
117  return m_value;
118  }
119 
120 private:
121 
122  T m_value;
123 };
124 
125 }
Helper class for keeping track of changing data.
Definition: touchable.h:18
A single touchable value.
Definition: touchable.h:66
bool hasChanges() const
Whether this Touchable has unapplied changes.
Definition: touchable.cpp:20
static luabind::scope luaBindings()
Lua bindings.
Definition: touchable.cpp:9
void touch()
Marks the Touchable as changed.
Definition: touchable.cpp:26
TouchableValue(const T &value=T())
Constructor.
Definition: touchable.h:76
Definition: bullet_to_ogre_system.h:5
Definition: bullet_ogre_conversion.h:6
void untouch()
Marks all changes as applied.
Definition: touchable.cpp:32
TouchableValue & operator=(const T &value)
Assignment operator.
Definition: touchable.h:93