;;;; in Text, HTML, and XML formats. This includes hyperlinking
;;;; capability and sub-objects.
;;;;
-;;;; $Id: mop.lisp,v 1.11 2002/12/13 08:25:45 kevin Exp $
+;;;; $Id: mop.lisp,v 1.12 2002/12/13 22:00:05 kevin Exp $
;;;;
;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
;;;;
"List of fields that contain a list of subobjects objects.")
(hyperlinks :type list :initform nil :accessor hyperlinks
:documentation "List of fields that have hyperlinks")
+ (direct-rules :type list :initform nil :accessor direct-rules
+ :documentation "List of rules to fire on slot changes.")
(class-id :type integer :initform nil
:accessor class-id
:documentation "Unique ID for the class")
:description (slot-value dsd 'description)
:user-name (slot-value dsd 'user-name)
:index (slot-value dsd 'index)
+ :value-constraint (slot-value dsd 'value-constraint)
+ :null-allowed (slot-value dsd 'null-allowed)
ia))))
(defun ho-type-to-lisp-type (ho-type)
(defun hyperobject-class-fields (obj)
(class-slots (class-of obj)))
+;;; Slot accessor and class rules
+
+(defun fire-class-rules (cl obj)
+ "Fire all class rules. Called after a slot is modified."
+ (dolist (rule (direct-rules cl))
+ (cmsg "firing rule: ~a" rule)))
+
+
+(defmethod (setf slot-value-using-class)
+ :around (new-value (cl hyperobject-class) obj
+ (slot standard-effective-slot-definition))
+ (cmsg-c :verbose "Setf slot value: class: ~s, obj: ~s, slot: ~s, value: ~s" cl (class-of obj) slot new-value)
+ (let ((func (esd-value-constraint slot)))
+ (cond
+ ((and func (not (funcall func new-value obj)))
+ (warn "Rejected change to value of slot ~a of object ~a"
+ (slot-definition-name slot) obj)
+ (slot-value obj (slot-definition-name slot)))
+ (t
+ (call-next-method)
+ (fire-class-rules cl obj)
+ new-value))))
+
+(defmethod slot-value-using-class :around ((cl hyperobject-class) obj
+ (slot standard-effective-slot-definition))
+ (let ((value (call-next-method)))
+ (cmsg-c :verbose "slot value: class: ~s, obj: ~s, slot: ~s" cl (class-of obj) slot)
+ value))