Constructor. owner can be null, in this case object won't have an owner. Such objects are called root owners and should be deleted manually.
Destructor
Add owned object. Usually you don't have to do it explicitly, just pass the owner to constructor
Delete owned object without deleting object itself
Delete particular owned object, if it is there
class Test: Owner { string name; static bool[string] available; this(string name, Owner o = null) { super(o); this.name = name; available[name] = true; } ~this() { available[name] = false; } } Test obj1 = New!Test("obj1", null); Test obj2 = New!Test("obj2", obj1); Test obj3 = New!Test("obj3", obj2); obj2.deleteOwnedObject(obj3); assert(!Test.available["obj3"]); Delete(obj1); assert(!Test.available["obj2"]); assert(!Test.available["obj1"]);
Basic owner object class. When you delete it, all owned object are automatically deleted