Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / resource / FUi_ResourceMapContainer.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FUi_ResourceMapContainer.cpp
19  * @brief               This is the implementation file for Config class.
20  * @version             3.0
21  *
22  * This cpp file contains implementation of Config class.
23  * The ActionEvent class can call listener's method. So, when event occurred,
24  * application can handle it appropriately.
25  *
26  */
27 #include <FBaseInteger.h>
28 #include <FGrpColor.h>
29 #include <FGrpDimension.h>
30 #include <FBaseSysLog.h>
31 #include <FBaseColIHashCodeProviderT.h>
32 #include "FUi_ResourceMapContainer.h"
33
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Graphics;
37
38 namespace Tizen { namespace Ui { namespace _Resource
39 {
40
41 MapContainer::MapContainer(void)
42         : __pColorMap(null)
43         , __pDimensionMap(null)
44         , __pFixedValueMap(null)
45         , __pImageMap(null)
46         , __pShapeMap(null)
47         , __pProvider(null)
48         , __pComparer(null)
49         , __version(L"")
50         , __themeName(L"")
51         , __resolution(L"")
52         , __resolutionForImage(L"")
53 {
54         __pProvider = new _ResourceHashCodeProvider;
55         SysTryReturnVoidResult(NID_UI, __pProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
56         __pComparer = new _ResourceComparer;
57         SysTryReturnVoidResult(NID_UI, __pComparer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
58 }
59 MapContainer::~MapContainer(void)
60 {
61         delete __pColorMap;
62         __pColorMap = null;
63         delete __pDimensionMap;
64         __pDimensionMap = null;
65         delete __pFixedValueMap;
66         __pFixedValueMap = null;
67         delete __pImageMap;
68         __pImageMap = null;
69         delete __pShapeMap;
70         __pShapeMap = null;
71         delete __pProvider;
72         __pProvider = null;
73         delete __pComparer;
74         __pComparer = null;
75 }
76
77 void
78 MapContainer::CreateMap(_ResourceType type)
79 {
80         switch(type)
81         {
82         case RESOURCE_TYPE_COLOR:
83                 if(__pColorMap == null)
84                 {
85                         __pColorMap = new (std::nothrow) ResourceColorMap(type);
86                         SysTryReturnVoidResult(NID_UI, __pColorMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
87                         __pColorMap->Construct(0, 0, *__pProvider, *__pComparer);
88                 }
89                 break;
90         case RESOURCE_TYPE_DIMENSION:
91                 if(__pDimensionMap == null)
92                 {
93                         __pDimensionMap = new (std::nothrow) ResourceDimensionMap(type);
94                         SysTryReturnVoidResult(NID_UI, __pDimensionMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
95                         __pDimensionMap->Construct(0, 0, *__pProvider, *__pComparer);
96                 }
97                 break;
98
99         case RESOURCE_TYPE_FIXED_VALUE:
100                 if(__pFixedValueMap == null)
101                 {
102                         __pFixedValueMap = new (std::nothrow) ResourceShapeMap(type);
103                         SysTryReturnVoidResult(NID_UI, __pFixedValueMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
104                         __pFixedValueMap->Construct(0, 0, *__pProvider, *__pComparer);
105                 }
106                 break;
107         case RESOURCE_TYPE_IMAGE:
108                 if(__pImageMap == null)
109                 {
110                         __pImageMap = new (std::nothrow) ResourceImageMap(type);
111                         SysTryReturnVoidResult(NID_UI, __pImageMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
112                         __pImageMap->Construct(0, 0, *__pProvider, *__pComparer);
113                 }
114                 break;
115         case RESOURCE_TYPE_SHAPE:
116                 if(__pShapeMap == null)
117                 {
118                         __pShapeMap = new (std::nothrow) ResourceShapeMap(type);
119                         SysTryReturnVoidResult(NID_UI, __pShapeMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
120                         __pShapeMap->Construct(0, 0, *__pProvider, *__pComparer);
121                 }
122                 break;
123         default:
124                 break;
125         }
126         InitializeMap(type);
127 }
128 void
129 MapContainer::InitializeMap(_ResourceType type)
130 {
131         switch(type)
132         {
133         case RESOURCE_TYPE_COLOR:
134                 if(__pColorMap != null)
135                 {
136                         __pColorMap->Initialize();
137                 }
138                 break;
139         case RESOURCE_TYPE_DIMENSION:
140                 if(__pDimensionMap != null)
141                 {
142                         __pDimensionMap->Initialize();
143                 }
144                 break;
145         case RESOURCE_TYPE_FIXED_VALUE:
146                 if(__pFixedValueMap != null)
147                 {
148                         __pFixedValueMap->Initialize();
149                 }
150                 break;
151         case RESOURCE_TYPE_IMAGE:
152                 if(__pImageMap != null)
153                 {
154                         __pImageMap->Initialize();
155                 }
156                 break;
157         case RESOURCE_TYPE_SHAPE:
158                 if(__pShapeMap != null)
159                 {
160                         __pShapeMap->Initialize();
161                 }
162                 break;
163         default:
164                 break;
165         }
166 }
167
168 ResourceColorMap*
169 MapContainer::GetColorMap(void) const
170 {
171         return __pColorMap;
172 }
173
174 ResourceDimensionMap*
175 MapContainer::GetDimensionMap(void) const
176 {
177         return __pDimensionMap;
178 }
179
180 ResourceShapeMap*
181 MapContainer::GetFixedValueMap(void) const
182 {
183         return __pFixedValueMap;
184 }
185
186 ResourceImageMap*
187 MapContainer::GetImageMap(void) const
188 {
189         return __pImageMap;
190 }
191
192 ResourceShapeMap*
193 MapContainer::GetShapeMap(void) const
194 {
195         return __pShapeMap;
196 }
197 void
198 MapContainer::SetVersion (const Tizen::Base::String& version)
199 {
200         __version = version;
201 }
202 Tizen::Base::String
203 MapContainer::GetVersion(void)
204 {
205         return __version;
206 }
207 void
208 MapContainer::SetThemeName(const Tizen::Base::String& themeName)
209 {
210         __themeName = themeName;
211 }
212 Tizen::Base::String
213 MapContainer::GetThemeName(void)
214 {
215         return __themeName;
216 }
217 void
218 MapContainer::SetResolution(const Tizen::Base::String& resolution)
219 {
220         __resolution = resolution;
221 }
222 Tizen::Base::String
223 MapContainer::GetResolution(void)
224 {
225         return __resolution;
226 }
227 void
228 MapContainer::SetResolutionForImage(const Tizen::Base::String& resolution)
229 {
230         __resolutionForImage  = resolution;
231 }
232 Tizen::Base::String
233 MapContainer::GetResolutionForImage(void)
234 {
235         return __resolutionForImage;
236 }
237
238 }}} //Tizen::Ui::_Resource