cmdr
Diff
Not logged in

Differences From Artifact [42209380d3]:

To Artifact [01dc1e629c]:


20
21
22
23
24
25
26
27
28





29
30
31
32
33

34
35
36
37



38
39
40

41
42
43
44
45
46
47
48
49

50















































51
52
53
54
55

56
57
58
59
60
61
62
20
21
22
23
24
25
26


27
28
29
30
31
32
33
34
35

36




37
38
39



40


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108







-
-
+
+
+
+
+




-
+
-
-
-
-
+
+
+
-
-
-
+
-
-







+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+




-
+







# # ## ### ##### ######## ############# #####################
## Definition - Single purpose command.

oo::class create ::xo::actor {
    # # ## ### ##### ######## #############
    ## Lifecycle

    constructor {{thename {}}} {
	my name: $thename
    constructor {} {
	set myname        {}
	set mydescription {}
	set mysuper       {}
	set mystore       {}
	return
    }

    # # ## ### ##### ######## #############
    ## Public APIs:
    ## Public API: Common actor attributes and behaviour
    #
    # - Perform an action.
    # - Return help information about the action.
    # - Return actor name.
    ## - Name.
    ## - Description (help information).
    ## - Chain of command.
    #
    ## Overridden by sub-classes.

    ## - Associative data store
    method do   {args} {}
    method help {}     {}

    method name {} {
	return $myname
    }

    method name: {thename} {
	set myname $thename
	return
    }

    method description {} {
	return $mydescription
    }

    method description: {thedescription} {
	set mydescription $the description
	return
    }

    method super {} {
	return $mysuper
    }

    method super: {thesuper} {
	set mysuper $thesuper
	return
    }

    method get {key} {
	# Satisfy from local store first ...
	if {[dict exists $mystore $key]} {
	    return [dict get $mystore $key]
	}
	# ... then ask in the chain of command ...
	if {$super ne {}} {
	    return [$super get $key]
	}
	# ... and fail if we are at the top.
	return -code error -errorcode {XO STORE UNKNOWN} \
	    "Expected known key for get, got \"$key\""
    }

    method set {key data} {
	dict set mystore $key $data
	return
    }

    # # ## ### ##### ######## #############
    ## Public APIs:
    ## Overridden by sub-classes.

    # - Perform an action.
    # - Return help information about the action.

    method do   {args} {}
    method help {}     {}

    ##
    # # ## ### ##### ######## #############

    variable myname
    variable myname mydescription mysuper mystore

    # # ## ### ##### ######## #############
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide xo::actor 0.1