5 type informationtuple struct {
10 type informationretrievalpath struct {
12 returnpath chan interface{}
15 type hippocampus map[string]interface{}
18 storeTuple chan informationtuple
19 retrieveValue chan informationretrievalpath
25 b.storeTuple = make(chan informationtuple)
26 b.retrieveValue = make(chan informationretrievalpath)
31 func (b *Brain) runBrain() {
32 var h hippocampus = make(hippocampus)
35 case newtuple := <- b.storeTuple:
36 h[newtuple.name] = newtuple.value
38 case retrievvalue := <- b.retrieveValue:
39 v, e := h[retrievvalue.name]
41 retrievvalue.returnpath <- v
43 retrievvalue.returnpath <- nil
52 func (b *Brain) Shutdown() {
56 func (b *Brain) Oboite(name string, value interface{}) {
57 b.storeTuple <- informationtuple{name, value}
60 func (b *Brain) OmoiDashite(name string) (interface{}, error) {
61 rc := make(chan interface{})
62 b.retrieveValue <- informationretrievalpath{name, rc}
65 return v, errors.New("name not in brain")
70 func (b *Brain) OmoiDashiteBool(name string) (bool, error) {
71 v, e := b.OmoiDashite(name)
77 return false, errors.New(name + " does not have type bool")
82 func (b *Brain) OmoiDashiteInt(name string) (int, error) {
83 v, e := b.OmoiDashite(name)
89 return 0, errors.New(name + " does not have type int")
94 func (b *Brain) OmoiDashiteFloat(name string) (float64, error) {
95 v, e := b.OmoiDashite(name)
101 return 0, errors.New(name + " does not have type float64")
106 func (b *Brain) OmoiDashiteString(name string) (string, error) {
107 v, e := b.OmoiDashite(name)
113 return "", errors.New(name + " does not have type string")