SRuntime.xcore 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. @GenModel(copyrightText="Copyright (c) 2018 committers of YAKINDU and others.\r\nAll rights reserved. This program and the accompanying materials\r\nare made available under the terms of the Eclipse Public License v1.0\r\nwhich accompanies this distribution, and is available at\r\nhttp://www.eclipse.org/legal/epl-v10.html\r\nContributors:\r\ncommitters of YAKINDU - initial API and implementation\r\n",
  2. operationReflection="false", prefix="SRuntime", modelDirectory="/org.yakindu.sct.model.sruntime/emf-gen",
  3. suppressEMFTypes="true", importerID="org.eclipse.emf.importer.ecore", publicConstructors="true",
  4. interfaceNamePattern="", dataTypeConverters="true")
  5. @Ecore(nsURI="http://www.yakindu.org/sct/sruntime/2.0.0")
  6. package org.yakindu.sct.model.sruntime
  7. import com.google.common.collect.Lists
  8. import org.eclipse.core.runtime.Assert
  9. import org.eclipse.emf.common.util.BasicEList
  10. import org.eclipse.emf.ecore.EObject
  11. import org.yakindu.base.base.NamedElement
  12. import org.yakindu.base.types.Direction
  13. import org.yakindu.base.types.Type
  14. /**
  15. *
  16. * @author andreas muelder - Initial contribution and API
  17. *
  18. */
  19. class ExecutionContext extends NamedElement, CompositeSlot {
  20. refers EObject[] activeStates
  21. refers EObject[] executedElements
  22. refers EObject[] suspendedElements
  23. boolean snapshot
  24. op unique ExecutionEvent[] getRaisedEvents() {
  25. return allEvents.filter[raised].toList
  26. }
  27. op ExecutionVariable getVariable(String qualifiedName) {
  28. Assert.isNotNull(qualifiedName);
  29. allVariables.findFirst[qualifiedName == it.fqName]
  30. }
  31. op ExecutionEvent getEvent(String qualifiedName) {
  32. Assert.isNotNull(qualifiedName);
  33. allEvents.findFirst[qualifiedName == it.fqName]
  34. }
  35. op ExecutionSlot getSlot(String qualifiedName) {
  36. Assert.isNotNull(qualifiedName);
  37. allSlots.findFirst[qualifiedName == it.fqName]
  38. }
  39. op unique ExecutionEvent[] getAllEvents() {
  40. allSlots.filter(ExecutionEvent).toList
  41. }
  42. op unique ExecutionVariable[] getAllVariables() {
  43. allSlots.filter(ExecutionVariable).toList
  44. }
  45. op unique ExecutionSlot[] getAllSlots() {
  46. var result = new BasicEList<ExecutionSlot>
  47. addSlots(result, slots, Lists.newArrayList)
  48. result
  49. }
  50. op void addSlots(ExecutionSlot[] result, ExecutionSlot[] slots, unique ExecutionSlot[] visited) {
  51. slots.forEach [
  52. if (visited.add(it)) {
  53. result.add(it)
  54. if (it instanceof CompositeSlot) {
  55. addSlots(result, it.slots, visited)
  56. }
  57. }
  58. ]
  59. }
  60. }
  61. class ExecutionEvent extends ExecutionSlot {
  62. boolean raised
  63. Direction direction
  64. }
  65. abstract class ExecutionSlot extends NamedElement {
  66. JavaObject value
  67. String fqName
  68. boolean writable = "true"
  69. refers Type ^type
  70. }
  71. class ExecutionVariable extends ExecutionSlot {
  72. }
  73. class CompositeSlot extends ExecutionSlot {
  74. contains ExecutionSlot[] slots
  75. }
  76. class ReferenceSlot extends CompositeSlot {
  77. refers ExecutionSlot reference
  78. }
  79. class ExecutionOperation extends ExecutionVariable {
  80. }
  81. type JavaObject wraps Object