C++ API Reference
|
Class implementing ability to keep track of when objects are changed. More...
#include <adskCheckpointed.h>
Public Member Functions | |
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... | |
Checkpointed () | |
Default constructor - initialize counter. | |
virtual | ~Checkpointed () |
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 Public Member Functions | |
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... | |
Protected Member Functions | |
Checkpoint | objectChanged () |
Call this whenever an object changes, increments the class and object checkpoint counters. More... | |
Protected Attributes | |
Checkpoint | fCheckpoint |
ID updating when the object changes. | |
Static Protected Attributes | |
static Checkpoint | sfGlobalCheckpoint = 0 |
Global monotonic checkpoint. More... | |
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.
Checkpointed | ( | const Checkpointed & | rhs | ) |
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 |
|
protected |
Call this whenever an object changes, increments the class and object checkpoint counters.
Checkpoint checkpoint | ( | ) | const |
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 |
Checkpointed & operator= | ( | const Checkpointed & | rhs | ) |
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 |
|
static |
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.
|
static |
Update the global checkpoint and return the new value.
This is called after any change to any checkpointed object.
|
static |
Answer a Print request for a Checkpointed object.
Use the request object to dump all information on the "me" Checkpointed, or all static Checkpointed information if "me" is NULL.
[in] | me | Pointer to object to debug, NULL means class static |
[out] | request | Print request object |
|
static |
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 |
|
staticprotected |
Global monotonic checkpoint.
Monotonically increasing global checkpoint.
Bumped any time any object or class of any time changes.