Skip to content

Commit

Permalink
libraries/history-tree: Add data' slot for owner'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambrevar committed Nov 7, 2022
1 parent e853e0f commit 0254795
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libraries/history-tree/history-tree.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ If the node has no owner, return Epoch."
:type (or null node)
:documentation "The first node created for this owner.
Not to be confused with the root, since the owner be go back to a parent of `origin'.")
(data nil
:type t
:documentation "Arbitrary data.")
(creator-id nil
:type t
:documentation "The owner-id in `origin's parent node that
Expand Down Expand Up @@ -360,12 +363,14 @@ OWNER may be an owner ID or owner object."
(gethash owner-spec (owners history))))

(export-always 'add-owner)
(declaim (ftype (function (history-tree t &key (:creator-id t))
(declaim (ftype (function (history-tree t &key (:creator-id t)
(:data t))
(values owner &optional))
add-owner))
(defun add-owner (history owner-id &key creator-id)
(defun add-owner (history owner-id &key creator-id data)
"Create and register owner object for OWNER-IDENTIFIER.
CREATOR-ID is the optional identifier of the parent owner.
DATA is the optional, arbitrary payload associated to the owner.
Return the newly created owner. If the owner with such identifier already
exists, return it and raise a warning."
(let ((owner (owner history owner-id)))
Expand All @@ -381,6 +386,7 @@ exists, return it and raise a warning."
creator-id))
(let ((owner (make-instance 'owner
:creator-id creator-id
:data data
:creator-node (when creator-id
(current creator-owner)))))
(setf (gethash owner-id (owners history))
Expand Down

0 comments on commit 0254795

Please sign in to comment.