Previous Next Contents

10. Mutability

All Coldmud objects must inherit from class Data. Data contains an unsigned reference count, and defines a method to increment and decrement the refcount.

It is, of course, an error for refcount to fall below 0, and this invariant should be assert()ed. It is clear that no Object may be referenced more than 2^31 times in a given database.

Data defines virtual Slot Data::mutate() which is called when a modification is about to be performed upon an instance. Modifications are performed on the Data returned, instead.

The mutate() method may function as an identity, returning `this', in which case the object is directly operated upon.

Thus, a subclass of any basetype may declare itself mutable by redefining its mutate() method to be an identity function.


Previous Next Contents