GDBMAContainer.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 26 May 2017 08:05:28 +0100
changeset 78 c24e7d8bc881
parent 45 deb908479a37
child 89 ba62d486014f
permissions -rw-r--r--
BUpdated build files.

"{ Package: 'jv:libgdbs' }"

"{ NameSpace: Smalltalk }"

Magritte::MAContainer subclass:#GDBMAContainer
	instanceVariableNames:'klass'
	classVariableNames:''
	poolDictionaries:''
	category:'GDB-Support'
!

!GDBMAContainer class methodsFor:'instance creation'!

forClass: aClass
    ^ self new  
        klass:aClass;
        yourself

    "Created: / 23-09-2014 / 22:36:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBMAContainer class methodsFor:'testing'!

isAbstract
    ^ false

    "Created: / 23-09-2014 / 22:38:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBMAContainer methodsFor:'accessing'!

klass
    ^ klass
!

klass:something
    klass := something.
!

propertyDescriptorAt: name
    ^ children detect:[:each | (each accessor isKindOf: GDBMAPropertyAccessor) and:[ each accessor name = name ] ] ifNone:nil

    "Created: / 23-09-2014 / 22:50:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBMAContainer methodsFor:'adding-easy shortcuts'!

define: property as: class
    "/ Handle primitive types furst...

    | description |

    class == Boolean ifTrue:[ 
        description := Magritte::MABooleanDescription new.
    ] ifFalse:[
    class == Integer ifTrue:[ 
        description := Magritte::MANumberDescription new
    ] ifFalse:[
    class == String ifTrue:[ 
        description := Magritte::MAStringDescription new
    ] ifFalse:[
        description := class description. 
    ]]].
    description accessor: (GDBMAPropertyAccessor forPropertyNamed: property).

    self add: description.

    "Created: / 23-09-2014 / 22:20:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

define: property as: cclass of: class
    "/ Handle primitive types furst...

    | description |

    class == Boolean ifTrue:[ 
        description := Magritte::MAToManyScalarRelationDescription new
        description reference: Magritte::MABooleanDescription new.      
    ] ifFalse:[
    class == Integer ifTrue:[ 
        description := Magritte::MAToManyScalarRelationDescription new.
        description reference: Magritte::MANumberDescription new.
    ] ifFalse:[
    class == String ifTrue:[
        description := Magritte::MAToManyScalarRelationDescription new.
        description reference: Magritte::MAStringDescription new.
    ] ifFalse:[
        description := Magritte::MAToManyRelationDescription new.
        description reference: class description.
    ]]].
    description accessor: (GDBMAPropertyAccessor forPropertyNamed: property).       
    description classes: (Array with: class).
    description ordered: (cclass inheritsFrom: SequenceableCollection).

    self add: description.

    "Created: / 23-09-2014 / 22:54:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBMAContainer methodsFor:'parsing-GDB/MI'!

parseUsingGDBMIParser:aGDBMIParser
    ^ aGDBMIParser parseValueAsInstanceOf: klass describedBy: self.

    "Created: / 23-09-2014 / 22:32:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !