Fix ThemeInfoBuilder 11/234711/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 28 May 2020 06:32:57 +0000 (15:32 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Fri, 29 May 2020 05:36:38 +0000 (05:36 +0000)
Fix ThemeInfobuilder for extendability.
Put parsed data into a bundle, and build ThemeInfo using bundle.

Change-Id: Ia7055e6587640c5cc68087ce25937b18bad66602
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/theme_plugin/theme_info_builder.cc
src/theme_plugin/theme_info_builder.h
src/theme_plugin/theme_parser.cc

index f76ad6b..7a68df1 100644 (file)
@@ -7,54 +7,24 @@
 namespace ttm {
 namespace plugin {
 
-ThemeInfoBuilder::ThemeInfoBuilder(const std::string& id) : id_(id) {
+ThemeInfoBuilder::ThemeInfoBuilder(const std::string& id) {
+  bundle_.Add("id", id);
 }
 
-ThemeInfoBuilder& ThemeInfoBuilder::SetVersion(const std::string& ver) {
-    version_ = ver;
-  return *this;
-}
-
-ThemeInfoBuilder& ThemeInfoBuilder::SetToolVersion(const std::string& ver) {
-    tool_version_ = ver;
-  return *this;
-}
-
-ThemeInfoBuilder& ThemeInfoBuilder::SetTitle(const std::string& title) {
-    title_ = title;
-  return *this;
-}
-
-ThemeInfoBuilder& ThemeInfoBuilder::SetPreview(const std::string& path) {
-    preview_ = path;
-  return *this;
-}
-
-ThemeInfoBuilder& ThemeInfoBuilder::SetDescription(const std::string& desc) {
-    description_ = desc;
-  return *this;
-}
-
-ThemeInfoBuilder& ThemeInfoBuilder::SetResolution(
-    const std::string& resolution) {
-        resolution_ = resolution;
-  return *this;
-}
-
-ThemeInfoBuilder& ThemeInfoBuilder::PutExtra(const std::string& key,
+ThemeInfoBuilder& ThemeInfoBuilder::PutString(const std::string& key,
     const std::string& value) {
+  bundle_.Add(key, value);
   return *this;
 }
 
-ThemeInfoBuilder& ThemeInfoBuilder::PutExtraArray(const std::string& key,
-    std::string value[]) {
+ThemeInfoBuilder& ThemeInfoBuilder::PutStringArray(const std::string& key,
+    const std::vector<std::string>& value) {
+  bundle_.Add(key, value);
   return *this;
 }
 
 loader::ThemeInfo ThemeInfoBuilder::Build() {
-  loader::ThemeInfo info(id_, version_, tool_version_, title_, resolution_,
-      preview_, description_);
-  return info;
+  return loader::ThemeInfo(bundle_);
 }
 
 }  // namespace plugin
index 2093a00..130fdf7 100644 (file)
@@ -5,8 +5,11 @@
 #ifndef THEME_PLUGIN_THEME_INFO_BUILDER_H_
 #define THEME_PLUGIN_THEME_INFO_BUILDER_H_
 
+#include <bundle_cpp.h>
+
 #include <memory>
 #include <string>
+#include <vector>
 
 #include "theme/loader/theme_info.h"
 
@@ -16,24 +19,13 @@ namespace plugin {
 class ThemeInfoBuilder {
  public:
   explicit ThemeInfoBuilder(const std::string& id);
-  ThemeInfoBuilder& SetVersion(const std::string& ver);
-  ThemeInfoBuilder& SetToolVersion(const std::string& ver);
-  ThemeInfoBuilder& SetTitle(const std::string& title);
-  ThemeInfoBuilder& SetPreview(const std::string& path);
-  ThemeInfoBuilder& SetDescription(const std::string& desc);
-  ThemeInfoBuilder& SetResolution(const std::string& resolution);
-  ThemeInfoBuilder& PutExtra(const std::string& key, const std::string& value);
-  ThemeInfoBuilder& PutExtraArray(const std::string& key, std::string value[]);
+  ThemeInfoBuilder& PutString(const std::string& key, const std::string& value);
+  ThemeInfoBuilder& PutStringArray(const std::string& key,
+      const std::vector<std::string>& value);
   loader::ThemeInfo Build();
 
  private:
-  std::string id_;
-  std::string version_;
-  std::string tool_version_;
-  std::string title_;
-  std::string preview_;
-  std::string description_;
-  std::string resolution_;
+  tizen_base::Bundle bundle_;
 };
 
 }  // namespace plugin
index dbac250..6c43d69 100644 (file)
@@ -32,10 +32,10 @@ loader::ThemeInfo ThemeParser::Inflate(const std::string id) {
 
   // FIXME: this parser should parse more theme information.
   ThemeInfoBuilder builder("testid");
-  builder.SetVersion(root["version"].asString()).
-      SetToolVersion(root["tool_version"].asString()).
-      SetTitle(root["header"]["title"].asString()).
-      SetDescription(root["header"]["description"].asString());
+  builder.PutString("version", root["version"].asString()).
+      PutString("tool_version", root["tool_version"].asString()).
+      PutString("title", root["header"]["title"].asString()).
+      PutString("description", root["header"]["description"].asString());
 
   return builder.Build();
 }