Skip to content

Commit

Permalink
Delete copy constructor of simultaneous_options
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Dec 8, 2024
1 parent f9f5111 commit 55cdc5c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
14 changes: 7 additions & 7 deletions src/share/manipulator/manipulators/basic/basic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -333,15 +333,15 @@ 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;

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 {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -583,15 +583,15 @@ 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,
time_stamp_delay,
*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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<simultaneous_options>()) {
}

virtual ~from_event_definition(void) {
Expand All @@ -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<std::shared_ptr<simultaneous_options>>& get_simultaneous_options(void) const {
return simultaneous_options_;
}

void set_simultaneous_options(const simultaneous_options& value) {
void set_simultaneous_options(const gsl::not_null<std::shared_ptr<simultaneous_options>>& value) {
simultaneous_options_ = value;
}

Expand Down Expand Up @@ -143,7 +144,7 @@ class from_event_definition final {
private:
std::vector<event_definition> event_definitions_;
from_modifiers_definition from_modifiers_definition_;
simultaneous_options simultaneous_options_;
gsl::not_null<std::shared_ptr<simultaneous_options>> simultaneous_options_;
};

inline void from_json(const nlohmann::json& json, from_event_definition& d) {
Expand Down Expand Up @@ -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<simultaneous_options>(value));
} catch (const pqrs::json::unmarshal_error& e) {
throw pqrs::json::unmarshal_error(fmt::format("`{0}` error: {1}", key, e.what()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions tests/src/manipulator_basic/src/simultaneous_options_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down

0 comments on commit 55cdc5c

Please sign in to comment.