2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
18 * @file FUi_ResourceMap.h
19 * @brief This is the header file for Map class.
22 * This header file contains declaration of Map class.
23 * The ActionEvent class can call listener's method. So, when event occurred,
24 * application can handle it appropriately.
27 #ifndef _FUI_INTERNAL_RESOURCE_MAP_H_
28 #define _FUI_INTERNAL_RESOURCE_MAP_H_
30 #include <FBaseString.h>
31 #include <FBaseColHashMapT.h>
32 #include <FBaseSysLog.h>
34 namespace Tizen { namespace Base {
38 namespace Tizen { namespace Ui { namespace _Resource
44 RESOURCE_TYPE_DIMENSION,
45 RESOURCE_TYPE_FIXED_VALUE,
52 class _ResourceHashCodeProvider
53 : public Tizen::Base::Collection::IHashCodeProviderT <Tizen::Base::String>
56 _ResourceHashCodeProvider(void) {}
57 virtual ~_ResourceHashCodeProvider(void) {}
59 virtual int GetHashCode(const Tizen::Base::String& obj) const
61 return obj.GetHashCode();
65 class _ResourceComparer
66 : public Tizen::Base::Collection::IComparerT <Tizen::Base::String>
69 _ResourceComparer(void) {}
70 virtual ~_ResourceComparer(void) {}
71 virtual result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
86 template<class ValueType>
88 : public Tizen::Base::Collection::HashMapT<Tizen::Base::String, ValueType>
91 Map(_ResourceType type)
92 : Tizen::Base::Collection::HashMapT<Tizen::Base::String, ValueType>()
95 __pProvider = new _ResourceHashCodeProvider;
96 SysTryReturnVoidResult(NID_UI, __pProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
97 __pComparer = new _ResourceComparer;
98 SysTryReturnVoidResult(NID_UI, __pComparer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
99 __modifiedItemTable.Construct(0,0,*__pProvider, *__pComparer);
103 result r = E_SUCCESS;
104 Tizen::Base::Collection::IMapEnumeratorT<Tizen::Base::String, ValueType >* pMapEnum = null;
105 if (Tizen::Base::Collection::HashMapT<Tizen::Base::String, ValueType>::GetCount() > 0)
107 pMapEnum = Tizen::Base::Collection::HashMapT<Tizen::Base::String, ValueType>::GetMapEnumeratorN();
108 SysTryReturn(NID_UI_ANIM, (pMapEnum != null), , E_SYSTEM, "[E_SYSTEM] System Error.");
110 Tizen::Base::Collection::MapEntryT<Tizen::Base::String, ValueType> value;
111 while ((pMapEnum->MoveNext() == E_SUCCESS))
113 r = pMapEnum->GetCurrent(value);
114 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error.");
116 ValueType pObj = value.GetValue();
119 Tizen::Base::Collection::HashMapT<Tizen::Base::String, ValueType>::RemoveAll();
131 void Initialize(void)
133 result r = E_SUCCESS;
134 Tizen::Base::Collection::MapEntryT <Tizen::Base::String, ValueType> currentEntry;
135 Tizen::Base::Collection::IEnumeratorT <Tizen::Base::Collection::MapEntryT <Tizen::Base::String, ValueType> >* pMapEnumerator = Tizen::Base::Collection::HashMapT<Tizen::Base::String, ValueType>::GetMapEnumeratorN();
137 SysTryReturn(NID_UI, pMapEnumerator, , E_SYSTEM, "[E_SYSTEM] Getting enumerator is failed.");
139 while ((pMapEnumerator->MoveNext() == E_SUCCESS))
141 ValueType pObject = null;
142 r = pMapEnumerator->GetCurrent(currentEntry);
143 SysTryCatch(NID_UI, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] removing data binding is failed.");
145 pObject = currentEntry.GetValue();
146 SysTryCatch(NID_UI, pObject, r = E_SYSTEM, r, "[E_SYSTEM] UpdateAllBindings is failed.");
149 delete pMapEnumerator;
150 pMapEnumerator = null;
151 Tizen::Base::Collection::HashMapT<Tizen::Base::String, ValueType>::RemoveAll();
154 delete pMapEnumerator;
156 result SetValue(const Tizen::Base::String& key, const ValueType& value)
158 ValueType _value = null;
159 if(GetValue(key, _value) == E_SUCCESS)
161 __modifiedItemTable.Add(key, true);
167 return E_OBJ_NOT_FOUND;
170 _ResourceType GetMode(void) const
174 void SetInformation (const Tizen::Base::String& information)
176 __information = information;
178 Tizen::Base::String GetInformation(void)
180 return __information;
182 bool IsUserThemeItem(const Tizen::Base::String& key)
185 __modifiedItemTable.ContainsKey(key, exist);
192 Map& operator =(const Map&);
194 const _ResourceType __type;
195 Tizen::Base::String __information;
196 Tizen::Base::Collection::HashMapT<Tizen::Base::String, bool> __modifiedItemTable;
197 Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>* __pProvider;
198 Tizen::Base::Collection::IComparerT<Tizen::Base::String>* __pComparer;
203 #endif // _FUI_INTERNAL_RESOURCE_MAP_H_