-
Notifications
You must be signed in to change notification settings - Fork 0
/
finiteStateMachines.py
1308 lines (969 loc) · 45.9 KB
/
finiteStateMachines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#------------------------------------------------------------------------------
# This code was generated by a tool.
#
# Changes to this file can cause unexpected behaviour
# and get lost when the code gets generated again.
#------------------------------------------------------------------------------
from pyNMF import *
from pyNMF.collections.generic import *
from pyNMF.collections.object_model import *
from pyNMF.serialization import *
"""The default implementation of the FiniteStateMachine class"""
class FiniteStateMachine(ModelElement):
"""type(__id) == str, type(IdChanging) == System.EventHandler, type(IdChanged) == System.EventHandler, type(__states) == ObservableCompositionOrderedSet, type(__transitions) == ObservableCompositionOrderedSet"""
"""The backing field for the Id property"""
@staticmethod
def _typeOfID():
return str
"""The backing field for the States property"""
@staticmethod
def _typeOfSTATES():
return State
"""The backing field for the Transitions property"""
@staticmethod
def _typeOfTRANSITIONS():
return Transition
def __init__(self):
super(FiniteStateMachine, self).__init__()
self._ConstructorFieldInitFunction()
self.__states = ObservableCompositionOrderedSet(self)
self.__states.CollectionChanging += self._StatesCollectionChanging
self.__states.CollectionChanged += self._StatesCollectionChanged
self.__transitions = ObservableCompositionOrderedSet(self)
self.__transitions.CollectionChanging += self._TransitionsCollectionChanging
self.__transitions.CollectionChanged += self._TransitionsCollectionChanged
"""The id property"""
def get_Id(self):
return self.__id
def set_Id(self, value):
if self.__id != value:
old = self.__id
e = ValueChangedEventArgs(old, value)
self.OnIdChanging(e)
self.OnPropertyChanging('Id', e)
self.__id = value
self.OnIdChanged(e)
self.OnPropertyChanged('Id', e)
Id = property(fget=get_Id,fset=set_Id,doc="""The id property""")
"""The states property"""
def get_States(self):
return self.__states
States = property(fget=get_States,doc="""The states property""")
"""The transitions property"""
def get_Transitions(self):
return self.__transitions
Transitions = property(fget=get_Transitions,doc="""The transitions property""")
"""Gets the child model elements of this model element"""
def get_Children(self):
return super(FiniteStateMachine, self).Children.Concat(FiniteStateMachineChildrenCollection(self))
Children = property(fget=get_Children,doc="""Gets the child model elements of this model element""")
"""Gets the referenced model elements of this model element"""
def get_ReferencedElements(self):
return super(FiniteStateMachine, self).ReferencedElements.Concat(FiniteStateMachineReferencedElementsCollection(self))
ReferencedElements = property(fget=get_ReferencedElements,doc="""Gets the referenced model elements of this model element""")
"""Gets a value indicating whether the current model element can be identified by an attribute value"""
def get_IsIdentified(self):
return True
IsIdentified = property(fget=get_IsIdentified,doc="""Gets a value indicating whether the current model element can be identified by an attribute value""")
"""Gets fired before the Id property changes its value"""
"""Gets fired when the Id property changed its value"""
def OnIdChanging(self, eventArgs):
"""
Raises the IdChanging event
:param eventArgs: The event data
"""
handler = self.IdChanging
if handler != None:
handler.Invoke(self, eventArgs)
def OnIdChanged(self, eventArgs):
"""
Raises the IdChanged event
:param eventArgs: The event data
"""
handler = self.IdChanged
if handler != None:
handler.Invoke(self, eventArgs)
def _StatesCollectionChanging(self, sender, e):
"""
Forwards CollectionChanging notifications for the States property to the parent model element
:param sender: The collection that raised the change
:param e: The original event data
"""
self.OnCollectionChanging('States', e)
def _StatesCollectionChanged(self, sender, e):
"""
Forwards CollectionChanged notifications for the States property to the parent model element
:param sender: The collection that raised the change
:param e: The original event data
"""
self.OnCollectionChanged('States', e)
def _TransitionsCollectionChanging(self, sender, e):
"""
Forwards CollectionChanging notifications for the Transitions property to the parent model element
:param sender: The collection that raised the change
:param e: The original event data
"""
self.OnCollectionChanging('Transitions', e)
def _TransitionsCollectionChanged(self, sender, e):
"""
Forwards CollectionChanged notifications for the Transitions property to the parent model element
:param sender: The collection that raised the change
:param e: The original event data
"""
self.OnCollectionChanged('Transitions', e)
def GetRelativePathForNonIdentifiedChild(self, element):
"""
Gets the relative URI fragment for the given child model element
:returns: A fragment of the relative URI
:param element: The element that should be looked for
"""
statesIndex = ModelHelper.IndexOfReference(self.States, element)
if statesIndex != -1:
return ModelHelper.CreatePath('states', statesIndex)
transitionsIndex = ModelHelper.IndexOfReference(self.Transitions, element)
if transitionsIndex != -1:
return ModelHelper.CreatePath('transitions', transitionsIndex)
return super(FiniteStateMachine, self).GetRelativePathForNonIdentifiedChild(element)
def GetModelElementForReference(self, reference, index):
"""
Resolves the given URI to a child model element
:returns: The model element or null if it could not be found
:param reference: The requested reference name
:param index: The index of this reference
"""
if reference == 'STATES':
if index < self.States.Count:
return self.States[index]
else:
return None
if reference == 'TRANSITIONS':
if index < self.Transitions.Count:
return self.Transitions[index]
else:
return None
return super(FiniteStateMachine, self).GetModelElementForReference(reference, index)
def GetAttributeValue(self, attribute, index):
"""
Resolves the given attribute name
:returns: The attribute value or null if it could not be found
:param attribute: The requested attribute name
:param index: The index of this attribute
"""
if attribute == 'ID':
return self.Id
return super(FiniteStateMachine, self).GetAttributeValue(attribute, index)
def GetCollectionForFeature(self, feature):
"""
Gets the Model element collection for the given feature
:returns: A non-generic list of elements
:param feature: The requested feature
"""
if feature == 'STATES':
return self.__states
if feature == 'TRANSITIONS':
return self.__transitions
return super(FiniteStateMachine, self).GetCollectionForFeature(feature)
def SetFeature(self, feature, value):
"""
Sets a value to the given feature
:param feature: The requested feature
:param value: The value that should be set to that feature
"""
if feature == 'ID':
self.Id = value
return
super(FiniteStateMachine, self).SetFeature(feature, value)
def GetCompositionName(self, container):
"""
Gets the property name for the given container
:returns: The name of the respective container reference
:param container: The container object
"""
if container == self.__states:
return 'states'
if container == self.__transitions:
return 'transitions'
return super(FiniteStateMachine, self).GetCompositionName(container)
def ToIdentifierString(self):
"""
Gets the identifier string for this model element
:returns: The identifier string
"""
if self.Id is None:
return None
return str(self.Id)
def CreateUriWithFragment(self, fragment, absolute, baseElement):
return self.CreateUriFromGlobalIdentifier(fragment, absolute)
def PropagateNewModel(self, newModel, oldModel, subtreeRoot):
id = self.ToIdentifierString()
if oldModel != None:
oldModel.UnregisterId(id)
if newModel != None:
newModel.RegisterId(id, self)
super(FiniteStateMachine, self).PropagateNewModel(newModel, oldModel, subtreeRoot)
class FiniteStateMachineChildrenCollection(ReferenceCollection,CollectionExpression,Collection):
"""type(__parent) == FiniteStateMachine"""
@staticmethod
def _typeOfPARENT():
return FiniteStateMachine
def __init__(self, parent):
super(FiniteStateMachineChildrenCollection, self).__init__()
self._ConstructorFieldInitFunction()
self.__parent = parent
"""Gets the amount of elements contained in this collection"""
def get_Count(self):
count = 0
count = count + self.__parent.States.Count
count = count + self.__parent.Transitions.Count
return count
Count = property(fget=get_Count,doc="""Gets the amount of elements contained in this collection""")
def AttachCore(self):
self.__parent.States.AsNotifiable().CollectionChanged += self.PropagateCollectionChanges
self.__parent.Transitions.AsNotifiable().CollectionChanged += self.PropagateCollectionChanges
def DetachCore(self):
self.__parent.States.AsNotifiable().CollectionChanged -= self.PropagateCollectionChanges
self.__parent.Transitions.AsNotifiable().CollectionChanged -= self.PropagateCollectionChanges
def Add(self, item):
"""
Adds the given element to the collection
:param item: The item to add
"""
statesCasted = item.As()
if statesCasted != None:
self.__parent.States.Add(statesCasted)
transitionsCasted = item.As()
if transitionsCasted != None:
self.__parent.Transitions.Add(transitionsCasted)
def Clear(self):
"""Clears the collection and resets all references that implement it."""
self.__parent.States.Clear()
self.__parent.Transitions.Clear()
def Contains(self, item):
"""
Gets a value indicating whether the given element is contained in the collection
:returns: True, if it is contained, otherwise False
:param item: The item that should be looked out for
"""
if self.__parent.States.Contains(item):
return True
if self.__parent.Transitions.Contains(item):
return True
return False
def CopyTo(self, array, arrayIndex):
"""
Copies the contents of the collection to the given array starting from the given array index
:param array: The array in which the elements should be copied
:param arrayIndex: The starting index
"""
statesEnumerator = self.__parent.States.GetEnumerator()
try:
# Snippet Statement
# End Snippet Statement
while statesEnumerator.MoveNext():
array[arrayIndex] = statesEnumerator.Current
arrayIndex = arrayIndex + 1
# Snippet Statement
# End Snippet Statement
finally:
statesEnumerator.Dispose()
transitionsEnumerator = self.__parent.Transitions.GetEnumerator()
try:
# Snippet Statement
# End Snippet Statement
while transitionsEnumerator.MoveNext():
array[arrayIndex] = transitionsEnumerator.Current
arrayIndex = arrayIndex + 1
# Snippet Statement
# End Snippet Statement
finally:
transitionsEnumerator.Dispose()
def Remove(self, item):
"""
Removes the given item from the collection
:returns: True, if the item was removed, otherwise False
:param item: The item that should be removed
"""
stateItem = item.As()
if stateItem != None and self.__parent.States.Remove(stateItem):
return True
transitionItem = item.As()
if transitionItem != None and self.__parent.Transitions.Remove(transitionItem):
return True
return False
def GetEnumerator(self):
"""
Gets an enumerator that enumerates the collection
:returns: A generic enumerator
"""
return Enumerable.Empty().Concat(self.__parent.States).Concat(self.__parent.Transitions).GetEnumerator()
def _ConstructorFieldInitFunction(self):
self.__parent = None
class FiniteStateMachineReferencedElementsCollection(ReferenceCollection,CollectionExpression,Collection):
"""type(__parent) == FiniteStateMachine"""
@staticmethod
def _typeOfPARENT():
return FiniteStateMachine
def __init__(self, parent):
super(FiniteStateMachineReferencedElementsCollection, self).__init__()
self._ConstructorFieldInitFunction()
self.__parent = parent
"""Gets the amount of elements contained in this collection"""
def get_Count(self):
count = 0
count = count + self.__parent.States.Count
count = count + self.__parent.Transitions.Count
return count
Count = property(fget=get_Count,doc="""Gets the amount of elements contained in this collection""")
def AttachCore(self):
self.__parent.States.AsNotifiable().CollectionChanged += self.PropagateCollectionChanges
self.__parent.Transitions.AsNotifiable().CollectionChanged += self.PropagateCollectionChanges
def DetachCore(self):
self.__parent.States.AsNotifiable().CollectionChanged -= self.PropagateCollectionChanges
self.__parent.Transitions.AsNotifiable().CollectionChanged -= self.PropagateCollectionChanges
def Add(self, item):
"""
Adds the given element to the collection
:param item: The item to add
"""
statesCasted = item.As()
if statesCasted != None:
self.__parent.States.Add(statesCasted)
transitionsCasted = item.As()
if transitionsCasted != None:
self.__parent.Transitions.Add(transitionsCasted)
def Clear(self):
"""Clears the collection and resets all references that implement it."""
self.__parent.States.Clear()
self.__parent.Transitions.Clear()
def Contains(self, item):
"""
Gets a value indicating whether the given element is contained in the collection
:returns: True, if it is contained, otherwise False
:param item: The item that should be looked out for
"""
if self.__parent.States.Contains(item):
return True
if self.__parent.Transitions.Contains(item):
return True
return False
def CopyTo(self, array, arrayIndex):
"""
Copies the contents of the collection to the given array starting from the given array index
:param array: The array in which the elements should be copied
:param arrayIndex: The starting index
"""
statesEnumerator = self.__parent.States.GetEnumerator()
try:
# Snippet Statement
# End Snippet Statement
while statesEnumerator.MoveNext():
array[arrayIndex] = statesEnumerator.Current
arrayIndex = arrayIndex + 1
# Snippet Statement
# End Snippet Statement
finally:
statesEnumerator.Dispose()
transitionsEnumerator = self.__parent.Transitions.GetEnumerator()
try:
# Snippet Statement
# End Snippet Statement
while transitionsEnumerator.MoveNext():
array[arrayIndex] = transitionsEnumerator.Current
arrayIndex = arrayIndex + 1
# Snippet Statement
# End Snippet Statement
finally:
transitionsEnumerator.Dispose()
def Remove(self, item):
"""
Removes the given item from the collection
:returns: True, if the item was removed, otherwise False
:param item: The item that should be removed
"""
stateItem = item.As()
if stateItem != None and self.__parent.States.Remove(stateItem):
return True
transitionItem = item.As()
if transitionItem != None and self.__parent.Transitions.Remove(transitionItem):
return True
return False
def GetEnumerator(self):
"""
Gets an enumerator that enumerates the collection
:returns: A generic enumerator
"""
return Enumerable.Empty().Concat(self.__parent.States).Concat(self.__parent.Transitions).GetEnumerator()
def _ConstructorFieldInitFunction(self):
self.__parent = None
def _ConstructorFieldInitFunction(self):
self.__id = None
self.IdChanging = EventHandler()
self.IdChanged = EventHandler()
self.__states = None
self.__transitions = None
class State(ModelElement):
"""type(__isEndState) == bool, type(IsEndStateChanging) == System.EventHandler, type(IsEndStateChanged) == System.EventHandler, type(__isStartState) == bool, type(IsStartStateChanging) == System.EventHandler, type(IsStartStateChanged) == System.EventHandler, type(__name) == str, type(NameChanging) == System.EventHandler, type(NameChanged) == System.EventHandler, type(__transitions) == StateTransitionsCollection"""
"""The backing field for the IsEndState property"""
@staticmethod
def _typeOfISENDSTATE():
return bool
"""The backing field for the IsStartState property"""
@staticmethod
def _typeOfISSTARTSTATE():
return bool
"""The backing field for the Name property"""
@staticmethod
def _typeOfNAME():
return str
"""The backing field for the Transitions property"""
@staticmethod
def _typeOfTRANSITIONS():
return Transition
def __init__(self):
super(State, self).__init__()
self._ConstructorFieldInitFunction()
self.__transitions = StateTransitionsCollection(self)
self.__transitions.CollectionChanging += self._TransitionsCollectionChanging
self.__transitions.CollectionChanged += self._TransitionsCollectionChanged
"""The isEndState property"""
def get_IsEndState(self):
return self.__isEndState
def set_IsEndState(self, value):
if self.__isEndState != value:
old = self.__isEndState
e = ValueChangedEventArgs(old, value)
self.OnIsEndStateChanging(e)
self.OnPropertyChanging('IsEndState', e)
self.__isEndState = value
self.OnIsEndStateChanged(e)
self.OnPropertyChanged('IsEndState', e)
IsEndState = property(fget=get_IsEndState,fset=set_IsEndState,doc="""The isEndState property""")
"""The isStartState property"""
def get_IsStartState(self):
return self.__isStartState
def set_IsStartState(self, value):
if self.__isStartState != value:
old = self.__isStartState
e = ValueChangedEventArgs(old, value)
self.OnIsStartStateChanging(e)
self.OnPropertyChanging('IsStartState', e)
self.__isStartState = value
self.OnIsStartStateChanged(e)
self.OnPropertyChanged('IsStartState', e)
IsStartState = property(fget=get_IsStartState,fset=set_IsStartState,doc="""The isStartState property""")
"""The name property"""
def get_Name(self):
return self.__name
def set_Name(self, value):
if self.__name != value:
old = self.__name
e = ValueChangedEventArgs(old, value)
self.OnNameChanging(e)
self.OnPropertyChanging('Name', e)
self.__name = value
self.OnNameChanged(e)
self.OnPropertyChanged('Name', e)
Name = property(fget=get_Name,fset=set_Name,doc="""The name property""")
"""The transitions property"""
def get_Transitions(self):
return self.__transitions
Transitions = property(fget=get_Transitions,doc="""The transitions property""")
"""Gets the referenced model elements of this model element"""
def get_ReferencedElements(self):
return super(State, self).ReferencedElements.Concat(StateReferencedElementsCollection(self))
ReferencedElements = property(fget=get_ReferencedElements,doc="""Gets the referenced model elements of this model element""")
"""Gets a value indicating whether the current model element can be identified by an attribute value"""
def get_IsIdentified(self):
return True
IsIdentified = property(fget=get_IsIdentified,doc="""Gets a value indicating whether the current model element can be identified by an attribute value""")
"""Gets fired before the IsEndState property changes its value"""
"""Gets fired when the IsEndState property changed its value"""
"""Gets fired before the IsStartState property changes its value"""
"""Gets fired when the IsStartState property changed its value"""
"""Gets fired before the Name property changes its value"""
"""Gets fired when the Name property changed its value"""
def OnIsEndStateChanging(self, eventArgs):
"""
Raises the IsEndStateChanging event
:param eventArgs: The event data
"""
handler = self.IsEndStateChanging
if handler != None:
handler.Invoke(self, eventArgs)
def OnIsEndStateChanged(self, eventArgs):
"""
Raises the IsEndStateChanged event
:param eventArgs: The event data
"""
handler = self.IsEndStateChanged
if handler != None:
handler.Invoke(self, eventArgs)
def OnIsStartStateChanging(self, eventArgs):
"""
Raises the IsStartStateChanging event
:param eventArgs: The event data
"""
handler = self.IsStartStateChanging
if handler != None:
handler.Invoke(self, eventArgs)
def OnIsStartStateChanged(self, eventArgs):
"""
Raises the IsStartStateChanged event
:param eventArgs: The event data
"""
handler = self.IsStartStateChanged
if handler != None:
handler.Invoke(self, eventArgs)
def OnNameChanging(self, eventArgs):
"""
Raises the NameChanging event
:param eventArgs: The event data
"""
handler = self.NameChanging
if handler != None:
handler.Invoke(self, eventArgs)
def OnNameChanged(self, eventArgs):
"""
Raises the NameChanged event
:param eventArgs: The event data
"""
handler = self.NameChanged
if handler != None:
handler.Invoke(self, eventArgs)
def _TransitionsCollectionChanging(self, sender, e):
"""
Forwards CollectionChanging notifications for the Transitions property to the parent model element
:param sender: The collection that raised the change
:param e: The original event data
"""
self.OnCollectionChanging('Transitions', e)
def _TransitionsCollectionChanged(self, sender, e):
"""
Forwards CollectionChanged notifications for the Transitions property to the parent model element
:param sender: The collection that raised the change
:param e: The original event data
"""
self.OnCollectionChanged('Transitions', e)
def GetAttributeValue(self, attribute, index):
"""
Resolves the given attribute name
:returns: The attribute value or null if it could not be found
:param attribute: The requested attribute name
:param index: The index of this attribute
"""
if attribute == 'ISENDSTATE':
return self.IsEndState
if attribute == 'ISSTARTSTATE':
return self.IsStartState
if attribute == 'NAME':
return self.Name
return super(State, self).GetAttributeValue(attribute, index)
def GetCollectionForFeature(self, feature):
"""
Gets the Model element collection for the given feature
:returns: A non-generic list of elements
:param feature: The requested feature
"""
if feature == 'TRANSITIONS':
return self.__transitions
return super(State, self).GetCollectionForFeature(feature)
def SetFeature(self, feature, value):
"""
Sets a value to the given feature
:param feature: The requested feature
:param value: The value that should be set to that feature
"""
if feature == 'ISENDSTATE':
self.IsEndState = value
return
if feature == 'ISSTARTSTATE':
self.IsStartState = value
return
if feature == 'NAME':
self.Name = value
return
super(State, self).SetFeature(feature, value)
def ToIdentifierString(self):
"""
Gets the identifier string for this model element
:returns: The identifier string
"""
if self.Name is None:
return None
return str(self.Name)
def CreateUriWithFragment(self, fragment, absolute, baseElement):
return self.CreateUriFromGlobalIdentifier(fragment, absolute)
def PropagateNewModel(self, newModel, oldModel, subtreeRoot):
id = self.ToIdentifierString()
if oldModel != None:
oldModel.UnregisterId(id)
if newModel != None:
newModel.RegisterId(id, self)
super(State, self).PropagateNewModel(newModel, oldModel, subtreeRoot)
class StateReferencedElementsCollection(ReferenceCollection,CollectionExpression,Collection):
"""type(__parent) == State"""
@staticmethod
def _typeOfPARENT():
return State
def __init__(self, parent):
super(StateReferencedElementsCollection, self).__init__()
self._ConstructorFieldInitFunction()
self.__parent = parent
"""Gets the amount of elements contained in this collection"""
def get_Count(self):
count = 0
count = count + self.__parent.Transitions.Count
return count
Count = property(fget=get_Count,doc="""Gets the amount of elements contained in this collection""")
def AttachCore(self):
self.__parent.Transitions.AsNotifiable().CollectionChanged += self.PropagateCollectionChanges
def DetachCore(self):
self.__parent.Transitions.AsNotifiable().CollectionChanged -= self.PropagateCollectionChanges
def Add(self, item):
"""
Adds the given element to the collection
:param item: The item to add
"""
transitionsCasted = item.As()
if transitionsCasted != None:
self.__parent.Transitions.Add(transitionsCasted)
def Clear(self):
"""Clears the collection and resets all references that implement it."""
self.__parent.Transitions.Clear()
def Contains(self, item):
"""
Gets a value indicating whether the given element is contained in the collection
:returns: True, if it is contained, otherwise False
:param item: The item that should be looked out for
"""
if self.__parent.Transitions.Contains(item):
return True
return False
def CopyTo(self, array, arrayIndex):
"""
Copies the contents of the collection to the given array starting from the given array index
:param array: The array in which the elements should be copied
:param arrayIndex: The starting index
"""
transitionsEnumerator = self.__parent.Transitions.GetEnumerator()
try:
# Snippet Statement
# End Snippet Statement
while transitionsEnumerator.MoveNext():
array[arrayIndex] = transitionsEnumerator.Current
arrayIndex = arrayIndex + 1
# Snippet Statement
# End Snippet Statement
finally:
transitionsEnumerator.Dispose()
def Remove(self, item):
"""
Removes the given item from the collection
:returns: True, if the item was removed, otherwise False
:param item: The item that should be removed
"""
transitionItem = item.As()
if transitionItem != None and self.__parent.Transitions.Remove(transitionItem):
return True
return False
def GetEnumerator(self):
"""
Gets an enumerator that enumerates the collection
:returns: A generic enumerator
"""
return Enumerable.Empty().Concat(self.__parent.Transitions).GetEnumerator()
def _ConstructorFieldInitFunction(self):
self.__parent = None
def _ConstructorFieldInitFunction(self):
self.__isEndState = False
self.IsEndStateChanging = EventHandler()
self.IsEndStateChanged = EventHandler()
self.__isStartState = False
self.IsStartStateChanging = EventHandler()
self.IsStartStateChanged = EventHandler()
self.__name = None
self.NameChanging = EventHandler()
self.NameChanged = EventHandler()
self.__transitions = None
class Transition(ModelElement):
"""type(__input) == str, type(InputChanging) == System.EventHandler, type(InputChanged) == System.EventHandler, type(__startState) == State, type(StartStateChanging) == System.EventHandler, type(StartStateChanged) == System.EventHandler, type(__endState) == State, type(EndStateChanging) == System.EventHandler, type(EndStateChanged) == System.EventHandler"""
"""The backing field for the Input property"""
@staticmethod
def _typeOfINPUT():
return str
"""The backing field for the StartState property"""
@staticmethod
def _typeOfSTARTSTATE():
return State
"""The backing field for the EndState property"""
@staticmethod
def _typeOfENDSTATE():
return State
def __init__(self):
super(Transition, self).__init__()
self._ConstructorFieldInitFunction()
super(Transition, self).__init__()
"""The input property"""
def get_Input(self):
return self.__input
def set_Input(self, value):
if self.__input != value:
old = self.__input
e = ValueChangedEventArgs(old, value)
self.OnInputChanging(e)
self.OnPropertyChanging('Input', e)
self.__input = value
self.OnInputChanged(e)
self.OnPropertyChanged('Input', e)
Input = property(fget=get_Input,fset=set_Input,doc="""The input property""")
"""The startState property"""
def get_StartState(self):
return self.__startState
def set_StartState(self, value):
if self.__startState != value:
old = self.__startState
e = ValueChangedEventArgs(old, value)
self.OnStartStateChanging(e)
self.OnPropertyChanging('StartState', e)
self.__startState = value
if old != None:
old.Transitions.Remove(self)
old.Deleted -= self._OnResetStartState
if value != None:
value.Transitions.Add(self)
value.Deleted += self._OnResetStartState
self.OnStartStateChanged(e)
self.OnPropertyChanged('StartState', e)
StartState = property(fget=get_StartState,fset=set_StartState,doc="""The startState property""")
"""The endState property"""
def get_EndState(self):
return self.__endState
def set_EndState(self, value):