Class implementing ability to keep track of when objects are changed.
Often the question arises "has this object changed since I did X?". Using this class gives you the ability to create a unique monotonic ID to identify how recently something has changed, usually accompanied by the queryer remembering a checkpoint value to compare against.
This class must be a mixin to the class being tracked. The important thing is to insert this call at every point that object is changed:
Since the virtual function table isn't correct until the top level class constructor is called unfortunately you also have to insert checkpoint updates into the constructors and destructor of your class. The macros
will do that for you.
Object changes will also flag the class as changed but if any other changes happen which apply to the class as a whole they can be tagged with:
Example 1: An external object handler wishes to know when any object of class type MyObject was changed.
Note that since construction and destruction of objects count as changes to "the set of" MyObject they also get the edit flag updated.
Example 2: An external object handler wishes to know when a specific object has been changed.
|Checkpoint||checkpoint () const|
|Retrieve the current object checkpoint state. More...|
|bool||changedSinceCheckpoint (const Checkpoint &check) const|
|Determine if the object has been altered since the given checkpoint. More...|
|Default constructor - initialize counter. |
|Destructor, updates checkpoint count for the class. |
|Checkpointed (const Checkpointed &rhs)|
|Copy constructor - counter starts where copy left off. More...|
|Checkpointed &||operator= (const Checkpointed &rhs)|
|Assignment operator and copy constructor are just to allow objects with counters embedded or derived to copy properly. More...|
|static Checkpoint||globalCheckpoint ()|
|Retrieve the global checkpoint. More...|
|static Checkpoint||globalChange ()|
|Update the global checkpoint and return the new value. More...|
|static bool||Debug (const Checkpointed *me, Debug::Print &request)|
|Answer a Print request for a Checkpointed object. More...|
|static bool||Debug (const Checkpointed *me, Debug::Footprint &request)|
|Answer a footprint request for an Checkpointed object. More...|
|Call this whenever an object changes, increments the class and object checkpoint counters. More...|
|ID updating when the object changes. |
|static Checkpoint||sfGlobalCheckpoint = 0|
|Global monotonic checkpoint. More...|
Copy constructor - counter starts where copy left off.
It won't hurt to be higher and this prevents any unintended clash between objects who have copied counters.
|[in]||rhs||Counter to be copied|
Call this whenever an object changes, increments the class and object checkpoint counters.
Retrieve the current object checkpoint state.
|bool changedSinceCheckpoint||(||const Checkpoint &||check||)||const|
Determine if the object has been altered since the given checkpoint.
|[in]||check||Previous checkpoint to compare against|
Assignment operator and copy constructor are just to allow objects with counters embedded or derived to copy properly.
Assignment operator, updates the checkpoint and copies values.
|[in]||rhs||Counter to copy|
|[in]||rhs||Counter to copy|
Retrieve the global checkpoint.
Maintaining a single global checkpoint value ensures that any objects that are checkpointed can be compared against not only themselves but also each other. A fine enough grained timer would serve the same function but a monotonic counter is more flexible since its updates are asynchronous.
Update the global checkpoint and return the new value.
This is called after any change to any checkpointed object.
Answer a Print request for a Checkpointed object.
|[in]||me||Pointer to object to debug, NULL means class static|
|[out]||request||Print request object|
Answer a footprint request for an Checkpointed object.
Populate the Footprint request with the information on all data stored within this class if "me" is NULL, otherwise the information stored in the Checkpointed object pointed at by "me".
|[in]||me||Pointer to object to footprint, NULL means class static|
|[out]||request||Footprint object to populate|
Global monotonic checkpoint.
Monotonically increasing global checkpoint.
Bumped any time any object or class of any time changes.