1 #ifndef changetracker_h 2 #define changetracker_h 29 : chgd_(c), chgid_(0) {}
31 : chgd_(&c), chgid_(0) {}
33 : chgid_(&c), chgd_(0) {}
35 : chgid_(c), chgd_(0) {}
37 : chgd_(&c), chgid_(&ci) {}
40 template <
class T,
class U>
41 inline bool set(
const T& oldval,
const U& newval);
43 template <
class T,
class U>
44 inline bool update(T& val,
const U& newval);
47 inline bool set(
const char*&,
const char*&);
50 {
return chgd_ ? *chgd_ : (bool)(chgid_ ? *chgid_ : 0);}
52 {
return chgid_ ? *chgid_ : (chgd_ ? (*chgd_?1:0) : 0);}
53 inline void setChanged(
bool yn=
true);
55 {
if ( chgid_ ) *chgid_ = c; }
59 const bool&
boolVar()
const {
return *chgd_; }
61 const unsigned int&
intVar()
const {
return *chgid_; }
64 void setVar(
bool* m ) { chgd_ = m; }
65 void setVar(
bool& m ) { chgd_ = &m; }
66 void setVar(
unsigned int* m ) { chgid_ = m; }
67 void setVar(
unsigned int& m ) { chgid_ = &m; }
88 #define mChgTrackGetSet(chtr,obj,getfn,setfn,newval) { \ 89 if ( chtr.set( obj->getfn(), newval ) ) \ 90 obj->setfn( newval ); } 98 {
if ( ischgd ) (*chgid_)++; }
102 template <
class T,
class U>
105 bool ret = !(val ==
mCast(T,newval));
113 bool ret = (val && newval) || (!val && !newval);
114 if ( !ret ) {
setChanged(
true);
return true; }
115 if ( !val )
return false;
123 template <
class T,
class U>
126 bool ret =
set( val, newval );
const bool & boolVar() const
Don't call if !hasBoolVar()
Definition: changetracker.h:59
const unsigned int & intVar() const
Don't call if !hasIntVar()
Definition: changetracker.h:61
void setChanged(bool yn=true)
Definition: changetracker.h:93
bool update(T &val, const U &newval)
Changes and returns wether this value is changed.
Definition: changetracker.h:124
OD::String that holds an existing text string.
Definition: fixedstring.h:29
#define mCast(tp, v)
Definition: commondefs.h:124
bool * chgd_
Definition: changetracker.h:71
bool isChanged() const
Definition: changetracker.h:49
ChangeTracker(bool *c=0)
Definition: changetracker.h:28
ChangeTracker(unsigned int *c)
Definition: changetracker.h:34
unsigned int * chgid_
Definition: changetracker.h:72
bool hasIntVar() const
Definition: changetracker.h:58
void setVar(bool &m)
Definition: changetracker.h:65
ChangeTracker(unsigned int &c)
Definition: changetracker.h:32
ChangeTracker(bool &c)
Definition: changetracker.h:30
bool set(const T &oldval, const U &newval)
returns wether this value is changed
Definition: changetracker.h:103
ChangeTracker(bool &c, unsigned int &ci)
Definition: changetracker.h:36
void setVar(unsigned int *m)
Definition: changetracker.h:66
Updates a variable when changes occur.
Definition: changetracker.h:25
bool hasBoolVar() const
Definition: changetracker.h:57
unsigned int changeId() const
Definition: changetracker.h:51
void setChangeId(unsigned int c)
Definition: changetracker.h:54
#define mClass(module)
Definition: commondefs.h:164
void setVar(unsigned int &m)
Definition: changetracker.h:67
void setVar(bool *m)
Definition: changetracker.h:64