class.lisp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. (in-package :hurd-translator)
  2. ;;
  3. ;; This file implements the translator class.
  4. ;;
  5. (defun %get-identity-port ()
  6. "Creates a new port as the translator identity port."
  7. (port-allocate :right-receive))
  8. (defclass translator ()
  9. ((identity-port :initform (%get-identity-port)
  10. :accessor identity-port
  11. :documentation "The translator's identity port.")
  12. (port-bucket :initform (make-bucket)
  13. :accessor port-bucket
  14. :documentation "The bucket, where we save all the translator ports.")
  15. (underlying-node :initform nil
  16. :reader underlying-node
  17. :documentation "The port to the underlying node where the translator is set.")
  18. (root-node :initform nil
  19. :accessor root
  20. :documentation "The root node.")
  21. (statfs :initform (make-statfs)
  22. :accessor get-statfs
  23. :documentation "File system statistics")
  24. (name :initform "cl-translator"
  25. :accessor name
  26. :initarg :name
  27. :documentation "Translator's name.")
  28. (version :initform (list 1 0 0)
  29. :accessor version
  30. :initarg :version
  31. :documentation "Translator version.")
  32. (storage :initform :memory
  33. :initarg :storage
  34. :accessor storage
  35. :documentation "Translator's storage type.")
  36. (options :initform (make-translator-options)
  37. :accessor options
  38. :initarg :options
  39. :documentation "Translator options."))
  40. (:documentation "Translator class."))
  41. (defmethod new-protid ((trans translator) user (open-node open-node))
  42. "Creates a new protid and inserts it into the translator bucket."
  43. (bucket-add-port (port-bucket trans)
  44. (make-protid user open-node)))
  45. (defmethod initialize-instance :after ((translator translator) &key)
  46. "Destroy identity port when translator goes away."
  47. (with-accessors ((id identity-port)) translator
  48. (finalize translator (lambda () (port-destroy id)))))
  49. (defmethod running-p ((translator translator))
  50. "Checking if translator is now running."
  51. (slot-value translator 'underlying-node))