tie_rarray.tcl

Go to the documentation of this file.
00001 /*  tie_rarray.tcl --*/
00002 /* */
00003 /*  Data source: Remote Tcl array.*/
00004 /* */
00005 /*  Copyright (c) 2004 Andreas Kupries <andreas_kupries@users.sourceforge.net>*/
00006 /* */
00007 /*  See the file "license.terms" for information on usage and redistribution*/
00008 /*  of this file, and for a DISCLAIMER OF ALL WARRANTIES.*/
00009 /*  */
00010 /*  RCS: @(#) $Id: tie_rarray.tcl,v 1.3 2005/09/28 04:51:24 andreas_kupries Exp $*/
00011 
00012 /*  ### ### ### ######### ######### #########*/
00013 /*  Requisites*/
00014 
00015 package require snit
00016 package require tie
00017 
00018 /*  ### ### ### ######### ######### #########*/
00019 /*  Implementation*/
00020 
00021 snit::type ::tie::std::rarray {
00022 
00023     /*  ### ### ### ######### ######### #########*/
00024     /*  Specials*/
00025 
00026     pragma -hastyperet s no
00027     pragma -hasinfo        no
00028     pragma -simpledispatch yes
00029 
00030     # ### ### ### ######### ######### #########
00031     ## API : Construction & Destruction
00032 
00033     constructor (type rvar , type cmdpfx , type id) {
00034     set remotevar $rvar
00035     set cmd       $cmdpfx
00036     set rid       $id
00037 
00038     if {![$self Call array exists $rvar]} {
00039         return -code error "Undefined source array variable \"$rvar\""
00040     }
00041     return
00042     }
00043 
00044     /*  ### ### ### ######### ######### #########*/
00045     /*  API : Data source methods*/
00046 
00047     ret  get () {
00048     return [$self Call array get $remotevar]
00049     }
00050 
00051     ret  set (type dict) {
00052     $self Call array set $remotevar $dict
00053     return
00054     }
00055 
00056     ret  unset (optional pattern =*) {
00057     $self Call array unset $remotevar $pattern
00058     return
00059     }
00060 
00061     ret  names () {
00062     return [$self Call array names $remotevar]
00063     }
00064 
00065     ret  size () {
00066     return [$self Call array size $remotevar]
00067     }
00068 
00069     ret  getv (type index) {
00070     return [$self Call set ${remotevar}($index)]
00071     }
00072 
00073     ret  setv (type index , type value) {
00074     $self Call set ${remotevar}($index) $value
00075     return
00076     }
00077 
00078     ret  unsetv (type index) {
00079     $self Call unset -nocomplain ${remotevar}($index)
00080     return
00081     }
00082 
00083     /*  ### ### ### ######### ######### #########*/
00084     /*  Internal : Instance data*/
00085 
00086     variable remotevar {} ; /*  Name of rmeote array*/
00087     variable cmd       {} ; /*  Send command prefix*/
00088     variable rid       {} ; /*  Id of entity hosting the array.*/
00089 
00090     /*  ### ### ### ######### ######### #########*/
00091     /*  Internal: Calling to the remote entity.*/
00092 
00093     /*  All calls are synchronous. Asynchronous operations would*/
00094     /*  created problems with circular ties. Because the operation may*/
00095     /*  came back so much later that the origin is already in a*/
00096     /*  completely new state. This is avoied in synchronous mode as the*/
00097     /*  origin waits for the change to be acknowledged, and the*/
00098     /*  operation came back in this time. The change made by it is no*/
00099     /*  problem. The trace is still running, thus any write does _not_*/
00100     /*  re-invoke our trace. The only possible problem is an unset for*/
00101     /*  an element already gone. This was solved by using -nocomplain*/
00102     /*  when propagating this type of change.*/
00103 
00104     ret  Call (type args) {
00105     set     c $cmd
00106     lappend c $rid
00107     foreach a $args {lappend c $a}
00108     return [uplevel #0 $c]
00109     }
00110 
00111     /*  ### ### ### ######### ######### #########*/
00112 }
00113 
00114 /*  ### ### ### ######### ######### #########*/
00115 /*  Ready to go*/
00116 
00117 ::tie::register ::tie::std::rarray as remotearray
00118 package provide   tie::std::rarray 1.0
00119 

Generated on 21 Sep 2010 for Gui by  doxygen 1.6.1