ValModel.st
author Claus Gittinger <cg@exept.de>
Mon, 28 Jul 1997 12:43:53 +0200
changeset 673 5e342b1ebe45
parent 504 b77cdd860259
child 773 b6337f784d05
permissions -rw-r--r--
added #booleanAspectFor: as a code-saver

"
 COPYRIGHT (c) 1995 by Claus Gittinger
	      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.
"

Model subclass:#ValueModel
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Support-Models'
!

!ValueModel class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1995 by Claus Gittinger
	      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
"
    abstract superclass for ValueHolders and Adaptors.
    It does not itself know how and where the value is stored,
    but knows about interested objects (which get informed, whenever
    the value changes) and keeps track if the value was ever accepted.

    Notice: 
        this class was implemented using protocol information
        from alpha testers - it may not be complete or compatible to
        the corresponding ST-80 class. 
        If you encounter any incompatibilities, please forward a note 
        describing the incompatibility verbal (i.e. no code) to the ST/X team.

    subclasses must redefine: #setValue: and #value
    (and optionally redefine #value:)

    [author:]
        Claus Gittinger
"
! !

!ValueModel class methodsFor:'instance creation'!

new
    ^ (super new) initialize
! !

!ValueModel methodsFor:'accessing'!

setValue:newValue 
    "physically set my value, without change notifications"

    ^ self subclassResponsibility
!

value 
    "return my value"

    ^ self subclassResponsibility
!

value:newValue
    "set my value & send change notifications to my dependents
     if it changed."

    |oldValue|

    oldValue := self value.
    oldValue ~~ newValue ifTrue:[
        self setValue:newValue.
        self changed:#value
    ]

    "Modified: 27.3.1997 / 15:14:04 / cg"
! !

!ValueModel methodsFor:'converting'!

compute:aBlock
    "return a BlockValue on the receiver, which computes aBlock"

    ^ BlockValue with:aBlock arguments:(Array with:self)
! !

!ValueModel methodsFor:'initialization'!

initialize

    "Modified: 21.2.1997 / 16:29:38 / cg"
! !

!ValueModel class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/Attic/ValModel.st,v 1.21 1997-03-27 14:14:10 cg Exp $'
! !