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>
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
#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"
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
// 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();
}