# $Id: s.JufGdbmStorage.xotcl 1.5 01/03/23 21:55:32+01:00 neumann@somewhere.wu-wien.ac.at $
package provide xotcl::store::jufgdbm 0.81

package require xotcl::store::juf_gdbm
package require xotcl::store

#
# a simple GNU Gdbm DB Store Access
#
Class Storage=JufGdbm -superclass Storage
Storage=JufGdbm instproc open f {
  my set persistenceDB [juf_gdbm open $f rwc]
}

Storage=JufGdbm instproc store {k v} {
  #my showCall
  juf_gdbm store [my set persistenceDB] $k $v
}

Storage=JufGdbm instproc list {} {
  juf_gdbm list [my set persistenceDB]
}

Storage=JufGdbm instproc fetch {k var} {
  my instvar persistenceDB
  if {[juf_gdbm exists $persistenceDB $k]} {
    upvar [self callinglevel] $var value
    set value [juf_gdbm fetch $persistenceDB $k]
    return 1
  }
  return 0
}

Storage=JufGdbm instproc close args {
  juf_gdbm close [my set persistenceDB]
}

Storage=JufGdbm instproc delete k {
  juf_gdbm delete [my set persistenceDB] $k
}
