diff options
Diffstat (limited to 'src/core/unit.lisp')
-rw-r--r-- | src/core/unit.lisp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/core/unit.lisp b/src/core/unit.lisp new file mode 100644 index 0000000..20e05e2 --- /dev/null +++ b/src/core/unit.lisp @@ -0,0 +1,30 @@ +;;;; units/unit.lisp + +(in-package #:wheelwork) + +(defclass/std unit () + ((cached-application :a) + (container :with :a))) + +(defmethod (setf closer-mop:slot-value-using-class) :after + (newval class (unit unit) slot) + (case (closer-mop:slot-definition-name slot) + (container + (setf (cached-application unit) nil)))) + + +(defun app-of-unit (unit) + "Returns the APPLICATION instance, if any, of which this UNIT is a +part. NIL indicates that the unit has not been added to any container +in this application." + (or (cached-application unit) + (setf (cached-application unit) + (labels ((rec (u) + (when-let (c (unit-container u)) + (etypecase c + (application c) + (unit (rec c)) + (null nil))))) + (rec unit))))) + + |