1tool(n)            Standardized OO Framework for development           tool(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       tool - TclOO Library (TOOL) Framework
9

SYNOPSIS

11       package require Tcl  8.6
12
13       package require sha1
14
15       package require dicttool
16
17       package require oo::meta
18
19       package require oo::dialect
20
21       tool::define class_method arglist body
22
23       tool::define array name contents
24
25       tool::define array_ensemble methodname varname ?cases?
26
27       tool::define dict_ensemble methodname varname ?cases?
28
29       tool::define method methodname arglist body
30
31       tool::define option name dictopts
32
33       tool::define property ?branch? field value
34
35       tool::define variable name value
36
37       object cget option
38
39       object configure ?keyvaluelist?
40
41       object configure field value ?field? ?value? ?...?
42
43       object configurelist ?keyvaluelist?
44
45       object forward stub forward
46
47       object graft stub forward
48
49       object InitializePublic
50
51       object Eval_Script ?script?
52
53       object Option_Default field
54
55______________________________________________________________________________
56

DESCRIPTION

58       This  module  implements  the Tcl Object Oriented Library framework, or
59       TOOL. It is intended to be a general purpose framework that is  useable
60       in its own right, and easily extensible.
61
62       TOOL  defines  a metaclass with provides several additional keywords to
63       the TclOO description langauge, default behaviors  for  its  consituent
64       objects, and top-down integration with the capabilities provided by the
65       oo::meta package.
66
67       The TOOL metaclass was build with the oo::dialect package, and thus can
68       be  used  as the basis for additional metaclasses. As a metaclass, TOOL
69       has it's own "class" class, "object" class, and define namespace.
70
71
72              package require tool
73
74              # tool::class workds just like oo::class
75              tool::class create myclass {
76              }
77
78              # tool::define works just like oo::define
79              tool::define myclass method noop {} {}
80
81              # tool::define and tool::class understand additional keywords
82              tool::define myclass array_ensemble mysettings mysettings {}
83
84              # And tool interoperates with oo::define
85              oo::define myclass method do_something {} { return something }
86
87              # TOOL and TclOO objects are interchangeable
88              oo::class create myooclass {
89                superclass myclass
90              }
91
92
93       Several manual pages go into more detail about  specific  keywords  and
94       methods.
95
96       tool::array_ensemble
97
98       tool::dict_ensemble
99
100       tool::method_ensemble
101
102       tool::object
103
104       tool::option_handling
105

KEYWORDS

107       TOOL  adds  new  (or  modifies)  keywords  used  in  the definitions of
108       classes. However, the new keywords are  only  available  via  calls  to
109       tool::class create or tool::define
110
111       tool::define class_method arglist body
112              Defines  a  method for the class object itself. This method will
113              be passed on to descendents of the class, unlike self method.
114
115       tool::define array name contents
116              Declares a variable name which will be initialized as an  array,
117              populated  with  contents  for objects of this class, as well as
118              any objects for classes which are descendents of this class.
119
120       tool::define array_ensemble methodname varname ?cases?
121              Declares a method ensemble methodname which will control  access
122              to  variable varname. Cases are a key/value list of method names
123              and bodies which will be overlaid on top of  the  standard  tem‐
124              plate. See tool::array_ensemble.
125
126              One method name is reserved: initialize. initialize Declares the
127              initial values to be populated in  the  array,  as  a  key/value
128              list, and will not be expressed as a method for the ensemble.
129
130       tool::define dict_ensemble methodname varname ?cases?
131              Declares  a method ensemble methodname which will control access
132              to variable varname. Cases are a key/value list of method  names
133              and  bodies  which  will be overlaid on top of the standard tem‐
134              plate. See tool::dict_ensemble.
135
136              One method name is reserved: initialize. initialize Declares the
137              initial  values  to  be  populated  in the array, as a key/value
138              list, and will not be expressed as a method for the ensemble.
139
140       tool::define method methodname arglist body
141              If methodname contains ::, the method is considered to  be  part
142              of a method ensemble. See tool::method_ensembles. Otherwise this
143              command behaves exactly like the standard oo::define method com‐
144              mand.
145
146       tool::define option name dictopts
147              Declares an option. dictopts is a key/value list defining param‐
148              eters for the option. See tool::option_handling.
149
150
151              tool::class create myclass {
152                option color {
153                  post-command: {puts [list %self%'s %field% is now %value%]}
154                  default: green
155                }
156              }
157              myclass create foo
158              foo configure color purple
159              > foo's color is now purple
160
161
162       tool::define property ?branch? field value
163              Defines a new leaf in the class metadata tree. With  no  branch,
164              the  leaf will appear in the const section, accessible by either
165              the object's property method, or via  oo::meta::info  class  get
166              const field:
167
168       tool::define variable name value
169              Declares  a  variable  name  which  will be initialized with the
170              value value for objects of this class, as well  as  any  objects
171              for classes which are descendents of this class.
172

PUBLIC OBJECT METHODS

174       The  TOOL  object  mother of all classes defines several methods to en‐
175       forces consistent behavior throughout the framework.
176
177       object cget option
178              Return the value of this object's option option. If the property
179              options_strict  is  true for this class, calling an option which
180              was not declared by the option keyword will throw an  error.  In
181              all  other cases if the value is present in the object's options
182              array that value is returned. If it does not exist,  the  object
183              will attempt to retrieve a property of the same name.
184
185       object configure ?keyvaluelist?
186
187       object configure field value ?field? ?value? ?...?
188              This command will inject new values into the objects options ar‐
189              ray, according to the rules as set forth by the option  descrip‐
190              tions.  See  tool::option_handling  for details.  configure will
191              strip leading -'s off of field names, allowing it to behave in a
192              quasi-backward compatible manner to tk options.
193
194       object configurelist ?keyvaluelist?
195              This command will inject new values into the objects options ar‐
196              ray, according to the rules as set forth by the option  descrip‐
197              tions.  This command will perform validation and alternate stor‐
198              age rules. It will  not  invoke  trigger  rules.  See  tool::op‐
199              tion_handling for details.
200
201       object forward stub forward
202              A passthrough to oo:objdefine [self] forward
203
204       object graft stub forward
205              Delegates  the <stub> method to the object or command designated
206              by forward
207
208
209              tool::object create A
210              tool::object create B
211              A graft buddy B
212              A configure color red
213              B configure color blue
214              A cget color
215              > red
216              A <buddy> cget color
217              > blue
218
219

PRIVATE OBJECT METHODS

221       object InitializePublic
222              Consults the metadata for the class to ensure every  array,  op‐
223              tion,  and  variable which has been declared but not initialized
224              is initialized with the default value.  This method is called by
225              the  constructor and the morph method. It is safe to invoke mul‐
226              tiple times.
227
228       object Eval_Script ?script?
229              Executes a block of text within the  namespace  of  the  object.
230              Lines that begin with a # are ignored as comments. Commands that
231              begin with :: are interpreted as calling a global  command.  All
232              other Tcl commands that lack a "my" prefix are given one, to al‐
233              low the script to exercise internal methods. This method is  in‐
234              tended for configuration scripts, where the object's methods are
235              intepreting a domain specific language.
236
237
238              tool::class myclass {
239                constructor script {
240                  my Eval_Script $script
241                }
242                method node {nodename info} {
243                  my variable node
244                  dict set node $nodename $info
245                }
246                method get {args} {
247                  my variable node
248                  return [dict get $node $args]
249                }
250              }
251              myclass create movies {
252                # This block of code is executed by the object
253                node {The Day the Earth Stood Still} {
254                  date: 1952
255                  characters: {GORT Klatoo}
256                }
257              }
258              movies get {The Day the Earth Stood Still} date:
259              > 1952
260
261
262       object Option_Default field
263              Computes the default value for an option. See  tool::option_han‐
264              dling.
265

AUTHORS

267       Sean Woods
268

BUGS, IDEAS, FEEDBACK

270       This  document,  and the package it describes, will undoubtedly contain
271       bugs and other problems.  Please report such in the category  tcloo  of
272       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
273       also report any ideas for enhancements you may have for either  package
274       and/or documentation.
275
276       When proposing code changes, please provide unified diffs, i.e the out‐
277       put of diff -u.
278
279       Note further that  attachments  are  strongly  preferred  over  inlined
280       patches.  Attachments  can  be  made  by  going to the Edit form of the
281       ticket immediately after its creation, and  then  using  the  left-most
282       button in the secondary navigation bar.
283

KEYWORDS

285       TOOL, TclOO, framework
286

CATEGORY

288       TclOO
289
291       Copyright (c) 2015 Sean Woods <yoda@etoyoc.com>
292
293
294
295
296tcllib                               0.4.2                             tool(n)
Impressum