IStatemachine.xtend 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. Copyright (c) 2012 committers of YAKINDU and others.
  3. All rights reserved. This program and the accompanying materials
  4. are made available under the terms of the Eclipse Public License v1.0
  5. which accompanies this distribution, and is available at
  6. http://www.eclipse.org/legal/epl-v10.html
  7. Contributors:
  8. Markus Muehlbrandt - Initial contribution and API
  9. */
  10. package org.yakindu.sct.generator.csharp
  11. import org.yakindu.sct.model.sexec.ExecutionFlow
  12. import org.yakindu.sct.model.sgen.GeneratorEntry
  13. import org.eclipse.xtext.generator.IFileSystemAccess
  14. import com.google.inject.Inject
  15. class IStatemachine {
  16. @Inject
  17. extension Naming
  18. @Inject
  19. extension GenmodelEntries
  20. def generateIStatemachine(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
  21. fsa.generateFile(entry.basePackagePath + '/' + iStatemachine.csharp, content(entry))
  22. }
  23. def private content(GeneratorEntry entry) {
  24. '''
  25. «entry.licenseText»
  26. namespace «entry.getNamespaceName()»
  27. {
  28. /**
  29. * Basic interface for statemachines.
  30. */
  31. public interface IStatemachine {
  32. /**
  33. * Initializes the statemachine. Use to init internal variables etc.
  34. */
  35. void init();
  36. /**
  37. * Enters the statemachine. Sets the statemachine in a defined state.
  38. */
  39. void enter();
  40. /**
  41. * Exits the statemachine. Leaves the statemachine with a defined state.
  42. */
  43. void exit();
  44. /**
  45. * Checks if the statemachine is active.
  46. * A statemachine is active if it was entered. It is inactive if it has not been entered at all or if it was exited.
  47. */
  48. bool isActive();
  49. /**
  50. * Checks if all active states are final.
  51. * If there are no active states then the statemachine is considered as incative and this method returns false.
  52. */
  53. bool isFinal();
  54. /**
  55. * Start a run-to-completion cycle.
  56. */
  57. void runCycle();
  58. }
  59. }
  60. '''
  61. }
  62. }