1# -*- tcl -*-
2# # ## ### ##### ######## #############
3# (C) 2009 Andreas Kupries
4
5# @@ Meta Begin
6# Package tcl::transform::core 1
7# Meta as::author {Andreas Kupries}
8# Meta as::copyright 2009
9# Meta as::license BSD
10# Meta description Support package handling a core
11# Meta description aspect of reflected transform channels
12# Meta description (initialization, finalization).
13# Meta description It is expected that this class
14# Meta description is used as either one superclass of the
15# Meta description class C for a specific channel, or is
16# Meta description mixed into C.
17# Meta platform tcl
18# Meta require TclOO
19# Meta require {Tcl 8.6}
20# @@ Meta End
21
22# # ## ### ##### ######## #############
23
24package require Tcl 8.6
25
26# # ## ### ##### ######## #############
27
28oo::class create ::tcl::transform::core {
29    destructor {
30	if {$channel eq {}} return
31	close $channel
32	return
33    }
34
35    # # ## ### ##### ######## #############
36
37    method initialize {thechannel mode} {
38	set methods [info object methods [self] -all]
39
40	# Note: Checking of the mode against the supported methods is
41	#       done by the caller.
42
43	set channel $thechannel
44	set supported {}
45	foreach m {
46	    initialize finalize read write drain flush limit?
47	} {
48	    if {$m in $methods} {
49		lappend supported $m
50	    }
51	}
52	return $supported
53    }
54
55    method finalize {c} {
56	set channel {} ; # Prevent destroctor from calling close.
57	my destroy
58	return
59    }
60
61    # # ## ### ##### ######## #############
62
63    variable channel
64
65    # channel The channel the handler belongs to.
66    # # ## ### ##### ######## #############
67}
68
69# # ## ### #####
70package provide tcl::transform::core 1
71return
72