From 347b685b164c0c63257e6d4affc8abee0b3f9197 Mon Sep 17 00:00:00 2001 From: Neal Kruis Date: Mon, 27 May 2024 11:48:33 -0600 Subject: [PATCH 1/2] Make it impossible to not define class_name for Sender class. --- include/courier/helpers.h | 7 +++++-- test/library.h | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/courier/helpers.h b/include/courier/helpers.h index fea3b42..721ebeb 100644 --- a/include/courier/helpers.h +++ b/include/courier/helpers.h @@ -30,9 +30,10 @@ class DefaultCourier : public Courier { class Sender { public: Sender() = default; - explicit Sender(std::string name_in, + explicit Sender(std::string class_name_in, + std::string name_in, const std::shared_ptr& courier_in = std::make_shared()) - : name(std::move(name_in)), courier(courier_in) {}; + : name(std::move(name_in)), courier(courier_in), class_name(std::move(class_name_in)) {}; std::string name; protected: @@ -61,6 +62,8 @@ class Sender { { courier->send_debug(make_message(message)); } + void set_courier(const std::shared_ptr& courier_in) { courier = courier_in; } + std::shared_ptr get_courier() { return courier; }; }; } // namespace Courier diff --git a/test/library.h b/test/library.h index a50106a..fe4ca81 100644 --- a/test/library.h +++ b/test/library.h @@ -11,9 +11,8 @@ class LibraryClass : Courier::Sender { explicit LibraryClass(std::string name_in, const std::shared_ptr& courier_in = std::make_shared()) - : Courier::Sender(std::move(name_in), courier_in) + : Courier::Sender("LibraryClass", std::move(name_in), courier_in) { - class_name = "LibraryClass"; } void generate_debug() { send_debug("Something for the developer happened."); } void generate_info() { send_info("Something you should notice happened."); } From aceb9a606be8ea3986cb54ad0666e06d2e2b9bb5 Mon Sep 17 00:00:00 2001 From: Neal Kruis Date: Mon, 27 May 2024 13:56:41 -0600 Subject: [PATCH 2/2] Make setters/getters public. --- include/courier/helpers.h | 5 +++-- test/library.h | 7 +------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/courier/helpers.h b/include/courier/helpers.h index 721ebeb..be0db27 100644 --- a/include/courier/helpers.h +++ b/include/courier/helpers.h @@ -35,6 +35,9 @@ class Sender { const std::shared_ptr& courier_in = std::make_shared()) : name(std::move(name_in)), courier(courier_in), class_name(std::move(class_name_in)) {}; std::string name; + void set_courier(const std::shared_ptr& courier_in) { courier = courier_in; } + std::shared_ptr get_courier() { return courier; } + void set_parent_pointer(Sender* parent_pointer_in) { parent_pointer = parent_pointer_in; } protected: std::shared_ptr courier; @@ -62,8 +65,6 @@ class Sender { { courier->send_debug(make_message(message)); } - void set_courier(const std::shared_ptr& courier_in) { courier = courier_in; } - std::shared_ptr get_courier() { return courier; }; }; } // namespace Courier diff --git a/test/library.h b/test/library.h index fe4ca81..c8d1b59 100644 --- a/test/library.h +++ b/test/library.h @@ -6,7 +6,7 @@ #include #include -class LibraryClass : Courier::Sender { +class LibraryClass : public Courier::Sender { public: explicit LibraryClass(std::string name_in, const std::shared_ptr& courier_in = @@ -18,9 +18,4 @@ class LibraryClass : Courier::Sender { void generate_info() { send_info("Something you should notice happened."); } void generate_warning() { send_warning("Something unexpected happened."); } void generate_error() { send_error("Something serious happened."); } - void set_courier(std::shared_ptr courier_in) - { - courier = std::move(courier_in); - } - std::shared_ptr get_courier() { return courier; } };