Skip to content

dlib.core.ownership

Timur Gafarov edited this page Feb 22, 2018 · 4 revisions

dlib.core.ownership

Object ownership system similar to Delphi's. All classes deriving from Owner can store references to objects implementing Owned interface (and other Owner objects as well). When an owner is deleted, its owned objects are also deleted.

This module is not compatible with GC-collected objects. It can be used only with dlib.core.memory. Using it with objects allocated any other way will cause application to crash.

interface Owned

An empty interface that is used to mark objects that can be owned.

class Owner: Owned

Base owner class.

  • this(Owner owner) - base constructor. owner is an owner for this object. It can be null, in this case object won't have an owner. Such objects are called root owners and should be deleted manually.
  • void addOwnedObject(Owned obj) - adds owned object.
  • void clearOwnedObjects() - deletes owned objects without deleting owner itself
Clone this wiki locally