add doc strings to cell and prop-net

This commit is contained in:
sorrel 2024-04-04 17:41:27 -04:00
parent 369fd89e62
commit d97bcfa82c
2 changed files with 21 additions and 16 deletions

View file

@ -5,10 +5,14 @@
(= content nothing))
(defprotocol ICell
(neighbors [this])
(content [this])
(add-content! [this increment])
(new-neighbor! [this new-neighbor]))
(neighbors [this]
"returns all propagators the cell serves as input to")
(content [this]
"returns current content")
(add-content! [this increment]
"adds content to cell if none is present")
(new-neighbor! [this new-neighbor]
"adds a new propagator as a neighbor to the cell"))
(defrecord Cell
[neighbors
@ -34,7 +38,6 @@
(let [old-neighbors (deref (:neighbors this))]
(do (swap! (:neighbors this) conj new-neighbor)
;; add input
;;(alert-propagator new-neighbor)
:ok))))
;; returns an initialized cell

View file

@ -12,11 +12,11 @@
(defprotocol IPropNet
"A Naive Scalar Propagation Network. Add Cells and Propagators, wire them
together and run. Cells should update based on wiring"
;; introspect methods
(alerted-propagators [this]
"")
;; -- introspect methods
(get-alerted-propagators [this]
"returns the keys of all propagators to be alerted on next scheduler cycle")
(propagators-ever-alerted [this]
"")
"returns the keys of all propagators alerted since last scheduler initialization")
(get-cells [this]
"returns hash-map of all cells in network")
(propagators [this]
@ -30,15 +30,16 @@
;; mutation methods
(add-cell! [this cell-key]
"")
"create a cell associated with a given key")
(add-content-to-cell! [this cell-key content]
"")
(add-propagator! [this func]
"")
"add content to a cell at the given key, alerting the cell's neighboring
propagators, if any")
(add-propagator! [this prop-key func]
"create a propagator from the given function and associate it with the given key")
(add-neighbor-to-cell! [this cell-key prop-key]
"")
"give the cell of the given cellkey a new neighbor of the given propagator key")
(add-output-to-propagator! [this prop-key cell-key]
"")
"wire the output of a given propagator to the set-content! function of a given cell")
;; run methods
(initialize-scheduler! [this]
@ -61,8 +62,9 @@
all-propagators
propagators-ever-alerted]
IPropNet
;; introspect methods INFO - complete
(alerted-propagators [net] (deref-get net :alerted-propagators))
(get-alerted-propagators [net] (deref-get net :alerted-propagators))
(propagators-ever-alerted [net] (deref-get net :propagators-ever-alerted))
(get-cells [net] (deref-get net :cells))
(propagators [net] (deref-get net :all-propagators))