[dali_2.0.7] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene-loader / public-api / customization.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #include "dali-scene-loader/public-api/customization.h"
18 #include "dali/devel-api/common/map-wrapper.h"
19
20 namespace Dali
21 {
22 namespace SceneLoader
23 {
24
25 struct Customization::Map::Impl {
26   std::map<Tag, Customization> mCustomizations;
27 };
28
29 Customization::Map::Map()
30 : mImpl{ new Impl }
31 {}
32
33 Customization::Map::~Map() = default;
34
35 Customization* Customization::Map::Set(Tag tag, Customization&& customization)
36 {
37   auto& result = (mImpl->mCustomizations[tag] = customization);
38   return &result;
39 }
40
41 const Customization* Customization::Map::Get(Tag tag) const
42 {
43   auto& customizations = mImpl->mCustomizations;
44   auto iFind = customizations.find(tag);
45   if (iFind != customizations.end())
46   {
47     return &iFind->second;
48   }
49   return nullptr;
50 }
51
52 Customization* Customization::Map::Get(Tag tag)
53 {
54   auto& customizations = mImpl->mCustomizations;
55   auto iFind = customizations.find(tag);
56   if (iFind != customizations.end())
57   {
58     return &iFind->second;
59   }
60   return nullptr;
61 }
62
63 uint32_t Customization::Map::Size() const
64 {
65   return mImpl->mCustomizations.size();
66 }
67
68 void Customization::Map::Clear()
69 {
70   mImpl->mCustomizations.clear();
71 }
72
73 struct Customization::Choices::Impl
74 {
75   std::map<Tag, OptionType> mOptions;
76 };
77
78 Customization::Choices::Choices()
79 : mImpl{ new Impl }
80 {}
81
82 Customization::Choices::~Choices() = default;
83
84 void Customization::Choices::Set(Tag tag, OptionType option)
85 {
86   mImpl->mOptions[tag] = option;
87 }
88
89 Customization::OptionType Customization::Choices::Get(Tag tag) const
90 {
91   auto& options = mImpl->mOptions;
92   auto iFind = options.find(tag);
93   if (iFind != options.end())
94   {
95     return iFind->second;
96   }
97   return NONE;
98 }
99
100 uint32_t Customization::Choices::Size() const
101 {
102   return mImpl->mOptions.size();
103 }
104
105 void Customization::Choices::Clear()
106 {
107   mImpl->mOptions.clear();
108 }
109
110 }
111 }