add doc strings to cell and prop-net
This commit is contained in:
parent
369fd89e62
commit
d97bcfa82c
2 changed files with 21 additions and 16 deletions
|
@ -5,10 +5,14 @@
|
||||||
(= content nothing))
|
(= content nothing))
|
||||||
|
|
||||||
(defprotocol ICell
|
(defprotocol ICell
|
||||||
(neighbors [this])
|
(neighbors [this]
|
||||||
(content [this])
|
"returns all propagators the cell serves as input to")
|
||||||
(add-content! [this increment])
|
(content [this]
|
||||||
(new-neighbor! [this new-neighbor]))
|
"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
|
(defrecord Cell
|
||||||
[neighbors
|
[neighbors
|
||||||
|
@ -34,7 +38,6 @@
|
||||||
(let [old-neighbors (deref (:neighbors this))]
|
(let [old-neighbors (deref (:neighbors this))]
|
||||||
(do (swap! (:neighbors this) conj new-neighbor)
|
(do (swap! (:neighbors this) conj new-neighbor)
|
||||||
;; add input
|
;; add input
|
||||||
;;(alert-propagator new-neighbor)
|
|
||||||
:ok))))
|
:ok))))
|
||||||
|
|
||||||
;; returns an initialized cell
|
;; returns an initialized cell
|
||||||
|
|
|
@ -12,11 +12,11 @@
|
||||||
(defprotocol IPropNet
|
(defprotocol IPropNet
|
||||||
"A Naive Scalar Propagation Network. Add Cells and Propagators, wire them
|
"A Naive Scalar Propagation Network. Add Cells and Propagators, wire them
|
||||||
together and run. Cells should update based on wiring"
|
together and run. Cells should update based on wiring"
|
||||||
;; introspect methods
|
;; -- introspect methods
|
||||||
(alerted-propagators [this]
|
(get-alerted-propagators [this]
|
||||||
"")
|
"returns the keys of all propagators to be alerted on next scheduler cycle")
|
||||||
(propagators-ever-alerted [this]
|
(propagators-ever-alerted [this]
|
||||||
"")
|
"returns the keys of all propagators alerted since last scheduler initialization")
|
||||||
(get-cells [this]
|
(get-cells [this]
|
||||||
"returns hash-map of all cells in network")
|
"returns hash-map of all cells in network")
|
||||||
(propagators [this]
|
(propagators [this]
|
||||||
|
@ -30,15 +30,16 @@
|
||||||
|
|
||||||
;; mutation methods
|
;; mutation methods
|
||||||
(add-cell! [this cell-key]
|
(add-cell! [this cell-key]
|
||||||
"")
|
"create a cell associated with a given key")
|
||||||
(add-content-to-cell! [this cell-key content]
|
(add-content-to-cell! [this cell-key content]
|
||||||
"")
|
"add content to a cell at the given key, alerting the cell's neighboring
|
||||||
(add-propagator! [this func]
|
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]
|
(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]
|
(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
|
;; run methods
|
||||||
(initialize-scheduler! [this]
|
(initialize-scheduler! [this]
|
||||||
|
@ -61,8 +62,9 @@
|
||||||
all-propagators
|
all-propagators
|
||||||
propagators-ever-alerted]
|
propagators-ever-alerted]
|
||||||
IPropNet
|
IPropNet
|
||||||
|
|
||||||
;; introspect methods INFO - complete
|
;; 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))
|
(propagators-ever-alerted [net] (deref-get net :propagators-ever-alerted))
|
||||||
(get-cells [net] (deref-get net :cells))
|
(get-cells [net] (deref-get net :cells))
|
||||||
(propagators [net] (deref-get net :all-propagators))
|
(propagators [net] (deref-get net :all-propagators))
|
||||||
|
|
Loading…
Reference in a new issue