Skip to content

Commit

Permalink
Delete copy constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jun 10, 2024
1 parent bd177d7 commit 79a001f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/share/core_configuration/configuration_json_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace configuration_json_helper {
class base_t {
public:
virtual ~base_t() = default;
virtual const std::string& get_key(void) const = 0;
virtual void update_value(const nlohmann::json& json) = 0;
virtual void update_json(nlohmann::json& json) const = 0;
};
Expand All @@ -24,6 +25,14 @@ class value_t final : public base_t {
default_value_(default_value) {
}

const std::string& get_key(void) const override {
return key_;
}

T& get_value(void) const {
return value_;
}

void update_value(const nlohmann::json& json) override {
if (auto v = pqrs::json::find<T>(json, key_)) {
value_ = *v;
Expand Down Expand Up @@ -53,6 +62,10 @@ class object_t final : public base_t {
value_(value) {
}

const std::string& get_key(void) const override {
return key_;
}

void update_value(const nlohmann::json& json) override {
if (auto v = pqrs::json::find_object(json, key_)) {
value_ = std::make_unique<T>(v->value());
Expand Down
12 changes: 6 additions & 6 deletions src/share/core_configuration/core_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class core_configuration final {
: json_(nlohmann::json::object()),
loaded_(false),
global_configuration_(std::make_unique<details::global_configuration>(nlohmann::json::object())),
machine_specific_(nlohmann::json::object()) {
machine_specific_(std::make_unique<details::machine_specific>(nlohmann::json::object())) {
helper_values_.push_back(std::make_unique<configuration_json_helper::object_t<details::global_configuration>>("global",
global_configuration_));

Expand Down Expand Up @@ -67,7 +67,7 @@ class core_configuration final {
}

if (auto v = pqrs::json::find_object(json_, "machine_specific")) {
machine_specific_ = details::machine_specific(v->value());
machine_specific_ = std::make_unique<details::machine_specific>(v->value());
}

if (auto v = pqrs::json::find_array(json_, "profiles")) {
Expand Down Expand Up @@ -104,7 +104,7 @@ class core_configuration final {
}

{
auto j = machine_specific_.to_json();
auto j = machine_specific_->to_json();
if (!j.empty()) {
json["machine_specific"] = j;
} else {
Expand All @@ -127,10 +127,10 @@ class core_configuration final {
}

const details::machine_specific& get_machine_specific(void) const {
return machine_specific_;
return *machine_specific_;
}
details::machine_specific& get_machine_specific(void) {
return machine_specific_;
return *machine_specific_;
}

const std::vector<details::profile>& get_profiles(void) const {
Expand Down Expand Up @@ -267,7 +267,7 @@ class core_configuration final {
bool loaded_;

std::unique_ptr<details::global_configuration> global_configuration_;
details::machine_specific machine_specific_;
std::unique_ptr<details::machine_specific> machine_specific_;
std::vector<details::profile> profiles_;
std::vector<std::unique_ptr<configuration_json_helper::base_t>> helper_values_;
};
Expand Down
4 changes: 4 additions & 0 deletions src/share/core_configuration/details/machine_specific.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class machine_specific final {
public:
static constexpr bool enable_multitouch_extension_default_value = false;

entry(const entry&) = delete;

entry(const nlohmann::json& json)
: json_(json),
enable_multitouch_extension_(enable_multitouch_extension_default_value) {
Expand Down Expand Up @@ -50,6 +52,8 @@ class machine_specific final {
std::vector<std::unique_ptr<configuration_json_helper::base_t>> helper_values_;
};

machine_specific(const machine_specific&) = delete;

machine_specific(const nlohmann::json& json)
: json_(json) {
pqrs::json::requires_object(json, "json");
Expand Down

0 comments on commit 79a001f

Please sign in to comment.