delegation



delegation

NAME
WARNING!
SYNOPSIS
DESCRIPTION
KEYWORDS

___________________________

NAME

itcl::delegation − delegate methods, procs or options to other objects

Parts of this description are "borrowed" from Tcl extension [snit], as the functionality is mostly identical.

WARNING!

This is new functionality in [incr Tcl] where the API can still change!!

SYNOPSIS

delegate method methodName to componentName ?as targetName?
delegate method
methodName ?to componentName? using pattern
delegate method
* ?to componentName? ?using pattern? ?except methodName methodName ...?

delegate proc procName to componentName ?as targetName?
delegate proc
procName ?to componentName? using pattern
delegate proc
* ?to componentName? ?using pattern? ?except procName procName ...?

delegate option optionSpec to componentName
delegate option
optionSpec to componentName as targetname?
delegate option
* to componentName
delegate option
* to componentName except optionName optionname ... ___________________________

DESCRIPTION

The delegate command is used inside an [incr Tcl] extendedclass/widget/widgetadaptor definition to delegate methods/procs/options to other objects for handling.
delegate method
methodName to componentName ?as targetName?

This form of delegate method delegates method methodName to component componentName. That is, when method methdoNameame is called on an instance of this type, the method and its arguments will be passed to the named component’s command instead. That is, the following statement

delegate method wag to tail

is roughly equivalent to this explicitly defined method:

method wag {args} {
uplevel $tail wag $args
}

The optional as clause allows you to specify the delegated method name and possibly add some arguments:

delegate method wagtail to tail as "wag briskly"

A method cannot be both locally defined and delegated.

delegate method methodName ?to componentName? using pattern

In this form of the delegate statement, the using clause is used to specify the precise form of the command to which method name name is delegated. The to clause is optional, since the chosen command might not involve any particular component.

The value of the using clause is a list that may contain any or all of the following substitution codes; these codes are substituted with the described value to build the delegated command prefix. Note that the following two statements are equivalent:

delegate method wag to tail
delegate method wag to tail using "%c %m"

Each element of the list becomes a single element of the delegated command --it is never reparsed as a string.

Substitutions:

%%

This is replaced with a single "%". Thus, to pass the string "%c" to the command as an argument, you’d write "%%c".

%c

This is replaced with the named component’s command.

%j

This is replaced by the method name; if the name consists of multiple tokens, they are joined by underscores ("_").

%m

This is replaced with the final token of the method name; if the method name has one token, this is identical to %M.

%M

This is replaced by the method name; if the name consists of multiple tokens, they are joined by space characters.

%n

This is replaced with the name of the instance’s private namespace.

%s

This is replaced with the name of the instance command.

%t

This is replaced with the fully qualified type name.

%w

This is replaced with the original name of the instance command; for Itcl widgets and widget adaptors, it will be the Tk window name. It remains constant, even if the instance command is renamed.

delegate method * ?to componentName? ?using pattern? ?except methodName
methodName ...
?

In this form all unknown method names are delegeted to the specified component. The except clause can be used to specify a list of exceptions, i.e., method names that will not be so delegated. The using clause is defined as given above. In this form, the statement must contain the to clause, the using clause, or both.

In fact, the "*" can be a list of two or more tokens whose last element is "*", as in the following example:

delegate method {tail *} to tail

This implicitly defines the method tail whose subcommands will be delegated to the tail component.

The definitions for delegate proc ... are the same as for method, the only difference being, that this is for procs.

delegate option namespec to comp
delegate option namespec to comp as target
delegate option * to
comp
delegate option * to
comp except exceptions

Defines a delegated option; the namespec is defined as for the option statement. When the configure, configurelist, or cget instance method is used to set or retrieve the option’s value, the equivalent configure or cget command will be applied to the component as though the option was defined with the following -configuremethod and -cgetmethod:

method ConfigureMethod {option value} {
$comp configure $option $value
}

method CgetMethod {option} {
return [$comp cget $option]
}

Note that delegated options never appear in the itcl_options array. If the as clause is specified, then the target option name is used in place of name.

delegate option * ?except optionName optionName ...?

This form delegates all unknown options to the specified component. The except clause can be used to specify a list of exceptions, i.e., option names that will not be so delegated.

Warning: options can only be delegated to a component if it supports the configure and cget instance methods.

An option cannot be both locally defined and delegated. TBD: Continue from here.

KEYWORDS

delegation, option, method, proc







Opportunity


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.





Free Software


Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.


Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.





Free Books


The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.


Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.





Education


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.


Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.