#pragma once /* MOUNT CONTROL COMPONENTS LIBRARY */ #include #include #include namespace mcc { enum class MccMountType : uint8_t { GERMAN_TYPE, FORK_TYPE, CROSSAXIS_TYPE, ALTAZ_TYPE }; // mount state type concept template concept mcc_mount_state_c = requires(T t, const T t_const) { typename T::state_id_t; { t.ident() } -> std::same_as; typename T::context_t; { t.enter(std::declval()) } -> std::same_as; { t.exit(std::declval()) } -> std::same_as; }; // implements a Finite State Machine Pattern template class MccMount { public: static constexpr MccMountType mountType = MOUNT_TYPE; MccMount() { _exitCurrentState = []() {}; // do nothing } virtual ~MccMount() {} template void setMountState(StateT& state) { _exitCurrentState(); // exit from current state _exitCurrentState = [&state, this]() { state.exit(this); }; state.enter(this); } protected: std::function _exitCurrentState; }; } // namespace mcc