diff --git a/src/share/manipulator/manipulators/basic/basic.hpp b/src/share/manipulator/manipulators/basic/basic.hpp index b7e4f690a..fe58796b5 100644 --- a/src/share/manipulator/manipulators/basic/basic.hpp +++ b/src/share/manipulator/manipulators/basic/basic.hpp @@ -276,7 +276,7 @@ class basic final : public base, public pqrs::dispatcher::extra::dispatcher_clie } else { // Do not manipulate if another event arrived. - if (!from_.get_simultaneous_options().get_detect_key_down_uninterruptedly()) { + if (!from_.get_simultaneous_options()->get_detect_key_down_uninterruptedly()) { if (!all_from_events_found(from_events)) { is_target = false; } @@ -324,7 +324,7 @@ class basic final : public base, public pqrs::dispatcher::extra::dispatcher_clie if (is_target) { if (!from_event_definition::test_key_order(ordered_key_down_events, - from_.get_simultaneous_options().get_key_down_order(), + from_.get_simultaneous_options()->get_key_down_order(), from_.get_event_definitions())) { is_target = false; } @@ -333,7 +333,7 @@ class basic final : public base, public pqrs::dispatcher::extra::dispatcher_clie bool needs_wait_key_up = false; if (is_target) { - switch (from_.get_simultaneous_options().get_key_up_order()) { + switch (from_.get_simultaneous_options()->get_key_up_order()) { case simultaneous_options::key_order::insensitive: // Do nothing break; @@ -341,7 +341,7 @@ class basic final : public base, public pqrs::dispatcher::extra::dispatcher_clie case simultaneous_options::key_order::strict: case simultaneous_options::key_order::strict_inverse: if (!from_event_definition::test_key_order(ordered_key_up_events, - from_.get_simultaneous_options().get_key_up_order(), + from_.get_simultaneous_options()->get_key_up_order(), from_.get_event_definitions())) { is_target = false; } else { @@ -475,7 +475,7 @@ class basic final : public base, public pqrs::dispatcher::extra::dispatcher_clie case event_type::key_up: { bool skip = false; - switch (from_.get_simultaneous_options().get_key_up_when()) { + switch (from_.get_simultaneous_options()->get_key_up_when()) { case simultaneous_options::key_up_when::any: break; @@ -583,7 +583,7 @@ class basic final : public base, public pqrs::dispatcher::extra::dispatcher_clie // simultaneous_options.to_after_key_up_ - if (!from_.get_simultaneous_options().get_to_after_key_up().empty()) { + if (!from_.get_simultaneous_options()->get_to_after_key_up().empty()) { if (current_manipulated_original_event->get_from_events().empty()) { event_sender::post_from_mandatory_modifiers_key_up(front_input_event, *current_manipulated_original_event, @@ -591,7 +591,7 @@ class basic final : public base, public pqrs::dispatcher::extra::dispatcher_clie *output_event_queue); event_sender::post_extra_to_events(front_input_event, - from_.get_simultaneous_options().get_to_after_key_up(), + from_.get_simultaneous_options()->get_to_after_key_up(), *current_manipulated_original_event, time_stamp_delay, *output_event_queue); diff --git a/src/share/manipulator/manipulators/basic/from_event_definition.hpp b/src/share/manipulator/manipulators/basic/from_event_definition.hpp index 2ef9ee9e7..9d93acff7 100644 --- a/src/share/manipulator/manipulators/basic/from_event_definition.hpp +++ b/src/share/manipulator/manipulators/basic/from_event_definition.hpp @@ -12,7 +12,8 @@ namespace manipulators { namespace basic { class from_event_definition final { public: - from_event_definition(void) { + from_event_definition(void) + : simultaneous_options_(std::make_shared()) { } virtual ~from_event_definition(void) { @@ -34,11 +35,11 @@ class from_event_definition final { from_modifiers_definition_ = value; } - const simultaneous_options& get_simultaneous_options(void) const { + const gsl::not_null>& get_simultaneous_options(void) const { return simultaneous_options_; } - void set_simultaneous_options(const simultaneous_options& value) { + void set_simultaneous_options(const gsl::not_null>& value) { simultaneous_options_ = value; } @@ -143,7 +144,7 @@ class from_event_definition final { private: std::vector event_definitions_; from_modifiers_definition from_modifiers_definition_; - simultaneous_options simultaneous_options_; + gsl::not_null> simultaneous_options_; }; inline void from_json(const nlohmann::json& json, from_event_definition& d) { @@ -192,7 +193,7 @@ inline void from_json(const nlohmann::json& json, from_event_definition& d) { } else if (key == "simultaneous_options") { try { - d.set_simultaneous_options(simultaneous_options(value)); + d.set_simultaneous_options(std::make_shared(value)); } catch (const pqrs::json::unmarshal_error& e) { throw pqrs::json::unmarshal_error(fmt::format("`{0}` error: {1}", key, e.what())); } diff --git a/src/share/manipulator/manipulators/basic/simultaneous_options.hpp b/src/share/manipulator/manipulators/basic/simultaneous_options.hpp index 7f36602ab..8e5e3e26e 100644 --- a/src/share/manipulator/manipulators/basic/simultaneous_options.hpp +++ b/src/share/manipulator/manipulators/basic/simultaneous_options.hpp @@ -21,6 +21,8 @@ class simultaneous_options final { all, }; + simultaneous_options(const simultaneous_options&) = delete; + simultaneous_options(void) : detect_key_down_uninterruptedly_(false), key_down_order_(key_order::insensitive), key_up_order_(key_order::insensitive), diff --git a/tests/src/manipulator_basic/src/simultaneous_options_test.hpp b/tests/src/manipulator_basic/src/simultaneous_options_test.hpp index 084d40ed1..6691b844b 100644 --- a/tests/src/manipulator_basic/src/simultaneous_options_test.hpp +++ b/tests/src/manipulator_basic/src/simultaneous_options_test.hpp @@ -22,10 +22,10 @@ void run_simultaneous_options_test(void) { })}, })); - expect(event_definition.get_simultaneous_options().get_detect_key_down_uninterruptedly() == true); - expect(event_definition.get_simultaneous_options().get_key_down_order() == basic::simultaneous_options::key_order::strict); - expect(event_definition.get_simultaneous_options().get_key_up_order() == basic::simultaneous_options::key_order::strict_inverse); - expect(event_definition.get_simultaneous_options().get_key_up_when() == basic::simultaneous_options::key_up_when::all); + expect(event_definition.get_simultaneous_options()->get_detect_key_down_uninterruptedly() == true); + expect(event_definition.get_simultaneous_options()->get_key_down_order() == basic::simultaneous_options::key_order::strict); + expect(event_definition.get_simultaneous_options()->get_key_up_order() == basic::simultaneous_options::key_order::strict_inverse); + expect(event_definition.get_simultaneous_options()->get_key_up_when() == basic::simultaneous_options::key_up_when::all); } };