tsc_IDatabaseMonitor

When entities in the database are added, modified, or removed, the resulting events may be captured and handled using this monitor class.

Starting and stopping the monitor

void tsc_IDatabaseMonitor::Start (tsc_Job& job);
Starts monitoring events that occur on the supplied job.  If the job is not open when Start() is called, events will never occur.  If the job is closed while events are being monitored, event handling will stop permanently.  Calling Start multiple times for the same job is not an error.

void tsc_IDatabaseMonitor::Stop  (tsc_Job& job);
Stops event handling for the specified job.  If events were never started this is not an error, however stopping events for a job different from the one for which they were started, will cause an assert.

Event handlers

These methods are overridden as required.  They all have default implementations that ignore the event, so that only required handlers need to be implemented.

virtual void OnEntityAppended (tsc_Entity* entity);
Called when an object has been appended to the end of the database.  A reference to the appended object is passed to the handler.  Note that sometimes objects are written to the database, and then immediately modified (possibly several times).

virtual void OnEntityModified (tsc_Entity* entity);
Some property of an object has been modified.  A reference to the modified object is passed to the handler.

virtual void OnEntityReplaced (tsc_Entity* entity);
The object has been replaced.  This is very similar to modified; the difference is that many properties may change at once.  A reference to the new object is passed to the handler.

virtual void OnEntityDeleted  (tsc_Entity* entity);
The object's deleted flag has been set true.  A reference to the deleted object is passed to the handler.

virtual void OnEntityUndeleted (tsc_Entity* entity);
The object's deleted flag has been set false.   A reference to the deleted object is passed to the handler.

virtual void OnEntityUnlinked ();
An object has been permanently removed from the database.  This only occurs for internal temporary items.

virtual void OnDatabaseClosing ();
While not strictly a database change, this event is useful for tidying up.  It occurs when the database is about to be closed.