NameSpace.st
author Claus Gittinger <cg@exept.de>
Sun, 27 Oct 1996 15:54:34 +0100
changeset 1828 92e8ede212e7
parent 1827 fa0017393e3b
child 1901 8eebbd3c7232
permissions -rw-r--r--
checkin from browser

"
 COPYRIGHT (c) 1996 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.
"


Class subclass:#Namespace
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Classes'
!

!Namespace class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1996 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
"
    A Namespace is actually a dummy class, providing a home
    for its private classes. This has two advantages:
        - we only need one mechanism for both namespaces
          and private classes

        - there are no possible conflicts between a class
          and a namespace named alike.


    [author:]
        Claus Gittinger

    [see also:]
        Behavior ClassDescription Class Metaclass
        PrivateMetaclass
"

! !

!Namespace class methodsFor:'instance creation'!

name:aSymbol
    |newNamespace|

    newNamespace := super new.
    newNamespace setName:aSymbol.
    newNamespace category:'* namespaces *'.
    Smalltalk at:aSymbol put:newNamespace.
    Smalltalk changed.
    ^ newNamespace
!

new
    self error:'namespaces are not to be created with new'
! !

!Namespace methodsFor:'accessing'!

at:classNameSymbol
    ^ self privateClassesAt:classNameSymbol
!

at:classNameSymbol ifAbsent:exceptionBlock
    |cls|

    cls := self privateClassesAt:classNameSymbol.
    cls isNil ifTrue:[
        ^ exceptionBlock value
    ].
    ^ cls
!

at:classNameSymbol put:aClass
    ^ self privateClassesAt:classNameSymbol put:aClass
! !

!Namespace methodsFor:'enumerating'!

allBehaviorsDo:aBlock
    self privateClassesDo:aBlock

    "Created: 26.10.1996 / 12:29:01 / cg"
! !

!Namespace methodsFor:'fileOut'!

basicFileOutDefinitionOn:aStream
    aStream nextPutAll:('Namespace name:' , name storeString)
! !

!Namespace methodsFor:'queries'!

isNamespace
    ^ true

    "Created: 26.10.1996 / 11:13:36 / cg"
! !

!Namespace class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.3 1996-10-27 14:54:34 cg Exp $'
! !