tool(3tcl) | Standardized OO Framework for development | tool(3tcl) |
tool - TclOO Library (TOOL) Framework
package require Tcl 8.6
package require sha1
package require dicttool
package require oo::meta
package require oo::dialect
tool::define class_method arglist body
tool::define array name contents
tool::define array_ensemble methodname varname ?cases?
tool::define dict_ensemble methodname varname ?cases?
tool::define method methodname arglist body
tool::define option name dictopts
tool::define property ?branch? field value
tool::define variable name value
object cget option
object configure ?keyvaluelist?
object configure field value ?field? ?value? ?...?
object configurelist ?keyvaluelist?
object forward stub forward
object graft stub forward
object InitializePublic
object Eval_Script ?script?
object Option_Default field
This module implements the Tcl Object Oriented Library framework, or TOOL. It is intended to be a general purpose framework that is useable in its own right, and easily extensible.
TOOL defines a metaclass with provides several additional keywords to the TclOO description langauge, default behaviors for its consituent objects, and top-down integration with the capabilities provided by the oo::meta package.
The TOOL metaclass was build with the oo::dialect package, and thus can be used as the basis for additional metaclasses. As a metaclass, TOOL has it's own "class" class, "object" class, and define namespace.
package require tool # tool::class workds just like oo::class tool::class create myclass { } # tool::define works just like oo::define tool::define myclass method noop {} {} # tool::define and tool::class understand additional keywords tool::define myclass array_ensemble mysettings mysettings {} # And tool interoperates with oo::define oo::define myclass method do_something {} { return something } # TOOL and TclOO objects are interchangeable oo::class create myooclass { superclass myclass }
Several manual pages go into more detail about specific keywords and methods.
TOOL adds new (or modifies) keywords used in the definitions of classes. However, the new keywords are only available via calls to tool::class create or tool::define
One method name is reserved: initialize. initialize Declares the initial values to be populated in the array, as a key/value list, and will not be expressed as a method for the ensemble.
One method name is reserved: initialize. initialize Declares the initial values to be populated in the array, as a key/value list, and will not be expressed as a method for the ensemble.
tool::class create myclass { option color { post-command: {puts [list %self%'s %field% is now %value%]} default: green } } myclass create foo foo configure color purple > foo's color is now purple
The TOOL object mother of all classes defines several methods to enforces consistent behavior throughout the framework.
tool::object create A tool::object create B A graft buddy B A configure color red B configure color blue A cget color > red A <buddy> cget color > blue
tool::class myclass { constructor script { my Eval_Script $script } method node {nodename info} { my variable node dict set node $nodename $info } method get {args} { my variable node return [dict get $node $args] } } myclass create movies { # This block of code is executed by the object node {The Day the Earth Stood Still} { date: 1952 characters: {GORT Klatoo} } } movies get {The Day the Earth Stood Still} date: > 1952
Sean Woods
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category tcloo of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
TOOL, TclOO, framework
TclOO
Copyright (c) 2015 Sean Woods <yoda@etoyoc.com>
0.4.2 | tcllib |