InEventLifeCycle.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef INEVENTLIFECYCLE_H_
  2. #define INEVENTLIFECYCLE_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'InEventLifeCycle'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. InEventLifeCycle_last_state,
  13. InEventLifeCycle_main_region_A
  14. } InEventLifeCycleStates;
  15. /*! Type definition of the data structure for the InEventLifeCycleIface interface scope. */
  16. typedef struct
  17. {
  18. sc_boolean e_raised;
  19. sc_integer i;
  20. } InEventLifeCycleIface;
  21. /*! Define dimension of the state configuration vector for orthogonal states. */
  22. #define INEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES 1
  23. /*! Define indices of states in the StateConfVector */
  24. #define SCVI_INEVENTLIFECYCLE_MAIN_REGION_A 0
  25. /*!
  26. * Type definition of the data structure for the InEventLifeCycle state machine.
  27. * This data structure has to be allocated by the client code.
  28. */
  29. typedef struct
  30. {
  31. InEventLifeCycleStates stateConfVector[INEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES];
  32. sc_ushort stateConfVectorPosition;
  33. InEventLifeCycleIface iface;
  34. } InEventLifeCycle;
  35. /*! Initializes the InEventLifeCycle state machine data structures. Must be called before first usage.*/
  36. extern void inEventLifeCycle_init(InEventLifeCycle* handle);
  37. /*! Activates the state machine */
  38. extern void inEventLifeCycle_enter(InEventLifeCycle* handle);
  39. /*! Deactivates the state machine */
  40. extern void inEventLifeCycle_exit(InEventLifeCycle* handle);
  41. /*! Performs a 'run to completion' step. */
  42. extern void inEventLifeCycle_runCycle(InEventLifeCycle* handle);
  43. /*! Raises the in event 'e' that is defined in the default interface scope. */
  44. extern void inEventLifeCycleIface_raise_e(InEventLifeCycle* handle);
  45. /*! Gets the value of the variable 'i' that is defined in the default interface scope. */
  46. extern sc_integer inEventLifeCycleIface_get_i(const InEventLifeCycle* handle);
  47. /*! Sets the value of the variable 'i' that is defined in the default interface scope. */
  48. extern void inEventLifeCycleIface_set_i(InEventLifeCycle* handle, sc_integer value);
  49. /*!
  50. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  51. * A state machine is active if it was entered. It is inactive if it has not been entered at all or if it has been exited.
  52. */
  53. extern sc_boolean inEventLifeCycle_isActive(const InEventLifeCycle* handle);
  54. /*!
  55. * Checks if all active states are final.
  56. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  57. */
  58. extern sc_boolean inEventLifeCycle_isFinal(const InEventLifeCycle* handle);
  59. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  60. extern sc_boolean inEventLifeCycle_isStateActive(const InEventLifeCycle* handle, InEventLifeCycleStates state);
  61. #ifdef __cplusplus
  62. }
  63. #endif
  64. #endif /* INEVENTLIFECYCLE_H_ */