2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FApp_RequestManagerT.cpp
19 * @brief This is the implementationfor the _RequestManagerT class.
24 #include "FApp_RequestManagerT.h"
25 #include "FApp_LaunchInfo.h"
26 #include "FApp_AppArg.h"
29 namespace Tizen { namespace App
32 _ResultInfo::~_ResultInfo(void)
40 _RequestManagerT<T>::_RequestManagerT(void)
43 __requestList.Construct();
47 _RequestManagerT<T>::~_RequestManagerT(void)
49 RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
55 while (pIter->MoveNext() == E_SUCCESS)
58 result r = pIter->GetValue(pInfo);
71 template<typename T> int
72 _RequestManagerT<T>::InsertItem(T* pItem)
74 SysTryReturn(NID_APP, pItem != null, -1, E_INVALID_ARG, "[E_INVALID_ARG] Empty argument.");
77 // [INFO] temporary disable due to OBS build system
78 __sync_add_and_fetch(&__reqId, 1);
80 // [TODO] awkward implementation after overflow
82 __sync_bool_compare_and_swap(&__reqId, INT_MAX, 1);
85 if (__reqId >= INT_MAX)
90 SysLog(NID_APP, "Current request ID : %d.", __reqId);
92 pItem->reqId = __reqId;
93 __requestList.Add(__reqId, pItem);
98 template<typename T> void
99 _RequestManagerT<T>::RemoveItem(int reqId)
101 T* pItem = FindItem(reqId);
104 __requestList.Remove(reqId);
109 template<typename T> void
110 _RequestManagerT<T>::RemoveItem(T* pItem)
112 RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
113 if (pItem == null || pIter == null)
118 while (pIter->MoveNext() == E_SUCCESS)
121 result r = pIter->GetValue(pInfo);
126 r = pIter->GetKey(id);
129 __requestList.Remove(id);
142 template<typename T> T*
143 _RequestManagerT<T>::FindItem(int reqId) const
146 result r = __requestList.GetValue(reqId, pItem);
148 return (r == E_SUCCESS) ? pItem : null;
154 _RequestManagerT<_ResultInfo>::~_RequestManagerT(void)
157 _ResultInfo* pItem = FindItem(0);
160 __requestList.Remove(0);
165 RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
171 while (pIter->MoveNext() == E_SUCCESS)
173 _ResultInfo* pInfo = null;
174 result r = pIter->GetValue(pInfo);
189 _RequestManagerT<_ResultInfo>::RemoveItem(int reqId)
191 // 1st request is launch request itself and do not remove it ever.
197 _ResultInfo* pItem = FindItem(reqId);
200 __requestList.Remove(reqId);
206 // explicit template initialization
207 template class _RequestManagerT<_LaunchInfo>;
208 template class _RequestManagerT<_InProcessInfo>;
209 template class _RequestManagerT<_ResultInfo>;