cf9f2f2aeec204dffcca6bf8f1bf6de98f7df01e
[platform/framework/native/appfw.git] / src / app / inc / FApp_TemplateUtil.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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 /**
19  * @file         FApp_TemplateUtil.h
20  * @brief       This is the header file for the internap Tizen::App utilities.
21  */
22
23 #ifndef _FAPP_INTERNAL_TEMPLATE_UTIL_H_
24 #define _FAPP_INTERNAL_TEMPLATE_UTIL_H_
25
26 #include <FBaseString.h>
27 #include <FBaseColICollectionT.h>
28 #include <FBaseColIEnumeratorT.h>
29
30 namespace Tizen { namespace App
31 {
32
33 template<class Type> void
34 _DeleteCollection(Tizen::Base::Collection::ICollectionT<Type*>& col)
35 {
36         Tizen::Base::Collection::IEnumeratorT<Type*>* pEnum = col.GetEnumeratorN();
37
38         if (pEnum)
39         {
40                 while (pEnum->MoveNext() == E_SUCCESS)
41                 {
42                         Type* pElem = null;
43                         pEnum->GetCurrent(pElem);
44
45                         delete pElem;
46                 }
47
48                 delete pEnum;
49         }
50 }
51
52 template<class KeyType, class ValueType> void
53 _DeleteCollectionMapValue(Tizen::Base::Collection::IMapT<KeyType, ValueType*>& col)
54 {
55         Tizen::Base::Collection::IMapEnumeratorT<KeyType, ValueType*>* pEnum = col.GetMapEnumeratorN();
56
57         if (pEnum)
58         {
59                 while (pEnum->MoveNext() == E_SUCCESS)
60                 {
61                         ValueType* pValue = null;
62                         pEnum->GetValue(pValue);
63
64                         delete pValue;
65                 }
66
67                 delete pEnum;
68         }
69 }
70
71 template<class KeyType, class ValueType> void
72 _DeleteCollectionMapValue(Tizen::Base::Collection::IMultiMapT<KeyType, ValueType*>& col)
73 {
74         Tizen::Base::Collection::IMapEnumeratorT<KeyType, ValueType*>* pEnum = col.GetMapEnumeratorN();
75
76         if (pEnum)
77         {
78                 while (pEnum->MoveNext() == E_SUCCESS)
79                 {
80                         ValueType* pValue = null;
81                         pEnum->GetValue(pValue);
82
83                         delete pValue;
84                 }
85
86                 delete pEnum;
87         }
88 }
89
90 } } // Tizen::App
91
92 namespace Tizen { namespace Base
93 {
94
95 namespace Collection
96 {
97
98 template <>
99 class __HashMapDefaultProviderT<String>
100 : public IHashCodeProviderT<String>
101 , public Object
102 {
103         public:
104                 __HashMapDefaultProviderT(void) {}
105
106                 virtual ~__HashMapDefaultProviderT(void) {}
107
108                 virtual int GetHashCode(const String& obj) const
109                 {
110                         return obj.GetHashCode();
111                 }
112 };
113
114 template<>
115 class __MultiHashMapDefaultProviderT<String>
116 : public IHashCodeProviderT<String>
117 , public Object
118 {
119         public:
120                 __MultiHashMapDefaultProviderT(void) {}
121
122                 virtual ~__MultiHashMapDefaultProviderT(void) {}
123
124                 virtual int GetHashCode(const String& obj) const
125                 {
126                         return obj.GetHashCode();
127                 }
128 };
129
130
131 } // Collection
132
133 }} // Tizen::Base
134
135 #endif //_FAPP_INTERNAL_TEMPLATE_UTIL_H_
136