Skip to content

Commit

Permalink
Reworked serialization extensions and format names
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Jul 25, 2024
1 parent 702728a commit fbac6dd
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 111 deletions.
9 changes: 4 additions & 5 deletions repository/OpenPonk-FSM/OPFsmController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ OPFsmController >> commonModelClassPrefix [

{ #category : 'accessing' }
OPFsmController >> controllerFactory [

^ super controllerFactory
register: OPFsmInitialStateController forModel: OPFsmInitialState;
register: OPFsmStateController forModel: OPFsmState;
register: OPFsmTransitionController forModel: OPFsmTransition;
register: OPFsmTransitionController
forModel: OPFsmIncomingTransition
register: OPFsmInitialStateController forModel: OPFsmInitialState;
register: OPFsmStateController forModel: OPFsmState;
register: OPFsmTransitionController forModel: OPFsmTransition
]

{ #category : 'accessing' }
Expand Down
66 changes: 5 additions & 61 deletions repository/OpenPonk-FSM/OPFsmIncomingTransition.class.st
Original file line number Diff line number Diff line change
@@ -1,75 +1,19 @@
Class {
#name : 'OPFsmIncomingTransition',
#superclass : 'Object',
#instVars : [
'transition'
],
#superclass : 'OPFsmTransition',
#category : 'OpenPonk-FSM-Adapters',
#package : 'OpenPonk-FSM',
#tag : 'Adapters'
}

{ #category : 'instance creation' }
OPFsmIncomingTransition class >> of: aTransition [
^ self ofTransition: aTransition
]

{ #category : 'instance creation' }
OPFsmIncomingTransition class >> ofTransition: aTransition [
^ self new
transition: aTransition;
yourself
]

{ #category : 'comparing' }
OPFsmIncomingTransition >> = otherTransition [
^ self represents: otherTransition
]

{ #category : 'converting' }
OPFsmIncomingTransition >> asTransition [
^ transition
]

{ #category : 'printing' }
OPFsmIncomingTransition >> changed [
^ transition changed
]

{ #category : 'reflective operations' }
OPFsmIncomingTransition >> doesNotUnderstand: aMessage [
^ aMessage sendTo: transition
]

{ #category : 'comparing' }
OPFsmIncomingTransition >> hash [
^ transition hash
]

{ #category : 'testing' }
OPFsmIncomingTransition >> isTransition [
OPFsmIncomingTransition class >> isDeprecated [

^ true
]

{ #category : 'printing' }
OPFsmIncomingTransition >> printOn: aStream [
^ transition printOn: aStream
]

{ #category : 'comparing' }
OPFsmIncomingTransition >> represents: otherTransition [

^ super = otherTransition or: [
transition == otherTransition or: [ transition = otherTransition ] ]
]

{ #category : 'accessing' }
OPFsmIncomingTransition >> transition: aTransition [
transition := aTransition
]
{ #category : 'instance creation' }
OPFsmIncomingTransition class >> new [

{ #category : 'printing' }
OPFsmIncomingTransition >> when: anAnnouncementClass send: aSelector to: anObject [
^ transition when: anAnnouncementClass send: aSelector to: anObject
^ self superclass new
]
19 changes: 19 additions & 0 deletions repository/OpenPonk-FSM/OPFsmModelDeprecatedSerializer.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Class {
#name : 'OPFsmModelDeprecatedSerializer',
#superclass : 'OPFsmModelSerializer',
#category : 'OpenPonk-FSM-Serialization',
#package : 'OpenPonk-FSM',
#tag : 'Serialization'
}

{ #category : 'as yet unclassified' }
OPFsmModelDeprecatedSerializer class >> fileExtension [

^ #ston
]

{ #category : 'as yet unclassified' }
OPFsmModelDeprecatedSerializer class >> formatName [

^ #'graphml-ston'
]
22 changes: 9 additions & 13 deletions repository/OpenPonk-FSM/OPFsmModelSerializer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ OPFsmModelSerializer class >> exportVersion [
^ 1
]

{ #category : 'formatting' }
{ #category : 'as yet unclassified' }
OPFsmModelSerializer class >> fileExtension [

^ #xml
]

{ #category : 'as yet unclassified' }
OPFsmModelSerializer class >> formatName [

^ #'graphml-ston'
^ #graphml
]

{ #category : 'accessing' }
Expand All @@ -24,11 +30,6 @@ OPFsmModelSerializer class >> minImportVersion [
^ 1
]

{ #category : 'accessing' }
OPFsmModelSerializer >> formatName [
^ 'ston'
]

{ #category : 'serialize/materialize' }
OPFsmModelSerializer >> materializeModelFrom: aStream [
^ self materializeModelFromString: aStream contents
Expand All @@ -39,17 +40,12 @@ OPFsmModelSerializer >> materializeModelFromString: aString [
^ OPFsmGraphML new import: aString
]

{ #category : 'accessing' }
OPFsmModelSerializer >> modelExtension [
^ 'graphml'
]

{ #category : 'serialize/materialize' }
OPFsmModelSerializer >> serializeModel: aModel [
^ OPFsmGraphML new export: aModel
]

{ #category : 'accessing' }
{ #category : 'serialize/materialize' }
OPFsmModelSerializer >> serializeModel: aModel to: aStream [
^ aStream << (self serializeModel: aModel)
]
61 changes: 29 additions & 32 deletions repository/OpenPonk-FSM/OPFsmNavigatorAdapter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,50 +21,46 @@ OPFsmNavigatorAdapter class >> priority [

{ #category : 'widget API' }
OPFsmNavigatorAdapter >> childrenMapping [
^ {(OPFsm -> #states).
(OPFsmVertex
-> [ :o |
o outgoing
, (o incoming collect: [ :each | OPFsmIncomingTransition of: each ]) ]).
(OPFsmIncomingTransition -> #()).
(OPFsmTransition -> #())}

^ {
(OPFsm -> #states).
(OPFsmVertex -> [ :o | o incoming , o outgoing ]).
(OPFsmTransition -> #( )) }
]

{ #category : 'widget API' }
OPFsmNavigatorAdapter >> displayMapping [
^ {(OPFsm -> 'Diagram').
(OPFsmInitialState -> 'Initial State').
(OPFsmState
-> [ :o |
o isNormal
ifTrue: [ 'State' ]
ifFalse: [ 'Final State' ] ]).
(OPFsmTransition -> 'Transition').
(OPFsmIncomingTransition -> 'Incoming transition')}

^ {
(OPFsm -> 'Diagram').
(OPFsmInitialState -> 'Initial State').
(OPFsmState -> [ :o |
o isNormal
ifTrue: [ 'State' ]
ifFalse: [ 'Final State' ] ]).
(OPFsmTransition -> 'Transition') }
]

{ #category : 'testing' }
OPFsmNavigatorAdapter >> hasMappingFor: anObject in: aModel [

^ {
^ {
OPFsm.
OPFsmTransition.
OPFsmIncomingTransition.
OPFsmVertex } anySatisfy: [ :any | anObject isKindOf: any ]
]

{ #category : 'widget API' }
OPFsmNavigatorAdapter >> iconMapping [
^ {(OPFsm -> OPCoreIcons opFsmDiagramIcon).
(OPFsmInitialState -> OPCoreIcons opFsmInitialStateIcon).
(OPFsmIncomingTransition
-> OPCoreIcons opFsmFlippedTransitionIcon).
(OPFsmTransition -> OPCoreIcons opFsmTransitionIcon).
(OPFsmState
-> [ :o |
o isNormal
ifTrue: [ OPCoreIcons opFsmRegularStateIcon ]
ifFalse: [ OPCoreIcons opFsmFinalStateIcon ] ])}

^ {
(OPFsm -> OPCoreIcons opFsmDiagramIcon).
(OPFsmInitialState -> OPCoreIcons opFsmInitialStateIcon).
(OPFsmTransition -> OPCoreIcons opFsmTransitionIcon).
(OPFsmState -> [ :o |
o isNormal
ifTrue: [ OPCoreIcons opFsmRegularStateIcon ]
ifFalse: [ OPCoreIcons opFsmFinalStateIcon ] ]) }
]

{ #category : 'private' }
Expand All @@ -76,8 +72,9 @@ OPFsmNavigatorAdapter >> sort: modelObjects [

{ #category : 'widget API' }
OPFsmNavigatorAdapter >> typesByDependency [
^ {OPFsm.
OPFsmVertex.
OPFsmTransition.
OPFsmIncomingTransition}

^ {
OPFsm.
OPFsmVertex.
OPFsmTransition }
]

0 comments on commit fbac6dd

Please sign in to comment.