From b49ce7201565e5e842091efafcd5d45f7d9e8f29 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Fri, 15 Mar 2019 17:06:04 +0900 Subject: [PATCH] Make AbstractItem::GetType as abstract method Change-Id: Id7ed489921a33f594ee75d89208eacf9a6872549 Signed-off-by: Junghoon Park --- notification-ex/abstract_action.cc | 5 ++--- notification-ex/abstract_action.h | 6 +++--- notification-ex/abstract_item.cc | 28 ++++++++++---------------- notification-ex/abstract_item.h | 16 +++++++-------- notification-ex/abstract_item_implementation.h | 10 ++++----- notification-ex/app_control_action.cc | 2 +- notification-ex/app_control_action.h | 2 +- notification-ex/button_item.cc | 13 +++++++----- notification-ex/button_item.h | 1 + notification-ex/chat_message_item.cc | 9 ++++++--- notification-ex/chat_message_item.h | 3 ++- notification-ex/checkbox_item.cc | 7 +++++-- notification-ex/checkbox_item.h | 1 + notification-ex/default_action_factory.cc | 4 +--- notification-ex/default_action_factory.h | 3 +-- notification-ex/default_item_factory.cc | 2 +- notification-ex/default_item_factory.h | 2 +- notification-ex/entry_item.cc | 8 ++++++-- notification-ex/entry_item.h | 1 + notification-ex/factory_manager.cc | 6 ++---- notification-ex/factory_manager.h | 4 ++-- notification-ex/group_item.cc | 8 ++++++-- notification-ex/group_item.h | 1 + notification-ex/iaction_factory.h | 3 +-- notification-ex/icon_item.cc | 4 ++++ notification-ex/icon_item.h | 1 + notification-ex/icon_text_item.cc | 6 +++++- notification-ex/icon_text_item.h | 2 ++ notification-ex/iitem_factory.h | 2 +- notification-ex/image_item.cc | 8 ++++++-- notification-ex/image_item.h | 1 + notification-ex/input_selector_item.cc | 8 ++++++-- notification-ex/input_selector_item.h | 1 + notification-ex/null_item.cc | 8 ++++++-- notification-ex/null_item.h | 9 ++++----- notification-ex/progress_item.cc | 8 ++++++-- notification-ex/progress_item.h | 1 + notification-ex/text_item.cc | 7 +++++-- notification-ex/text_item.h | 2 +- notification-ex/time_item.cc | 10 ++++++--- notification-ex/time_item.h | 2 +- notification-ex/visibility_action.cc | 2 +- notification-ex/visibility_action.h | 2 +- unittest/src/test_chat_message_item.cc | 4 ++-- 44 files changed, 138 insertions(+), 95 deletions(-) diff --git a/notification-ex/abstract_action.cc b/notification-ex/abstract_action.cc index a52414e..7b9ec9e 100644 --- a/notification-ex/abstract_action.cc +++ b/notification-ex/abstract_action.cc @@ -51,9 +51,8 @@ AbstractAction::Impl::Impl(AbstractAction* parent, bool isLocal, AbstractAction::~AbstractAction() = default; AbstractAction::Impl::~Impl() = default; -AbstractAction::Type AbstractAction::GetType(Bundle b) { - return static_cast( - std::stoi(b.GetString(ABSTRACT_ACTION_TYPE_KEY))); +int AbstractAction::GetType(Bundle b) { + return std::stoi(b.GetString(ABSTRACT_ACTION_TYPE_KEY)); } Bundle AbstractAction::Serialize() { diff --git a/notification-ex/abstract_action.h b/notification-ex/abstract_action.h index 7a6f393..cb1063d 100644 --- a/notification-ex/abstract_action.h +++ b/notification-ex/abstract_action.h @@ -36,7 +36,7 @@ class EXPORT_API AbstractAction { NullObject, AppControl, Visibility, - Custom, + Custom = 100 }; public: @@ -44,8 +44,8 @@ class EXPORT_API AbstractAction { AbstractAction(bool isLocal, std::string extra); virtual ~AbstractAction(); - virtual Type GetType() const = 0; - static Type GetType(Bundle b); + virtual int GetType() const = 0; + static int GetType(Bundle b); virtual Bundle Serialize() = 0; virtual void Deserialize(Bundle b) = 0; virtual bool IsLocal() const = 0; diff --git a/notification-ex/abstract_item.cc b/notification-ex/abstract_item.cc index c6397a2..3aad57d 100644 --- a/notification-ex/abstract_item.cc +++ b/notification-ex/abstract_item.cc @@ -36,25 +36,24 @@ using namespace std; namespace notification { namespace item { -AbstractItem::AbstractItem(AbstractItem::Type type, - std::shared_ptr action) - : impl_(new Impl(this, type, action)) { +AbstractItem::AbstractItem(std::shared_ptr action) + : impl_(new Impl(this, action)) { } -AbstractItem::AbstractItem(std::string id, AbstractItem::Type type, +AbstractItem::AbstractItem(std::string id, std::shared_ptr action) - : impl_(new Impl(this, id, type, action)) { + : impl_(new Impl(this, id, action)) { } AbstractItem::Impl::Impl(AbstractItem* parent, string id, - AbstractItem::Type type, std::shared_ptr action) - : id_(id), type_(type), action_(action), parent_(parent) { + std::shared_ptr action) + : id_(id), action_(action), parent_(parent) { LOGI("GroupItem created"); } AbstractItem::Impl::Impl(AbstractItem* parent, - AbstractItem::Type type, std::shared_ptr action) - : type_(type), action_(action), parent_(parent) { + std::shared_ptr action) + : action_(action), parent_(parent) { LOGI("GroupItem created"); } @@ -62,7 +61,7 @@ AbstractItem::~AbstractItem() = default; Bundle AbstractItem::Serialize() { Bundle b; - b.Add(ABSTRACT_ITEM_TYPE_KEY, to_string((int)impl_->type_)); + b.Add(ABSTRACT_ITEM_TYPE_KEY, to_string(GetType())); b.Add(ABSTRACT_ITEM_ID_KEY, impl_->id_); return b; } @@ -74,7 +73,6 @@ void AbstractItem::Deserialize(Bundle b) { string id_str = b.GetString(ABSTRACT_ITEM_ID_KEY); impl_->id_ = id_str; - impl_->type_ = static_cast(strtol(type_str.c_str(), NULL, 10)); } string AbstractItem::GetId() const { @@ -101,15 +99,11 @@ std::shared_ptr AbstractItem::GetLEDInfo() const { return impl_->led_; } -AbstractItem::Type AbstractItem::GetType() const { - return impl_->type_; -} - -AbstractItem::Type AbstractItem::GetType(Bundle b) { +int AbstractItem::GetType(Bundle b) { string type_str = b.GetString(ABSTRACT_ITEM_TYPE_KEY); if (type_str.empty()) THROW(NOTIFICATION_ERROR_IO_ERROR); - return static_cast(strtol(type_str.c_str(), NULL, 10)); + return strtol(type_str.c_str(), NULL, 10); } void AbstractItem::SetVisible(bool visible) { diff --git a/notification-ex/abstract_item.h b/notification-ex/abstract_item.h index 4895eed..8f9f8de 100644 --- a/notification-ex/abstract_item.h +++ b/notification-ex/abstract_item.h @@ -180,7 +180,7 @@ class EXPORT_API AbstractItem { Entry, Progress, Time, - Custom, + Custom = 100 }; enum Policy { @@ -190,24 +190,22 @@ class EXPORT_API AbstractItem { }; public: - AbstractItem(); - AbstractItem(Type type, - std::shared_ptr action = std::shared_ptr({})); - AbstractItem(std::string id, Type type, - std::shared_ptr action = std::shared_ptr({})); + AbstractItem(std::shared_ptr action = + std::shared_ptr({})); + AbstractItem(std::string id, std::shared_ptr action = + std::shared_ptr({})); virtual ~AbstractItem() = 0; - virtual Bundle Serialize() = 0; virtual void Deserialize(Bundle b) = 0; virtual AbstractItem& FindByID(std::string id) = 0; + virtual int GetType() const = 0; + static int GetType(Bundle b); std::string GetId() const; void SetId(std::string id); std::shared_ptr GetAction() const; void SetAction(std::shared_ptr action) const; std::shared_ptr