use explicit template initialization
authorYoung Ik Cho <youngik.cho@samsung.com>
Fri, 9 Aug 2013 12:18:44 +0000 (21:18 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Fri, 9 Aug 2013 12:24:34 +0000 (21:24 +0900)
Change-Id: Ifb496daf7d04bdbc059d2075102f154d76ff1f67
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
src/app/CMakeLists.txt
src/app/FApp_AppControlImpl.cpp
src/app/FApp_AppControlManager.cpp
src/app/FApp_AppControlRegistry.cpp
src/app/FApp_AppControlRegistry.h
src/app/FApp_RequestManagerT.cpp [new file with mode: 0644]
src/app/FApp_ServiceAppImpl.cpp
src/app/inc/FApp_AppControlManager.h
src/app/inc/FApp_LaunchInfo.h [new file with mode: 0644]
src/app/inc/FApp_RequestManagerT.h

index 6ba1638..86c07e8 100644 (file)
@@ -66,6 +66,7 @@ SET (${this_target}_SOURCE_FILES
        FApp_AppControlResponseEvent.cpp
        FApp_AppLifecycleEvent.cpp
        FApp_ActiveWindowManager.cpp
+       FApp_RequestManagerT.cpp
        )
 
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SINGLETON_CLEANUP -fvisibility=hidden")
index 496370c..74205ff 100644 (file)
 
 #include <appsvc/appsvc.h>
 
+#include <FBaseColHashMap.h>
+#include <FBaseSysLog.h>
 #include <FAppAppControl.h>
 #include <FAppAppManager.h>
 #include <FAppPkgPackageAppInfo.h>
-#include <FBaseColHashMap.h>
-#include <FBaseSysLog.h>
+#include <FAppIAppControlEventListener.h>
+#include <FAppIAppControlResponseListener.h>
 
 #include <FBaseRt_LibraryImpl.h>
 #include <FIo_DirectoryImpl.h>
@@ -63,9 +65,6 @@ static const int _REQ_ID_INVALID = -1;
 namespace Tizen { namespace App
 {
 
-class IAppControlEventListener;
-class IAppControlResponseListener;
-
 const wchar_t TIZEN_OPERATION_MAIN[] = L"http://tizen.org/appcontrol/operation/main";
 
 _AppControlImpl::_AppControlImpl(const AppControl& value)
index 4e264ab..8a8730a 100644 (file)
@@ -910,6 +910,12 @@ _AppControlManager::FinishAppControl(int reqId, int res, IMap* pMap)
        SysLog(NID_APP, "Exit.");
 }
 
+void
+_AppControlManager::RemoveResultRequest(int reqId)
+{
+       __resultManager.RemoveItem(reqId);
+}
+
 const _AppArg*
 _AppControlManager::FindResultRequest(int reqId) const
 {
index 8bcb653..4e09423 100644 (file)
@@ -291,7 +291,7 @@ CATCH:
 
 
 AppControl*
-_AppControlRegistry::GetTizenAppControlN(const String& aId, const String& oId)
+_AppControlRegistry::GetTizenAppControlN(const String& aId, const String& oId) const
 {
        int count = 0;
        const String* pAppId = &aId;
index 8554d54..c9f8201 100644 (file)
@@ -85,7 +85,7 @@ public:
 
        static _AppControlRegistry* GetInstance(void);
 
-       AppControl* GetTizenAppControlN(const Tizen::Base::String& aId, const Tizen::Base::String& oId);
+       AppControl* GetTizenAppControlN(const Tizen::Base::String& aId, const Tizen::Base::String& oId) const;
 
        AppControl* GetAppControlN(const Tizen::Base::String& appId, const Tizen::Base::String& operationId) const;
 
@@ -121,7 +121,7 @@ private:
 
        AliasMapType __aliasAppId;
 
-       RuntimeAliasType __runtimeAlias;
+       mutable RuntimeAliasType __runtimeAlias;
 
        static _AppControlRegistry* __pSelf;
 }; // _AppControlRegistry
diff --git a/src/app/FApp_RequestManagerT.cpp b/src/app/FApp_RequestManagerT.cpp
new file mode 100644 (file)
index 0000000..1457e58
--- /dev/null
@@ -0,0 +1,169 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FApp_RequestManagerT.cpp
+ * @brief      This is the implementationfor the _RequestManagerT class.
+ */
+
+#include <limits.h>
+
+#include "FApp_RequestManagerT.h"
+#include "FApp_LaunchInfo.h"
+
+
+namespace Tizen { namespace App
+{
+
+template<typename T>
+_RequestManagerT<T>::_RequestManagerT(void)
+: __reqId(-1)
+{
+       __requestList.Construct();
+}
+
+template<typename T>
+_RequestManagerT<T>::~_RequestManagerT(void)
+{
+       RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
+       if (pIter == null)
+       {
+               return;
+       }
+
+       while (pIter->MoveNext() == E_SUCCESS)
+       {
+               T* pInfo = null;
+               result r = pIter->GetValue(pInfo);
+
+               if (IsFailed(r))
+               {
+                       continue;
+               }
+
+               delete pInfo;
+       }
+
+       delete pIter;
+}
+
+template<typename T> int
+_RequestManagerT<T>::InsertItem(T* pItem)
+{
+       SysTryReturn(NID_APP, pItem != null, -1, E_INVALID_ARG, "[E_INVALID_ARG] Empty argument.");
+
+#if 0
+       // [INFO] temporary disable due to OBS build system
+       __sync_add_and_fetch(&__reqId, 1);
+
+       // [TODO] awkward implementation after overflow
+       // overflow detection
+       __sync_bool_compare_and_swap(&__reqId, INT_MAX, 1);
+#else
+       __reqId++;
+       if (__reqId >= INT_MAX)
+       {
+               __reqId = 1;
+       }
+#endif
+       SysLog(NID_APP, "Current request ID : %d.", __reqId);
+
+       pItem->reqId = __reqId;
+       __requestList.Add(__reqId, pItem);
+
+       return __reqId;
+}
+
+template<typename T> void
+_RequestManagerT<T>::RemoveItem(int reqId)
+{
+       T* pItem = FindItem(reqId);
+       if (pItem)
+       {
+               __requestList.Remove(reqId);
+               delete pItem;
+       }
+}
+
+template<typename T> void
+_RequestManagerT<T>::RemoveItem(T* pItem)
+{
+       RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
+       if (pItem == null || pIter == null)
+       {
+               return;
+       }
+
+       while (pIter->MoveNext() == E_SUCCESS)
+       {
+               T* pInfo = null;
+               result r = pIter->GetValue(pInfo);
+
+               if (pInfo == pItem)
+               {
+                       int id = -1;
+                       r = pIter->GetKey(id);
+                       if (r == E_SUCCESS)
+                       {
+                               __requestList.Remove(id);
+                       }
+
+                       delete pItem;
+                       delete pIter;
+
+                       return;
+               }
+       }
+
+       delete pIter;
+}
+
+template<typename T> T*
+_RequestManagerT<T>::FindItem(int reqId) const
+{
+       T* pItem = null;
+       result r = __requestList.GetValue(reqId, pItem);
+
+       return (r == E_SUCCESS) ? pItem : null;
+}
+
+
+// partial specialization
+template<> void
+_RequestManagerT<_ResultInfo>::RemoveItem(int reqId)
+{
+       // 1st request is launch request itself and do not remove it ever.
+       if (reqId == 0)
+       {
+               return;
+       }
+
+       _ResultInfo* pItem = FindItem(reqId);
+       if (pItem)
+       {
+               __requestList.Remove(reqId);
+               delete pItem;
+       }
+}
+
+
+// explicit template initialization
+template class _RequestManagerT<_LaunchInfo>;
+template class _RequestManagerT<_InProcessInfo>;
+template class _RequestManagerT<_ResultInfo>;
+
+} } // Tizen::App
+
index d4011cd..dd80c88 100644 (file)
@@ -55,7 +55,7 @@ static const RequestId  HANDLER_REQUEST_ALARMID = 2;
 namespace Tizen { namespace App
 {
 
-static const wchar_t* ALARM_PLUGIN_LIBRARY_PATH = L"/opt/apps/aospd00043/lib/libosp-cond-alarm.so";
+static const wchar_t* ALARM_PLUGIN_LIBRARY_PATH = L"/opt/usr/apps/aospd00043/lib/libosp-cond-alarm.so";
 typedef void (*OnAlarmForLaunch)(int alarmId);
 
 _ServiceAppImpl* _ServiceAppImpl::__pServiceAppImpl = null;
index 38c0246..002c73b 100644 (file)
 #include <FOspConfig.h>
 #include <FBaseColArrayListT.h>
 #include <FBaseObject.h>
-#include <FBaseString.h>
 #include <FBaseRtIEventListener.h>
 #include <FAppTypes.h>
-#include <FAppIAppControlEventListener.h>
-#include <FAppIAppControlResponseListener.h>
 #include <FBaseSysLog.h>
 
 #include "FApp_Types.h"
 #include "FApp_IAppManagerServiceEventListener.h"
 #include "FApp_RequestManagerT.h"
 #include "FApp_IAppControlResponseEventListener.h"
+#include "FApp_LaunchInfo.h"
 
 namespace Tizen { namespace Base
 {
 class String;
-namespace Runtime
-{
-class _LibraryImpl;
-}
 namespace Collection
 {
 class IMap;
@@ -72,123 +66,14 @@ class _IAppManagerEventListener;
 class _AppManagerEventArg;
 class _AppMessageImpl;
 class _AppControlResponseEvent;
-
-typedef result (*LaunchCbType)(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId);
+class IAppControlEventListener;
+class IAppControlResponseListener;
 
 typedef void (*AppSvcResFn)(void* b, int requestCode, service_result_e res, void* data);
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// _LaunchInfo handles the launch request from this process
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-const long LAUNCH_INFO_MAGIC = 0x494C;
 const int RESPONSE_EVENT_REQID_MAGIC = 65536;
 
-class _LaunchInfo
-{
-public:
-       _LaunchInfo(_AppArg* pArg, LaunchCbType pCb, void* pData, int prop)
-               : magic(LAUNCH_INFO_MAGIC)
-               , reqId(-1)
-               , pArg(pArg)
-               , launchCb(pCb)
-               , pUserData(pData)
-               , property(prop)
-       {
-       }
-
-       ~_LaunchInfo(void);
-
-private:
-       _LaunchInfo(const _LaunchInfo& rhs);
-       _LaunchInfo& operator =(const _LaunchInfo& rhs);
-
-public:
-       const long      magic;
-       int reqId;
-       _AppArg* pArg;
-       const LaunchCbType launchCb;
-       void* pUserData;
-       int property;
-}; // _LaunchInfo
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// _InAppRequestManager manges In-process AppControl request
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-struct _InProcessInfo
-{
-public:
-       _InProcessInfo(const Tizen::Base::String& aId, const Tizen::Base::String& oId, int prop, bool legacy, Tizen::Base::Runtime::_LibraryImpl& lib, Tizen::Base::Runtime::IEventListener* pListener)
-               : reqId(-1)
-               , providerId(aId)
-               , operationId(oId)
-               , property(prop)
-               , pLib(&lib)
-               , pListener(pListener)
-               , isLegacy(legacy)
-       {
-       }
-
-       ~_InProcessInfo(void);
-
-private:
-       _InProcessInfo(const _InProcessInfo& rhs);
-       _InProcessInfo& operator =(const _InProcessInfo& rhs);
-
-public:
-       int reqId;
-       const Tizen::Base::String providerId;
-       const Tizen::Base::String operationId;
-       const int property;
-       Tizen::Base::Runtime::_LibraryImpl* pLib;       // non-empty
-       Tizen::Base::Runtime::IEventListener* pListener;
-       bool isLegacy;
-}; // _InProcessInfo
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// _RequestManager manges out-of-process launch request and handles the return arguments
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-class _ResultInfo
-{
-public:
-       _ResultInfo(_AppArg& arg)
-               : reqId(-1)
-               , arg(arg)
-       {
-       }
-
-       ~_ResultInfo(void)
-       {
-       }
-
-private:
-       _ResultInfo(const _ResultInfo& rhs);
-       _ResultInfo& operator =(const _ResultInfo& rhs);
-
-public:
-       int reqId;
-       _AppArg& arg;
-}; // _ResultInfo
-
-// partial specialization
-template<> inline void _RequestManagerT<_ResultInfo>::RemoveItem(int reqId)
-{
-       // 1st request is launch request itself and do not remove it ever.
-       if (reqId == 0)
-       {
-               return;
-       }
-
-       _ResultInfo* pItem = FindItem(reqId);
-       if (pItem)
-       {
-               __requestList.Remove(reqId);
-               delete pItem;
-       }
-}
-
 
 class _OSP_EXPORT_ _AppControlManager
        : public Tizen::Base::Object
@@ -238,12 +123,10 @@ public:
        _OSP_LOCAL_ result SendAppControlEvent(Tizen::Base::Runtime::IEventArg& arg);
 
        _OSP_LOCAL_ Tizen::Base::Collection::IMapT<int,_AppControlResponseEvent*>* GetAppControlResponseEventContainer(void);
+
        _OSP_LOCAL_ result RegisterRequest(service_s* service, int& req, _AppHandler& handler);
 
-       _OSP_LOCAL_ void RemoveResultRequest(int reqId)
-       {
-               __resultManager.RemoveItem(reqId);
-       }
+       _OSP_LOCAL_ void RemoveResultRequest(int reqId);
 
        const _AppArg* FindResultRequest(int reqId) const;
 
diff --git a/src/app/inc/FApp_LaunchInfo.h b/src/app/inc/FApp_LaunchInfo.h
new file mode 100644 (file)
index 0000000..e8f6251
--- /dev/null
@@ -0,0 +1,145 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FApp_LaunchInfo.h
+ * @brief      This is the header file for the _LaunchInfo class.
+ */
+
+#ifndef _FAPP_INTERNAL_LAUNCH_INFO_H_
+#define _FAPP_INTERNAL_LAUNCH_INFO_H_
+
+#include <app_service.h>
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FAppTypes.h>
+
+namespace Tizen { namespace Base
+{
+namespace Runtime
+{
+class _LibraryImpl;
+class IEventListener;
+}
+}}
+
+namespace Tizen { namespace App
+{
+
+class _AppArg;
+
+typedef result (*LaunchCbType)(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// _LaunchInfo handles the launch request from this process
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+const long LAUNCH_INFO_MAGIC = 0x494C;
+
+class _LaunchInfo
+{
+public:
+       _LaunchInfo(_AppArg* pArg, LaunchCbType pCb, void* pData, int prop)
+               : magic(LAUNCH_INFO_MAGIC)
+               , reqId(-1)
+               , pArg(pArg)
+               , launchCb(pCb)
+               , pUserData(pData)
+               , property(prop)
+       {
+       }
+
+       ~_LaunchInfo(void);
+
+private:
+       _LaunchInfo(const _LaunchInfo& rhs);
+       _LaunchInfo& operator =(const _LaunchInfo& rhs);
+
+public:
+       const long      magic;
+       int reqId;
+       _AppArg* pArg;
+       const LaunchCbType launchCb;
+       void* pUserData;
+       int property;
+}; // _LaunchInfo
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// _InAppRequestManager manges In-process AppControl request
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+struct _InProcessInfo
+{
+public:
+       _InProcessInfo(const Tizen::Base::String& aId, const Tizen::Base::String& oId, int prop, bool legacy, Tizen::Base::Runtime::_LibraryImpl& lib, Tizen::Base::Runtime::IEventListener* pListener)
+               : reqId(-1)
+               , providerId(aId)
+               , operationId(oId)
+               , property(prop)
+               , pLib(&lib)
+               , pListener(pListener)
+               , isLegacy(legacy)
+       {
+       }
+
+       ~_InProcessInfo(void);
+
+private:
+       _InProcessInfo(const _InProcessInfo& rhs);
+       _InProcessInfo& operator =(const _InProcessInfo& rhs);
+
+public:
+       int reqId;
+       const Tizen::Base::String providerId;
+       const Tizen::Base::String operationId;
+       const int property;
+       Tizen::Base::Runtime::_LibraryImpl* pLib;       // non-empty
+       Tizen::Base::Runtime::IEventListener* pListener;
+       bool isLegacy;
+}; // _InProcessInfo
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// _RequestManager manges out-of-process launch request and handles the return arguments
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+class _ResultInfo
+{
+public:
+       _ResultInfo(_AppArg& arg)
+               : reqId(-1)
+               , arg(arg)
+       {
+       }
+
+       ~_ResultInfo(void)
+       {
+       }
+
+private:
+       _ResultInfo(const _ResultInfo& rhs);
+       _ResultInfo& operator =(const _ResultInfo& rhs);
+
+public:
+       int reqId;
+       _AppArg& arg;
+}; // _ResultInfo
+
+
+}} // Tizen::App
+
+#endif // _FAPP_INTERNAL_LAUNCH_INFO_H_
index 7e3edc1..ff1e57a 100644 (file)
 #ifndef _FAPP_INTERNAL_REQUEST_MANAGERT_H_
 #define _FAPP_INTERNAL_REQUEST_MANAGERT_H_
 
-#include <limits.h>
-
 #include <FOspConfig.h>
 #include <FBaseColHashMapT.h>
-
 #include <FBaseSysLog.h>
 
-namespace Tizen { namespace Base
-{
-class String;
-}}
-
 namespace Tizen { namespace App
 {
 
@@ -44,111 +36,17 @@ public:
        typedef Tizen::Base::Collection::HashMapT<int, T*> RequestListType;
        typedef Tizen::Base::Collection::IMapEnumeratorT<int, T*> RequestListEnumType;
 
-       _RequestManagerT(void)
-               : __reqId(-1)
-       {
-               __requestList.Construct();
-       }
-
-       ~_RequestManagerT(void)
-       {
-               RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
-               if (pIter == null)
-               {
-                       return;
-               }
-
-               while (pIter->MoveNext() == E_SUCCESS)
-               {
-                       T* pInfo = null;
-                       result r = pIter->GetValue(pInfo);
-
-                       if (IsFailed(r))
-                       {
-                               continue;
-                       }
-
-                       delete pInfo;
-               }
-
-               delete pIter;
-       }
-
-       int InsertItem(T* pItem)
-       {
-               SysTryReturn(NID_APP, pItem != null, -1, E_INVALID_ARG, "[E_INVALID_ARG] Empty argument.");
-
-#if 0
-               // [INFO] temporary disable due to OBS build system
-               __sync_add_and_fetch(&__reqId, 1);
-
-               // [TODO] awkward implementation after overflow
-               // overflow detection
-               __sync_bool_compare_and_swap(&__reqId, INT_MAX, 1);
-#else
-               __reqId++;
-               if (__reqId >= INT_MAX)
-               {
-                       __reqId = 1;
-               }
-#endif
-               SysLog(NID_APP, "Current request ID : %d.", __reqId);
-
-               pItem->reqId = __reqId;
-               __requestList.Add(__reqId, pItem);
-
-               return __reqId;
-       }
-
-       void RemoveItem(int reqId)
-       {
-               T* pItem = FindItem(reqId);
-               if (pItem)
-               {
-                       __requestList.Remove(reqId);
-                       delete pItem;
-               }
-       }
-
-       void RemoveItem(T* pItem)
-       {
-               RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
-               if (pItem == null || pIter == null)
-               {
-                       return;
-               }
-
-               while (pIter->MoveNext() == E_SUCCESS)
-               {
-                       T* pInfo = null;
-                       result r = pIter->GetValue(pInfo);
-
-                       if (pInfo == pItem)
-                       {
-                               int id = -1;
-                               r = pIter->GetKey(id);
-                               if (r == E_SUCCESS)
-                               {
-                                       __requestList.Remove(id);
-                               }
-
-                               delete pItem;
-                               delete pIter;
-
-                               return;
-                       }
-               }
-
-               delete pIter;
-       }
-
-       T* FindItem(int reqId) const
-       {
-               T* pItem = null;
-               result r = __requestList.GetValue(reqId, pItem);
-
-               return (r == E_SUCCESS) ? pItem : null;
-       }
+       _RequestManagerT(void);
+
+       ~_RequestManagerT(void);
+
+       int InsertItem(T* pItem);
+
+       void RemoveItem(int reqId);
+
+       void RemoveItem(T* pItem);
+
+       T* FindItem(int reqId) const;
 
 private:
        _RequestManagerT(const T& rhs);
@@ -160,6 +58,7 @@ private:
        RequestListType __requestList;
 }; // _RequestManagerT
 
+
 } } // Tizen::App
 
 #endif // _FAPP_INTERNAL_REQUEST_MANAGERT_H_