Tcl Library Source Code

Documentation
Login


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]

NAME

switched - switch/option management.

Table Of Contents

SYNOPSIS

package require Tcl 8.5 9
package require switched ?2.2.2?

complete this
options this
set-__option__ this value

DESCRIPTION

The switched class serves as base class for user classes with switch / option configuration procedures. It provides facilities for managing options through a simple interface.

For example:

set vehicle [new car -length 4.5 -width 2 -power 100 -fuel diesel]
puts "my car was running on [switched::cget $vehicle -fuel]"
switched::configure $vehicle -power 40 -fuel electricity
puts "but is now running on clean [switched::cget $vehicle -fuel]"

Of course, as you might have guessed, the car class is derived from the switched class. Let us see how it works:

class car {
    proc car {this args} switched {$args} {
        # car specific initialization code here
        switched::complete $this
    }
    ...
}

The switched class constructor takes the optional configuration option / value pairs as parameters. The switched class layer then completely manages the switched options: it checks their validity, stores their values and provides a clean interface to the user layer configuration setting procedures.

The switched class members available to the programmer are:

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category stooop of the Tcllib Trackers. 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.

KEYWORDS

C++, class, object, object oriented

CATEGORY

Programming tools