Make a class ItemInfo to avoid exporting some methods 89/201589/2
authorJunghoon Park <jh9216.park@samsung.com>
Mon, 18 Mar 2019 04:34:05 +0000 (13:34 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Mon, 18 Mar 2019 06:29:17 +0000 (15:29 +0900)
Change-Id: Iaed432aaec5f65069b503d4057d1b5aaaaafe243
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
notification-ex/abstract_item.cc
notification-ex/abstract_item.h
notification-ex/abstract_item_implementation.h
notification-ex/iitem_info.h [new file with mode: 0644]
notification-ex/iitem_info_internal.h [new file with mode: 0644]
notification-ex/item_info.cc [new file with mode: 0644]
notification-ex/item_info_internal.h [moved from notification-ex/item.h with 55% similarity]

index 3aad57d..0bdcdcc 100644 (file)
@@ -22,6 +22,7 @@
 #include "notification-ex/exception.h"
 #include "notification-ex/abstract_item.h"
 #include "notification-ex/abstract_item_implementation.h"
+#include "notification-ex/item_info_internal.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -47,14 +48,16 @@ AbstractItem::AbstractItem(std::string id,
 
 AbstractItem::Impl::Impl(AbstractItem* parent, string id,
     std::shared_ptr<AbstractAction> action)
-    : id_(id), action_(action), parent_(parent) {
-  LOGI("GroupItem created");
+    : id_(id), action_(action), parent_(parent),
+    info_(std::make_shared<ItemInfo>(this)) {
+  LOGI("Item created");
 }
 
 AbstractItem::Impl::Impl(AbstractItem* parent,
     std::shared_ptr<AbstractAction> action)
-    : action_(action), parent_(parent) {
-  LOGI("GroupItem created");
+    : action_(action), parent_(parent),
+    info_(std::make_shared<ItemInfo>(this)) {
+  LOGI("Item created");
 }
 
 AbstractItem::~AbstractItem() = default;
@@ -137,20 +140,8 @@ AbstractItem::Policy AbstractItem::GetPolicy() const {
   return impl_->policy_;
 }
 
-int AbstractItem::GetVersion() const {
-  return impl_->version_;
-}
-
-void AbstractItem::SetVersion(int ver) {
-  impl_->version_ = ver;
-}
-
-int AbstractItem::GetHideTime() const {
-  return impl_->hide_time_;
-}
-
-int AbstractItem::GetDeleteTime() const {
-  return impl_->delete_time_;
+std::shared_ptr<IItemInfo> AbstractItem::GetInfo() const {
+  return impl_->info_;
 }
 
 string AbstractItem::GetChannel() const {
index 8f9f8de..e5b5e7f 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "notification-ex/abstract_action.h"
 #include "notification-ex/ex_bundle.h"
+#include "notification-ex/iitem_info.h"
 
 #ifndef EXPORT_API
 #define EXPORT_API __attribute__((visibility("default")))
@@ -213,10 +214,6 @@ class EXPORT_API AbstractItem {
   bool CanReceive(std::string id) const;
   void SetPolicy(Policy policy);
   Policy GetPolicy() const;
-  int GetVersion() const;
-  void SetVersion(int ver);
-  int GetHideTime() const;
-  int GetDeleteTime() const;
   std::string GetChannel() const;
   void SetChannel(std::string channel);
   void SetLEDInfo(std::shared_ptr<LEDInfo> led);
@@ -225,6 +222,7 @@ class EXPORT_API AbstractItem {
   void SetVibrationPath(std::string path);
   std::string GetSoundPath() const;
   std::string GetVibrationPath() const;
+  std::shared_ptr<IItemInfo> GetInfo() const;
 
  private:
   class Impl;
index 23a7ed4..4f4b942 100644 (file)
@@ -28,6 +28,7 @@ namespace item {
 
 class AbstractItem::Impl {
  public:
+  class ItemInfo;
   virtual ~Impl() = default;
 
  private:
@@ -40,7 +41,6 @@ class AbstractItem::Impl {
 
  private:
   friend class AbstractItem;
-
   std::string channel_;
   std::string id_;
   std::shared_ptr<LEDInfo> led_ = nullptr;
@@ -57,6 +57,7 @@ class AbstractItem::Impl {
   AbstractItem* parent_;
   std::string sound_path_;
   std::string vibration_path_;
+  std::shared_ptr<IItemInfo> info_;
 };
 
 }  // namespace item
diff --git a/notification-ex/iitem_info.h b/notification-ex/iitem_info.h
new file mode 100644 (file)
index 0000000..049bf97
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_IITEM_INFO_H_
+#define NOTIFICATION_EX_IITEM_INFO_H_
+
+namespace notification {
+namespace item {
+
+class EXPORT_API IItemInfo {
+ public:
+  virtual ~IItemInfo() = default;
+  virtual int GetVersion() const = 0;
+  virtual void SetVersion(int ver) = 0;
+};
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_IITEM_INFO_H_
diff --git a/notification-ex/iitem_info_internal.h b/notification-ex/iitem_info_internal.h
new file mode 100644 (file)
index 0000000..56f667b
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_IITEM_INFO_INTERNAL_H_
+#define NOTIFICATION_EX_IITEM_INFO_INTERNAL_H_
+
+#include "notification-ex/iitem_info.h"
+
+namespace notification {
+namespace item {
+
+class IItemInfoInternal : public IItemInfo{
+ public:
+  virtual ~IItemInfoInternal() = default;
+  virtual int GetHideTime() const = 0;
+  virtual int GetDeleteTime() const = 0;
+};
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_IITEM_INFO_INTERNAL_H_
diff --git a/notification-ex/item_info.cc b/notification-ex/item_info.cc
new file mode 100644 (file)
index 0000000..2b456ce
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+
+#include <memory>
+
+#include "notification-ex/item_info_internal.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+using namespace std;
+namespace notification {
+namespace item {
+
+AbstractItem::Impl::ItemInfo::ItemInfo(AbstractItem::Impl* impl) : impl_(impl) {}
+
+int AbstractItem::Impl::ItemInfo::GetVersion() const {
+  return impl_->version_;
+}
+
+void AbstractItem::Impl::ItemInfo::SetVersion(int ver) {
+  impl_->version_ = ver;
+}
+
+int AbstractItem::Impl::ItemInfo::GetHideTime() const {
+  return impl_->hide_time_;
+}
+
+int AbstractItem::Impl::ItemInfo::GetDeleteTime() const {
+  return impl_->delete_time_;
+}
+
+}  // namespace item
+}  // namespace notification
similarity index 55%
rename from notification-ex/item.h
rename to notification-ex/item_info_internal.h
index 7e5f6a9..5c9d1b1 100644 (file)
  * limitations under the License.
  */
 
-#ifndef NOTIFICATION_EX_ITEM_H_
-#define NOTIFICATION_EX_ITEM_H_
+#ifndef NOTIFICATION_EX_ITEM_INFO_H_
+#define NOTIFICATION_EX_ITEM_INFO_H_
 
-#include <time.h>
-
-#include <memory>
-#include <string>
-#include <list>
-
-#include "notification-ex/abstract_item.h"
-#include "notification-ex/ex_bundle.h"
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
+#include "notification-ex/abstract_item_implementation.h"
+#include "notification-ex/iitem_info_internal.h"
 
 namespace notification {
 namespace item {
 
-class EXPORT_API CustomItem : public AbstractItem {
+class AbstractItem::Impl::ItemInfo : public IItemInfoInternal {
  public:
-  CustomItem();
-  virtual ~CustomItem();
+  ItemInfo(AbstractItem::Impl* impl);
+  virtual ~ItemInfo() = default;
+  int GetVersion() const override;
+  void SetVersion(int ver) override;
+  int GetHideTime() const override;
+  int GetDeleteTime() const override;
 
-  Bundle Serialize() override;
-  void Deserialize(Bundle b) override;
-  AbstractItem& FindByID(std::string id) override;
-};  // class CustomItem
+ private:
+  AbstractItem::Impl* impl_;
+};
 
 }  // namespace item
 }  // nampace notification
-#endif  // NOTIFICATION_EX_ITEM_H_
+#endif  // NOTIFICATION_EX_ITEM_INFO_H_