changelog shortlog graph tags branches changeset files file revisions raw help

Mercurial > core / annotate lisp/lib/obj/id.lisp

changeset 387: 8252ee515756
parent: a3b65a8138ac
author: Richard Westhaver <ellis@rwest.io>
date: Thu, 30 May 2024 18:31:53 -0400
permissions: -rw-r--r--
description: db and readtables
104
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
1
 ;;; lib/obj/id.lisp --- IDs
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
2
 (in-package :obj/id)
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
3
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
4
 (defclass id ()
115
7ed6bc70ca20 added basics of DB, included XDB, added IEEE floats to std/num module (new)
ellis <ellis@rwest.io>
parents: 104
diff changeset
5
   ((id :initarg :id :initform 0 :accessor id :type fixnum)))
104
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
6
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
7
 (defgeneric reset-id (obj)
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
8
   (:documentation "Reset the id slot of SELF to 0.")
115
7ed6bc70ca20 added basics of DB, included XDB, added IEEE floats to std/num module (new)
ellis <ellis@rwest.io>
parents: 104
diff changeset
9
   (:method ((obj standard-object)) (setf (id obj) 0))
104
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
10
   (:method ((obj t)) 0))
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
11
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
12
 (defgeneric update-id (obj)
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
13
   (:documentation "Update the id slot of SELF.")
115
7ed6bc70ca20 added basics of DB, included XDB, added IEEE floats to std/num module (new)
ellis <ellis@rwest.io>
parents: 104
diff changeset
14
   (:method ((obj standard-object)) (setf (id obj) (hash-object obj)))
104
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
15
   (:method ((obj t)) (hash-object obj)))
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
16
 
229
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 212
diff changeset
17
 (defgeneric make-id (kind)
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 212
diff changeset
18
   (:documentation "Allocate a new ID object of a specified KIND.")
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 212
diff changeset
19
   (:method ((kind (eql nil)))
240
a3b65a8138ac html,http init, uuid, db stuff
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
20
     (declare (ignore kind))
a3b65a8138ac html,http init, uuid, db stuff
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
21
     (make-instance 'id))
a3b65a8138ac html,http init, uuid, db stuff
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
22
   (:method ((kind (eql t)))
a3b65a8138ac html,http init, uuid, db stuff
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
23
     (declare (ignore kind))
a3b65a8138ac html,http init, uuid, db stuff
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
24
     (make-instance 'id :id most-positive-fixnum)))
a3b65a8138ac html,http init, uuid, db stuff
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
25
 
a3b65a8138ac html,http init, uuid, db stuff
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
26
 (defmethod print-object ((obj id) stream)
a3b65a8138ac html,http init, uuid, db stuff
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
27
   (print-unreadable-object (obj stream :type "ID")
a3b65a8138ac html,http init, uuid, db stuff
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
28
     (format stream "~A" (id obj))))
212
742e6d74752d added sans-io module, more bits
Richard Westhaver <ellis@rwest.io>
parents: 115
diff changeset
29
 
742e6d74752d added sans-io module, more bits
Richard Westhaver <ellis@rwest.io>
parents: 115
diff changeset
30
 (defclass id-factory () ())
387
8252ee515756 db and readtables
Richard Westhaver <ellis@rwest.io>
parents: 240
diff changeset
31
 
8252ee515756 db and readtables
Richard Westhaver <ellis@rwest.io>
parents: 240
diff changeset
32
 (defgeneric identify (self)
8252ee515756 db and readtables
Richard Westhaver <ellis@rwest.io>
parents: 240
diff changeset
33
   (:documentation "Return the identity of object SELF - usually meant for objects which don't
8252ee515756 db and readtables
Richard Westhaver <ellis@rwest.io>
parents: 240
diff changeset
34
 specialize on ID but should still sometimes return an ID."))