|
@@ -316,4 +316,67 @@ protected:
|
|
};
|
|
};
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+#define DECLARE_STATE_TRANSITION_TYPES(StateMachineClassName) \
|
|
|
|
+ typedef typename StateMachineClassName<Types, Parameters, StateType>::template State<StateMachineClassName<Types, Parameters, StateType>> State_t; \
|
|
|
|
+ typedef typename StateMachineClassName<Types, Parameters, StateType>::template Transition<StateMachineClassName<Types, Parameters, StateType>> Transition_t;
|
|
|
|
+
|
|
|
|
+#define DEFINE_STATE_MACHINE_STATE(StateClassName, StateID, StateMachineClassName) \
|
|
|
|
+ template<class Types, class Parameters, class StateType> \
|
|
|
|
+ struct StateClassName : StateMachineClassName<Types, Parameters, StateType>::State_t { \
|
|
|
|
+ StateClassName(const std::shared_ptr<StateMachineClassName<Types, Parameters, StateType>> &machine) : \
|
|
|
|
+ StateMachineClassName<Types, Parameters, StateType>::State_t(StateID, machine) {} \
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+#define DEFINE_STATE_MACHINE_STATE_WITH_NULL_TA(StateClassName, StateID, StateMachineClassName) \
|
|
|
|
+ template<class Types, class Parameters, class StateType> \
|
|
|
|
+ struct StateClassName : StateMachineClassName<Types, Parameters, StateType>::State_t { \
|
|
|
|
+ StateClassName(const std::shared_ptr<StateMachineClassName<Types, Parameters, StateType>> &machine) : \
|
|
|
|
+ StateMachineClassName<Types, Parameters, StateType>::State_t(StateID, machine) {} \
|
|
|
|
+ artis::traffic::core::Time ta(const artis::traffic::core::Time & /* t */) const override { return 0; }\
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+#define DEFINE_STATE_MACHINE_STATE_WITH_TA(StateClassName, StateID, StateMachineClassName) \
|
|
|
|
+ template<class Types, class Parameters, class StateType> \
|
|
|
|
+ struct StateClassName : StateMachineClassName<Types, Parameters, StateType>::State_t { \
|
|
|
|
+ StateClassName(const std::shared_ptr<StateMachineClassName<Types, Parameters, StateType>> &machine) : \
|
|
|
|
+ StateMachineClassName<Types, Parameters, StateType>::State_t(StateID, machine) {} \
|
|
|
|
+ artis::traffic::core::Time ta(const artis::traffic::core::Time & /* t */) const override; \
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_HEADER(TransitionClassName, StateMachineClassName) \
|
|
|
|
+ template<class Types, class Parameters, class StateType> \
|
|
|
|
+ struct TransitionClassName : StateMachineClassName<Types, Parameters, StateType>::Transition_t { \
|
|
|
|
+ TransitionClassName( \
|
|
|
|
+ const std::shared_ptr<StateMachineClassName<Types, Parameters, StateType>> &machine) : \
|
|
|
|
+ StateMachineClassName<Types, Parameters, StateType>::Transition_t(machine) {}
|
|
|
|
+
|
|
|
|
+#define ATTRIBUTE(Type, Var) Type Var;
|
|
|
|
+
|
|
|
|
+#define NO_ATTRIBUTE
|
|
|
|
+
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_FOOTER(Attribute) \
|
|
|
|
+ Attribute \
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_ACTION_true void action(const artis::traffic::core::Time & /* t */, const artis::common::event::Value & /* value */) override;
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_ACTION_false
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_EVENT_true bool event(const artis::traffic::core::Time & /* t */, int event) override;
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_EVENT_false
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_GUARD_true bool guard(const artis::traffic::core::Time & /* t */) const override;
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_GUARD_false
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_NO_EVENT_true bool no_event() const override { return true; }
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_NO_EVENT_false
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_OUTPUT_true(StateMachineClassName) typename StateMachineClassName<Types, Parameters, StateType>::Events output(const artis::traffic::core::Time & /* t */) const override;
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION_OUTPUT_false(StateMachineClassName)
|
|
|
|
+
|
|
|
|
+#define DEFINE_STATE_MACHINE_TRANSITION(TransitionClassName, StateMachineClassName, Attribute, ActionMethod, EventMethod, GuardMethod, NoEventMethod, OutputMethod) \
|
|
|
|
+ DEFINE_STATE_MACHINE_TRANSITION_HEADER(TransitionClassName, StateMachineClassName) \
|
|
|
|
+ DEFINE_STATE_MACHINE_TRANSITION_ACTION_##ActionMethod \
|
|
|
|
+ DEFINE_STATE_MACHINE_TRANSITION_EVENT_##EventMethod \
|
|
|
|
+ DEFINE_STATE_MACHINE_TRANSITION_GUARD_##GuardMethod \
|
|
|
|
+ DEFINE_STATE_MACHINE_TRANSITION_NO_EVENT_##NoEventMethod \
|
|
|
|
+ DEFINE_STATE_MACHINE_TRANSITION_OUTPUT_##OutputMethod(StateMachineClassName) \
|
|
|
|
+ DEFINE_STATE_MACHINE_TRANSITION_FOOTER(Attribute)
|
|
|
|
+
|
|
#endif //ARTIS_STAR_ADDONS_UTILS_STATE_MACHINE_HPP
|
|
#endif //ARTIS_STAR_ADDONS_UTILS_STATE_MACHINE_HPP
|