Make AbstractItem::GetType as abstract method 25/201525/6
authorJunghoon Park <jh9216.park@samsung.com>
Fri, 15 Mar 2019 08:06:04 +0000 (17:06 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Mon, 18 Mar 2019 06:26:11 +0000 (15:26 +0900)
Change-Id: Id7ed489921a33f594ee75d89208eacf9a6872549
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
44 files changed:
notification-ex/abstract_action.cc
notification-ex/abstract_action.h
notification-ex/abstract_item.cc
notification-ex/abstract_item.h
notification-ex/abstract_item_implementation.h
notification-ex/app_control_action.cc
notification-ex/app_control_action.h
notification-ex/button_item.cc
notification-ex/button_item.h
notification-ex/chat_message_item.cc
notification-ex/chat_message_item.h
notification-ex/checkbox_item.cc
notification-ex/checkbox_item.h
notification-ex/default_action_factory.cc
notification-ex/default_action_factory.h
notification-ex/default_item_factory.cc
notification-ex/default_item_factory.h
notification-ex/entry_item.cc
notification-ex/entry_item.h
notification-ex/factory_manager.cc
notification-ex/factory_manager.h
notification-ex/group_item.cc
notification-ex/group_item.h
notification-ex/iaction_factory.h
notification-ex/icon_item.cc
notification-ex/icon_item.h
notification-ex/icon_text_item.cc
notification-ex/icon_text_item.h
notification-ex/iitem_factory.h
notification-ex/image_item.cc
notification-ex/image_item.h
notification-ex/input_selector_item.cc
notification-ex/input_selector_item.h
notification-ex/null_item.cc
notification-ex/null_item.h
notification-ex/progress_item.cc
notification-ex/progress_item.h
notification-ex/text_item.cc
notification-ex/text_item.h
notification-ex/time_item.cc
notification-ex/time_item.h
notification-ex/visibility_action.cc
notification-ex/visibility_action.h
unittest/src/test_chat_message_item.cc

index a52414e..7b9ec9e 100644 (file)
@@ -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<AbstractAction::Type>(
-      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() {
index 7a6f393..cb1063d 100644 (file)
@@ -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;
index c6397a2..3aad57d 100644 (file)
@@ -36,25 +36,24 @@ using namespace std;
 namespace notification {
 namespace item {
 
-AbstractItem::AbstractItem(AbstractItem::Type type,
-    std::shared_ptr<AbstractAction> action)
-  : impl_(new Impl(this, type, action)) {
+AbstractItem::AbstractItem(std::shared_ptr<AbstractAction> action)
+    : impl_(new Impl(this, action)) {
 }
 
-AbstractItem::AbstractItem(std::string id, AbstractItem::Type type,
+AbstractItem::AbstractItem(std::string id,
     std::shared_ptr<AbstractAction> 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<AbstractAction> action)
-  : id_(id), type_(type), action_(action), parent_(parent) {
+    std::shared_ptr<AbstractAction> action)
+    : id_(id), action_(action), parent_(parent) {
   LOGI("GroupItem created");
 }
 
 AbstractItem::Impl::Impl(AbstractItem* parent,
-    AbstractItem::Type type, std::shared_ptr<AbstractAction> action)
-  : type_(type), action_(action), parent_(parent) {
+    std::shared_ptr<AbstractAction> 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<AbstractItem::Type>(strtol(type_str.c_str(), NULL, 10));
 }
 
 string AbstractItem::GetId() const {
@@ -101,15 +99,11 @@ std::shared_ptr<LEDInfo> 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<AbstractItem::Type>(strtol(type_str.c_str(), NULL, 10));
+  return strtol(type_str.c_str(), NULL, 10);
 }
 
 void AbstractItem::SetVisible(bool visible) {
index 4895eed..8f9f8de 100644 (file)
@@ -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<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
-  AbstractItem(std::string id, Type type,
-      std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+  AbstractItem(std::shared_ptr<AbstractAction> action =
+      std::shared_ptr<AbstractAction>({}));
+  AbstractItem(std::string id, std::shared_ptr<AbstractAction> action =
+      std::shared_ptr<AbstractAction>({}));
   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<AbstractAction> GetAction() const;
   void SetAction(std::shared_ptr<AbstractAction> action) const;
   std::shared_ptr<Style> GetStyle() const;
   void SetStyle(std::shared_ptr<Style> style);
-  Type GetType() const;
-  static AbstractItem::Type GetType(Bundle b);
   void SetVisible(bool visible);
   void SetEnable(bool enable);
   void AddReceiver(std::string receiver_group);
index 8a030f0..23a7ed4 100644 (file)
@@ -32,10 +32,11 @@ class AbstractItem::Impl {
 
  private:
   Impl(AbstractItem* parent);
-  Impl(AbstractItem* parent, AbstractItem::Type type,
-      std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
-  Impl(AbstractItem* parent, std::string id, AbstractItem::Type type,
-      std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+  Impl(AbstractItem* parent, std::shared_ptr<AbstractAction> action =
+      std::shared_ptr<AbstractAction>({}));
+  Impl(AbstractItem* parent, std::string id,
+      std::shared_ptr<AbstractAction> action =
+          std::shared_ptr<AbstractAction>({}));
 
  private:
   friend class AbstractItem;
@@ -45,7 +46,6 @@ class AbstractItem::Impl {
   std::shared_ptr<LEDInfo> led_ = nullptr;
   Policy policy_ = None;
   std::shared_ptr<Style> style_ = nullptr;
-  AbstractItem::Type type_;
   bool visible_ = true;
   bool enable_ = true;
   int version_ = 1;
index 14ae7e1..df2ec90 100644 (file)
@@ -56,7 +56,7 @@ AppControlAction::Impl::~Impl() {
     app_control_destroy(control_);
 }
 
-AbstractAction::Type AppControlAction::GetType() const {
+int AppControlAction::GetType() const {
   return AbstractAction::AppControl;
 }
 
index afd643d..0839eb0 100644 (file)
@@ -30,7 +30,7 @@ class EXPORT_API AppControlAction : public AbstractAction {
   AppControlAction(app_control_h app_control, std::string extra);
   virtual ~AppControlAction();
 
-  AbstractAction::Type GetType() const override;
+  int GetType() const override;
   Bundle Serialize() override;
   void Deserialize(Bundle b) override;
   bool IsLocal() const override;
index 0ac2858..284b806 100644 (file)
@@ -33,14 +33,13 @@ using namespace std;
 namespace notification {
 namespace item {
 
-ButtonItem::ButtonItem(string title,
-      std::shared_ptr<AbstractAction> action)
-  : AbstractItem(AbstractItem::Button, action), impl_(new Impl(this, title)) {
+ButtonItem::ButtonItem(string title, std::shared_ptr<AbstractAction> action)
+    : AbstractItem(action), impl_(new Impl(this, title)) {
 }
 
 ButtonItem::ButtonItem(string id, string title,
-      std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::Button, action), impl_(new Impl(this, title)) {
+    std::shared_ptr<AbstractAction> action)
+    : AbstractItem(id, action), impl_(new Impl(this, title)) {
 }
 
 ButtonItem::~ButtonItem() = default;
@@ -51,6 +50,10 @@ ButtonItem::Impl::Impl(ButtonItem* parent, string title)
   LOGI("ButtonItem impl created");
 }
 
+int ButtonItem::GetType() const {
+  return AbstractItem::Button;
+}
+
 Bundle ButtonItem::Serialize() {
   Bundle b;
   b = AbstractItem::Serialize();
index 246ffc7..6f459d2 100644 (file)
@@ -37,6 +37,7 @@ class EXPORT_API ButtonItem : public AbstractItem {
   Bundle Serialize() override;
   void Deserialize(Bundle b) override;
   AbstractItem& FindByID(std::string id) override;
+  int GetType() const override;
   std::string GetTitle() const;
 
  private:
index 0f88986..1970a87 100644 (file)
@@ -38,7 +38,7 @@ namespace item {
 ChatMessageItem::ChatMessageItem(std::string id, std::shared_ptr<TextItem> name,
   std::shared_ptr<TextItem> text, std::shared_ptr<TextItem> data,
   std::shared_ptr<TimeItem> time, Type type, std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::ChatMessage, action),
+  : AbstractItem(id, action),
   impl_(new Impl(this, name, text, data, time, type)) {
 }
 
@@ -49,6 +49,10 @@ ChatMessageItem::Impl::Impl(ChatMessageItem* parent,
   LOGI("ChatMessageItem impl created");
 }
 
+int ChatMessageItem::GetType() const {
+  return AbstractItem::ChatMessage;
+}
+
 Bundle ChatMessageItem::Serialize() {
   Bundle b;
   b = AbstractItem::Serialize();
@@ -104,7 +108,6 @@ TextItem& ChatMessageItem::GetNameItem() const {
 
 TextItem& ChatMessageItem::GetTextItem() const {
   return *(impl_->text_);
-
 }
 
 TextItem& ChatMessageItem::GetDataItem() const {
@@ -115,7 +118,7 @@ TimeItem& ChatMessageItem::GetTimeItem() const {
   return *(impl_->time_);
 }
 
-ChatMessageItem::Type ChatMessageItem::GetType() const {
+ChatMessageItem::Type ChatMessageItem::GetCurType() const {
   return impl_->type_;
 }
 
index e3234f6..1321b0b 100644 (file)
@@ -43,6 +43,7 @@ class EXPORT_API ChatMessageItem : public AbstractItem {
     std::shared_ptr<TimeItem> time, Type type,
     std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
   virtual ~ChatMessageItem();
+  int GetType() const override;
 
   Bundle Serialize() override;
   void Deserialize(Bundle b) override;
@@ -51,7 +52,7 @@ class EXPORT_API ChatMessageItem : public AbstractItem {
   TextItem& GetTextItem() const;
   TextItem& GetDataItem() const;
   TimeItem& GetTimeItem() const;
-  Type GetType() const;
+  Type GetCurType() const;
 
  private:
   class Impl;
index 73211d2..97cba96 100644 (file)
@@ -34,8 +34,7 @@ namespace item {
 
 CheckBoxItem::CheckBoxItem(std::string id, std::string title, bool checked,
   std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::CheckBox, action),
-  impl_(new Impl(this, title, checked)) {
+  : AbstractItem(id, action), impl_(new Impl(this, title, checked)) {
 }
 
 CheckBoxItem::Impl::Impl(CheckBoxItem* parent, std::string title, bool checked)
@@ -43,6 +42,10 @@ CheckBoxItem::Impl::Impl(CheckBoxItem* parent, std::string title, bool checked)
   LOGI("CheckBoxItem impl created");
 }
 
+int CheckBoxItem::GetType() const {
+  return AbstractItem::CheckBox;
+}
+
 Bundle CheckBoxItem::Serialize() {
   Bundle b;
 
index 79a6709..27c9fbd 100644 (file)
@@ -35,6 +35,7 @@ class EXPORT_API CheckBoxItem : public AbstractItem {
   Bundle Serialize() override;
   void Deserialize(Bundle b) override;
   AbstractItem& FindByID(std::string id) override;
+  int GetType() const override;
   std::string GetTitle() const;
   bool IsChecked() const;
 
index acaefe3..e60012e 100644 (file)
@@ -33,9 +33,7 @@ using namespace std;
 namespace notification {
 namespace item {
 
-unique_ptr<AbstractAction> DefaultActionFactory::CreateAction(
-    AbstractAction::Type type) {
-
+unique_ptr<AbstractAction> DefaultActionFactory::CreateAction(int type) {
   switch (type) {
   case AbstractAction::NullObject :
     THROW(NOTIFICATION_ERROR_INVALID_PARAMETER);
index 5381d1f..a1ecde5 100644 (file)
@@ -27,8 +27,7 @@ namespace item {
 class EXPORT_API DefaultActionFactory : public IActionFactory {
  public:
   virtual ~DefaultActionFactory() = default;
-  std::unique_ptr<AbstractAction> CreateAction(
-      AbstractAction::Type type) override;
+  std::unique_ptr<AbstractAction> CreateAction(int type) override;
 };
 
 }  // namespace item
index 569b4d9..bf77bb7 100644 (file)
@@ -43,7 +43,7 @@ using namespace std;
 namespace notification {
 namespace item {
 
-unique_ptr<AbstractItem> DefaultItemFactory::CreateItem(AbstractItem::Type type) {
+unique_ptr<AbstractItem> DefaultItemFactory::CreateItem(int type) {
   switch (type) {
   case AbstractItem::NullObject :
     THROW(NOTIFICATION_ERROR_INVALID_PARAMETER);
index 7f2b879..a9b0786 100644 (file)
@@ -27,7 +27,7 @@ namespace item {
 class EXPORT_API DefaultItemFactory : public IItemFactory {
  public:
   virtual ~DefaultItemFactory() = default;
-  std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type) override;
+  std::unique_ptr<AbstractItem> CreateItem(int type) override;
 };
 
 }  // namespace item
index 44c55b0..29bf5fc 100644 (file)
@@ -34,11 +34,11 @@ namespace notification {
 namespace item {
 
 EntryItem::EntryItem(std::shared_ptr<AbstractAction> action)
-  : AbstractItem(AbstractItem::Type::Entry, action), impl_(new Impl(this)) {
+  : AbstractItem(action), impl_(new Impl(this)) {
 }
 
 EntryItem::EntryItem(std::string id, std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::Type::Entry, action), impl_(new Impl(this)) {
+  : AbstractItem(id, action), impl_(new Impl(this)) {
 }
 
 EntryItem::Impl::Impl(EntryItem* parent)
@@ -49,6 +49,10 @@ EntryItem::Impl::Impl(EntryItem* parent)
 EntryItem::~EntryItem() = default;
 EntryItem::Impl::~Impl() = default;
 
+int EntryItem::GetType() const {
+  return AbstractItem::Entry;
+}
+
 Bundle EntryItem::Serialize() {
   Bundle b;
   b = AbstractItem::Serialize();
index f60287f..d3dcf66 100644 (file)
@@ -39,6 +39,7 @@ class EXPORT_API EntryItem : public AbstractItem {
   Bundle Serialize() override;
   void Deserialize(Bundle b) override;
   AbstractItem& FindByID(std::string id) override;
+  int GetType() const override;
   std::string GetText() const;
   void SetText(std::string text);
   int GetTextLimit() const;
index 81e8325..4945d50 100644 (file)
@@ -45,16 +45,14 @@ void FactoryManager::RegisterFactory(std::unique_ptr<IActionFactory> factory) {
   action_factory_ = std::move(factory);
 }
 
-std::unique_ptr<AbstractItem> FactoryManager::CreateItem(
-    AbstractItem::Type type) {
+std::unique_ptr<AbstractItem> FactoryManager::CreateItem(int type) {
   if (item_factory_.get() == nullptr)
     item_factory_.reset(new DefaultItemFactory());
 
   return item_factory_->CreateItem(type);
 }
 
-std::unique_ptr<AbstractAction> FactoryManager::CreateAction(
-    AbstractAction::Type type) {
+std::unique_ptr<AbstractAction> FactoryManager::CreateAction(int type) {
   if (action_factory_.get() == nullptr)
     action_factory_.reset(new DefaultActionFactory());
 
index 55a6e6e..66a356e 100644 (file)
@@ -32,8 +32,8 @@ class EXPORT_API FactoryManager {
   static FactoryManager& GetInst();
   void RegisterFactory(std::unique_ptr<IItemFactory> factory);
   void RegisterFactory(std::unique_ptr<IActionFactory> factory);
-  std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type);
-  std::unique_ptr<AbstractAction> CreateAction(AbstractAction::Type type);
+  std::unique_ptr<AbstractItem> CreateItem(int type);
+  std::unique_ptr<AbstractAction> CreateAction(int type);
   AbstractItem& GetNullItem();
 
  private:
index 2b52644..d6a53da 100644 (file)
@@ -42,11 +42,11 @@ namespace notification {
 namespace item {
 
 GroupItem::GroupItem(string id, shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::Group), impl_(new Impl(this)) {
+  : AbstractItem(id), impl_(new Impl(this)) {
 }
 
 GroupItem::GroupItem(shared_ptr<AbstractAction> action)
-  : AbstractItem(AbstractItem::Group), impl_(new Impl(this)) {
+  : AbstractItem(), impl_(new Impl(this)) {
 }
 
 GroupItem::Impl::Impl(GroupItem* parent)
@@ -57,6 +57,10 @@ GroupItem::Impl::Impl(GroupItem* parent)
 GroupItem::~GroupItem() {
 }
 
+int GroupItem::GetType() const {
+  return AbstractItem::Group;
+}
+
 Bundle GroupItem::Serialize() {
   Bundle b;
   b = AbstractItem::Serialize();
index 0a1c379..51d1b65 100644 (file)
@@ -37,6 +37,7 @@ class EXPORT_API GroupItem : public AbstractItem {
   virtual Bundle Serialize() override;
   virtual void Deserialize(Bundle b) override;
   virtual AbstractItem& FindByID(std::string id) override;
+  int GetType() const override;
 
   void SetDirection(bool vertical);
   bool IsVertical();
index c2d5d81..fd03ab8 100644 (file)
@@ -29,8 +29,7 @@ namespace item {
 class EXPORT_API IActionFactory {
  public:
   virtual ~IActionFactory() = default;
-  virtual std::unique_ptr<AbstractAction> CreateAction(
-      AbstractAction::Type type) = 0;
+  virtual std::unique_ptr<AbstractAction> CreateAction(int type) = 0;
 };
 
 }  // namespace item
index bef75b7..8e266a1 100644 (file)
@@ -46,6 +46,10 @@ IconItem::Impl::Impl(IconItem* parent, std::string iconPath)
 IconItem::~IconItem() = default;
 IconItem::Impl::~Impl() = default;
 
+int IconItem::GetType() const {
+  return AbstractItem::Icon;
+}
+
 }  // namespace item
 }  // namespace notification_ex
 
index 3b6a3eb..4875316 100644 (file)
@@ -33,6 +33,7 @@ class EXPORT_API IconItem : public ImageItem {
   IconItem(std::string id, std::string iconPath,
     std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
   virtual ~IconItem();
+  int GetType() const override;
 
  private:
   class Impl;
index bac2a7b..1006bfa 100644 (file)
@@ -34,7 +34,7 @@ namespace item {
 
 IconTextItem::IconTextItem(std::string id, std::shared_ptr<IconItem> icon,
   std::shared_ptr<TextItem> text, std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::IconText, action),
+  : AbstractItem(id, action),
   impl_(new Impl(this, icon, text)) {
 }
 
@@ -44,6 +44,10 @@ IconTextItem::Impl::Impl(IconTextItem* parent, std::shared_ptr<IconItem> icon,
   LOGI("IconTextItem impl created");
 }
 
+int IconTextItem::GetType() const {
+  return AbstractItem::IconText;
+}
+
 Bundle IconTextItem::Serialize() {
   Bundle b;
   b = AbstractItem::Serialize();
index 7fca273..4fdc44f 100644 (file)
@@ -39,6 +39,8 @@ class EXPORT_API IconTextItem : public AbstractItem {
   Bundle Serialize() override;
   void Deserialize(Bundle b) override;
   AbstractItem& FindByID(std::string id) override;
+  int GetType() const override;
+
   IconItem& GetIconItem() const;
   TextItem& GetTextItem() const;
 
index aec8652..0511184 100644 (file)
@@ -29,7 +29,7 @@ namespace item {
 class EXPORT_API IItemFactory {
  public:
   virtual ~IItemFactory() = default;
-  virtual std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type) = 0;
+  virtual std::unique_ptr<AbstractItem> CreateItem(int type) = 0;
 };
 
 }  // namespace item
index 4c437b9..c9e8701 100644 (file)
@@ -33,12 +33,12 @@ namespace item {
 
 ImageItem::ImageItem(std::string imagePath,
   std::shared_ptr<AbstractAction> action)
-  : AbstractItem(AbstractItem::Image, action), impl_(new Impl(this, imagePath)) {
+  : AbstractItem(action), impl_(new Impl(this, imagePath)) {
 }
 
 ImageItem::ImageItem(std::string id, std::string imagePath,
   std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::Image, action), impl_(new Impl(this, imagePath)) {
+  : AbstractItem(id, action), impl_(new Impl(this, imagePath)) {
 }
 
 ImageItem::Impl::Impl(ImageItem* parent, std::string imagePath)
@@ -46,6 +46,10 @@ ImageItem::Impl::Impl(ImageItem* parent, std::string imagePath)
   LOGI("ImageItem impl created");
 }
 
+int ImageItem::GetType() const {
+  return AbstractItem::Image;
+}
+
 Bundle ImageItem::Serialize() {
   Bundle b;
   b = AbstractItem::Serialize();
index f2e1802..c2bad80 100644 (file)
@@ -33,6 +33,7 @@ class EXPORT_API ImageItem : public AbstractItem {
   ImageItem(std::string id, std::string imagePath,
     std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
   virtual ~ImageItem();
+  int GetType() const override;
 
   Bundle Serialize() override;
   void Deserialize(Bundle b) override;
index 17385a7..5115552 100644 (file)
@@ -36,11 +36,11 @@ namespace notification {
 namespace item {
 
 InputSelectorItem::InputSelectorItem(std::shared_ptr<AbstractAction> action)
-  : AbstractItem(AbstractItem::InputSelector, action), impl_(new Impl(this)) {
+  : AbstractItem(action), impl_(new Impl(this)) {
 }
 
 InputSelectorItem::InputSelectorItem(string id, std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::InputSelector, action), impl_(new Impl(this)) {
+  : AbstractItem(id, action), impl_(new Impl(this)) {
 }
 
 InputSelectorItem::~InputSelectorItem() = default;
@@ -51,6 +51,10 @@ InputSelectorItem::Impl::Impl(InputSelectorItem* parent)
   LOGI("InputSelectorItem impl created");
 }
 
+int InputSelectorItem::GetType() const {
+  return AbstractItem::InputSelector;
+}
+
 Bundle InputSelectorItem::Serialize() {
   Bundle b;
   b = AbstractItem::Serialize();
index 339798d..6b1220a 100644 (file)
@@ -37,6 +37,7 @@ class EXPORT_API InputSelectorItem : public AbstractItem {
   virtual Bundle Serialize() override;
   virtual void Deserialize(Bundle b) override;
   virtual AbstractItem& FindByID(std::string id) override;
+  int GetType() const override;
 
   std::list<std::string> GetContents() const;
   void SetContents(std::list<std::string> contents);
index a1119c0..819677e 100644 (file)
@@ -31,15 +31,19 @@ namespace notification {
 namespace item {
 
 NullItem::NullItem(shared_ptr<AbstractAction> action)
-  : AbstractItem(AbstractItem::NullObject, action) {
+  : AbstractItem(action) {
 }
 
 NullItem::NullItem(string id,
       shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::NullObject, action) {
+  : AbstractItem(id, action) {
 }
 NullItem::~NullItem() = default;
 
+int NullItem::GetType() const {
+  return AbstractItem::NullObject;
+}
+
 Bundle NullItem::Serialize() {
   Bundle b;
   b = AbstractItem::Serialize();
index 15d28e0..cf27164 100644 (file)
@@ -32,11 +32,10 @@ class EXPORT_API NullItem : public AbstractItem {
   NullItem(std::string id,
       std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
   virtual ~NullItem();
-
- public:
-  virtual Bundle Serialize() override;
-  virtual void Deserialize(Bundle b) override;
-  virtual AbstractItem& FindByID(std::string id) override;
+  int GetType() const override;
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  AbstractItem& FindByID(std::string id) override;
 };
 
 }  // namespace item
index 6520075..fecefbc 100644 (file)
@@ -38,13 +38,13 @@ namespace item {
 
 ProgressItem::ProgressItem(float min_val, float current, float max_val,
     std::shared_ptr<AbstractAction> action)
-  : AbstractItem(AbstractItem::Progress, action),
+  : AbstractItem(action),
     impl_(new Impl(min_val, current, max_val, this)) {
 }
 
 ProgressItem::ProgressItem(string id, float min_val, float current, float max_val,
     std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::Progress, action),
+  : AbstractItem(id, action),
   impl_(new Impl(min_val, current, max_val, this)) {
 }
 
@@ -58,6 +58,10 @@ ProgressItem::Impl::Impl(float min_val, float current, float max_val, ProgressIt
   LOGI("ProgressItem impl created");
 }
 
+int ProgressItem::GetType() const {
+  return AbstractItem::Progress;
+}
+
 Bundle ProgressItem::Serialize() {
   Bundle b;
   b = AbstractItem::Serialize();
index 6060521..d3d4b9e 100644 (file)
@@ -38,6 +38,7 @@ class EXPORT_API ProgressItem : public AbstractItem {
   virtual Bundle Serialize() override;
   virtual void Deserialize(Bundle b) override;
   virtual AbstractItem& FindByID(std::string id) override;
+  int GetType() const override;
 
   float GetCurrent() const;
   void SetCurrent(float current);
index 6b153cb..f9543ac 100644 (file)
@@ -34,8 +34,7 @@ namespace notification {
 namespace item {
 TextItem::TextItem(std::string id, std::string text, std::string hyperlink,
       std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::Type::Text, action),
-  impl_(new Impl(this, text, hyperlink)) {
+  : AbstractItem(id, action), impl_(new Impl(this, text, hyperlink)) {
 }
 
 TextItem::Impl::Impl(TextItem* parent, std::string text, std::string hyperlink)
@@ -46,6 +45,10 @@ TextItem::Impl::Impl(TextItem* parent, std::string text, std::string hyperlink)
 TextItem::~TextItem() = default;
 TextItem::Impl::~Impl() = default;
 
+int TextItem::GetType() const {
+  return AbstractItem::Text;
+}
+
 Bundle TextItem::Serialize() {
   Bundle b;
   b = AbstractItem::Serialize();
index 2814992..b7487fa 100644 (file)
@@ -35,7 +35,7 @@ class EXPORT_API TextItem : public AbstractItem {
       std::string hyperlink = std::string(),
       std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
   virtual ~TextItem();
-
+  int GetType() const override;
   Bundle Serialize() override;
   void Deserialize(Bundle b) override;
   AbstractItem& FindByID(std::string id) override;
index c84563a..fc7fbf9 100644 (file)
@@ -32,7 +32,7 @@ namespace notification {
 namespace item {
 
 TimeItem::TimeItem(std::shared_ptr<AbstractAction> action)
-  : AbstractItem(AbstractItem::Time, action), impl_(new Impl(this, 0)) {
+  : AbstractItem(action), impl_(new Impl(this, 0)) {
   time_t current_time;
   time(&current_time);
 
@@ -40,12 +40,12 @@ TimeItem::TimeItem(std::shared_ptr<AbstractAction> action)
 }
 
 TimeItem::TimeItem(time_t time, std::shared_ptr<AbstractAction> action)
-  : AbstractItem(AbstractItem::Time, action), impl_(new Impl(this, time)) {
+  : AbstractItem(action), impl_(new Impl(this, time)) {
 }
 
 TimeItem::TimeItem(std::string id, time_t time,
   std::shared_ptr<AbstractAction> action)
-  : AbstractItem(id, AbstractItem::Time, action), impl_(new Impl(this, time)) {
+  : AbstractItem(id, action), impl_(new Impl(this, time)) {
 }
 
 TimeItem::Impl::Impl(TimeItem* parent, time_t time)
@@ -53,6 +53,10 @@ TimeItem::Impl::Impl(TimeItem* parent, time_t time)
   LOGI("TimeItem impl created");
 }
 
+int TimeItem::GetType() const {
+  return AbstractItem::Time;
+}
+
 Bundle TimeItem::Serialize() {
   Bundle b;
   struct tm* timeinfo;
index d1506f7..388a9b4 100644 (file)
@@ -38,7 +38,7 @@ class EXPORT_API TimeItem : public AbstractItem {
     std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
 
   virtual ~TimeItem();
-
+  int GetType() const override;
   Bundle Serialize() override;
   void Deserialize(Bundle b) override;
   AbstractItem& FindByID(std::string id) override;
index 65d7cbf..3ff4dfe 100644 (file)
@@ -45,7 +45,7 @@ VisibilityAction::Impl::Impl(VisibilityAction* parent) : parent_(parent) {
 VisibilityAction::~VisibilityAction() = default;
 VisibilityAction::Impl::~Impl() = default;
 
-AbstractAction::Type VisibilityAction::GetType() const {
+int VisibilityAction::GetType() const {
   return AbstractAction::Visibility;
 }
 
index d18f52e..c4e7b7a 100644 (file)
@@ -28,7 +28,7 @@ class EXPORT_API VisibilityAction  : public AbstractAction {
   VisibilityAction(std::string extra);
   virtual ~VisibilityAction();
 
-  AbstractAction::Type GetType() const override;
+  int GetType() const override;
   Bundle Serialize() override;
   void Deserialize(Bundle b) override;
   bool IsLocal() const override;
index abca486..20a86cf 100644 (file)
@@ -52,7 +52,7 @@ TEST_F(ChatMessageItemTest, FindByID) {
   ASSERT_EQ(message.GetNameItem().GetContents(), "name");
   ASSERT_EQ(message.GetTextItem().GetContents(), "text");
   ASSERT_EQ(message.GetDataItem().GetContents(), "data");
-  ASSERT_EQ(message.GetType(), ChatMessageItemTest::type);
+  ASSERT_EQ(message.GetCurType(), ChatMessageItemTest::type);
 }
 
 TEST_F(ChatMessageItemTest, FindByIDNullItemReturn) {
@@ -69,5 +69,5 @@ TEST_F(ChatMessageItemTest, SerializeDeserialize) {
   ASSERT_EQ(gen_message->GetTextItem().GetContents(), "text");
   ASSERT_EQ(gen_message->GetDataItem().GetContents(), "data");
   ASSERT_EQ(gen_message->GetTimeItem().GetTime(), ChatMessageItemTest::current_time);
-  ASSERT_EQ(gen_message->GetType(), ChatMessageItemTest::type);
+  ASSERT_EQ(gen_message->GetCurType(), ChatMessageItemTest::type);
 }