MINT2
CachedVar.h
Go to the documentation of this file.
1 
11 #ifndef CACHED_VAR_HH
12 #define CACHED_VAR_HH
13 
14 // HyperPlot includes
15 
16 
17 // Root includes
18 
19 
20 // std includes
21 
22 
23 template <class T>
24 class CachedVar {
25 
26  private:
27 
30 
31  public:
32 
33  CachedVar(const T& var = T());
34 
35  void changed(){
36  _needsUpdate = true;
37  }
38  void updated(){
39  _needsUpdate = false;
40  }
41 
42  T& get(){return _cachedVar;}
43  const T& get() const{return _cachedVar;}
44 
45  CachedVar& operator=(const T& other){
46  _cachedVar = other;
47  return *this;
48  }
49 
50  operator const T&() {
51  return _cachedVar;
52  }
53 
55  return _needsUpdate;
56  }
57 
59 
60  }
61 
62 
63 };
64 
65 template <class T> CachedVar<T>::CachedVar (const T& var) :
66  _needsUpdate(true),
67  _cachedVar(var)
68 {
69 
70 }
71 
72 
73 #endif
74 
void updated()
Definition: CachedVar.h:38
~CachedVar()
Definition: CachedVar.h:58
bool isUpdateNeeded()
Definition: CachedVar.h:54
void changed()
Definition: CachedVar.h:35
CachedVar & operator=(const T &other)
Definition: CachedVar.h:45
const T & get() const
Definition: CachedVar.h:43
T & get()
Definition: CachedVar.h:42
bool _needsUpdate
Definition: CachedVar.h:28
T _cachedVar
Definition: CachedVar.h:29
CachedVar(const T &var=T())
Definition: CachedVar.h:65