PackageId.st
author Claus Gittinger <cg@exept.de>
Fri, 18 Aug 2006 13:07:30 +0200
changeset 9577 03cce2fb9e0a
parent 9571 01355270af5c
child 9668 aa1d5186bd46
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 2006 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:libbasic3' }"

Object subclass:#PackageId
	instanceVariableNames:'packageIdString'
	classVariableNames:''
	poolDictionaries:''
	category:'System-Support-Projects'
!

!PackageId class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2006 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
"
    Represents packageID's.
    Knows the relationship between modules and directories in the package-organization.
"
! !

!PackageId class methodsFor:'instance creation'!

from: aStringOrSymbol
    ^ self new packageIdString:aStringOrSymbol

    "Created: / 18-08-2006 / 12:11:58 / cg"
! !

!PackageId methodsFor:'accessing'!

packageIdString:something
    packageIdString := something.

    "Created: / 18-08-2006 / 12:14:45 / cg"
!

string
    ^ packageIdString

    "Created: / 18-08-2006 / 12:20:54 / cg"
! !

!PackageId methodsFor:'comparing'!

= aPackageId
    ^ packageIdString = aPackageId asPackageId string

    "
     'stx:libbasic' asPackageId = 'stx:libbasic' asSymbol asPackageId  
     'stx:libbasic' asPackageId = 'stx:libbasic' asPackageId    
     'stx:libbasic2' asPackageId = 'stx:libbasic3' asPackageId  
    "

    "Created: / 18-08-2006 / 12:20:47 / cg"
!

hash
    ^ packageIdString hash

    "Created: / 18-08-2006 / 12:21:19 / cg"
! !

!PackageId methodsFor:'converting'!

asPackageId
    ^ self

    "Created: / 18-08-2006 / 12:22:10 / cg"
!

asString
    ^ packageIdString

    "Created: / 18-08-2006 / 12:12:22 / cg"
!

asSymbol
    ^ packageIdString asSymbol

    "Created: / 18-08-2006 / 12:12:29 / cg"
! !

!PackageId methodsFor:'queries'!

directory
    "return the directory component. Thats the rest after the colon.
     The module is typically used to define the project-path or project-id within its
     sourcecode repository (which is selected via the module)."

    ^ packageIdString copyFrom:(packageIdString indexOf:$:)+1

    "
     (PackageId from:'stx:libbasic') module  
     (PackageId from:'stx:libbasic') directory  
     (PackageId from:'stx:goodies/xml/stx') module  
     (PackageId from:'stx:goodies/xml/stx') directory  
    "

    "Created: / 18-08-2006 / 12:15:33 / cg"
!

libraryName
    "return the name of the library, when compiled to a binary (i.e. dll/so).
     To avoid conflicts with the projectDefinition class 
     (which is named <module>_<directory_components>), we prefix the library name
     with 'lib'. This has the added advantage, that under unix, linking can be done with
     '-l'shortName."

    ^ 'lib' , (packageIdString copy asString replaceAny:':/' with:$_)

    "
     (PackageId from:'stx:libbasic') libraryName        
     (PackageId from:'stx:goodies/xml/stx') libraryName   
     (PackageId from:'bosch:dapasx') libraryName  
     (PackageId from:'exept:expecco') libraryName  
    "

    "Created: / 18-08-2006 / 12:35:04 / cg"
!

module
    "return the module component. Thats the first component up to the colon.
     The module is typically used to select a corresponding sourcecode repository."

    ^ packageIdString upTo:$:

    "
     (PackageId from:'stx:libbasic') module  
     (PackageId from:'stx:libbasic') directory  
    "

    "Created: / 18-08-2006 / 12:13:53 / cg"
! !

!PackageId class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/PackageId.st,v 1.2 2006-08-18 11:07:30 cg Exp $'
! !