VirtualDictionary.st
author Claus Gittinger <cg@exept.de>
Sat, 02 May 2020 21:40:13 +0200
changeset 5476 7355a4b11cb6
parent 5387 64a6ef96c06f
permissions -rw-r--r--
#FEATURE by cg class: Socket class added: #newTCPclientToHost:port:domain:domainOrder:withTimeout: changed: #newTCPclientToHost:port:domain:withTimeout:

"{ Encoding: utf8 }"

"
 COPYRIGHT (c) 2018 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libbasic2' }"

"{ NameSpace: Smalltalk }"

Collection subclass:#VirtualDictionary
	instanceVariableNames:'fetchBlock'
	classVariableNames:''
	poolDictionaries:''
	category:'Collections-Unordered'
!

!VirtualDictionary class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2018 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    a collection which looks like a (read-only) dictionary to the outside,
    but invokes a pluggable fetchBlock to retrieve keys.

    [author:]
        cg

    [instance variables:]

    [class variables:]

    [see also:]

"
! !

!VirtualDictionary methodsFor:'accessing'!

at:aKey
    ^ self at:aKey ifAbsent:nil
!

at:aKey ifAbsent:exceptionValue
    |value|

    value := fetchBlock value:aKey.
    value isNil ifTrue:[
        ^ exceptionValue value
    ].
    ^ value
!

fetchBlock:something
    fetchBlock := something.
! !

!VirtualDictionary methodsFor:'queries'!

includesKey:aKey
    ^ (fetchBlock value:aKey) notNil
! !

!VirtualDictionary class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !