GDBMAContainer.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 23 Nov 2017 22:51:20 +0000
changeset 91 472a4841a8b6
parent 89 ba62d486014f
child 126 fb73b0af430b
permissions -rw-r--r--
License this package under 'GNU Lesser General Public License'

"
jv:libgdbs - GNU Debugger Interface Library
Copyright (C) 2015-now Jan Vrany

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License. 

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
"
"{ Package: 'jv:libgdbs' }"

"{ NameSpace: Smalltalk }"

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

!GDBMAContainer class methodsFor:'documentation'!

copyright
"
jv:libgdbs - GNU Debugger Interface Library
Copyright (C) 2015-now Jan Vrany

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License. 

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
"
! !

!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.
    ^ description

    "Created: / 23-09-2014 / 22:20:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 12-11-2017 / 17:20:50 / 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.
    ^ description.

    "Created: / 23-09-2014 / 22:54:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 12-11-2017 / 17:19:47 / 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>"
! !