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 FUiScenesSceneManager.cpp
19 * @brief This is the implementation file of the SceneManager class.
26 #include <FUiScenesSceneManager.h>
27 #include <FBaseSysLog.h>
28 #include "FUiScenes_SceneImpl.h"
29 #include "FUiScenes_SceneManagerImpl.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::App;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui::Animations;
39 namespace Tizen { namespace Ui { namespace Scenes
42 SceneManager* SceneManager::__pSceneManagerInstance = null;
44 SceneManager::SceneManager(void)
45 : __pSceneManagerImpl(null)
50 SceneManager::~SceneManager(void)
52 delete __pSceneManagerImpl;
56 SceneManager::GetInstance(void)
58 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
60 if (!__pSceneManagerInstance)
63 pthread_once(&onceBlock, InitSingleton);
64 result r = GetLastResult();
67 onceBlock = PTHREAD_ONCE_INIT;
71 return __pSceneManagerInstance;
75 SceneManager::Construct(void)
79 __pSceneManagerImpl = new (std::nothrow) _SceneManagerImpl;
80 SysTryReturnResult(NID_UI_SCENES, __pSceneManagerImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
81 GetErrorMessage(E_OUT_OF_MEMORY));
83 r = __pSceneManagerImpl->Construct();
84 SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
89 SceneManager::RegisterFormFactory(const IFormFactory& formFactory)
91 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
92 __pSceneManagerImpl->RegisterFormFactory(formFactory);
98 SceneManager::RegisterPanelFactory(const IPanelFactory& panelFactory)
100 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
101 __pSceneManagerImpl->RegisterPanelFactory(panelFactory);
106 SceneManager::RegisterScene(const SceneId& sceneId, const String& formId, const String& panelId)
108 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
109 return __pSceneManagerImpl->RegisterScene(sceneId, formId, panelId);
113 SceneManager::RegisterScene(const String& resourceId)
115 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
116 return __pSceneManagerImpl->RegisterScene(resourceId);
120 SceneManager::UnregisterScene(const SceneId& sceneId)
122 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
123 return __pSceneManagerImpl->UnregisterScene(sceneId);
127 SceneManager::AddSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener)
129 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
130 return __pSceneManagerImpl->AddSceneManagerEventListener(sceneManagerEventListener);
134 SceneManager::RemoveSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener)
136 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
137 return __pSceneManagerImpl->RemoveSceneManagerEventListener(sceneManagerEventListener);
141 SceneManager::AddSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener)
143 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
144 return __pSceneManagerImpl->AddSceneEventListener(sceneId, sceneEventListener);
148 SceneManager::RemoveSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener)
150 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
151 return __pSceneManagerImpl->RemoveSceneEventListener(sceneId, sceneEventListener);
155 SceneManager::SetSceneAnimationProvider(const SceneId& sceneId, ISceneAnimationProvider* pSceneAnimationProvider)
157 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
158 return __pSceneManagerImpl->SetSceneAnimationProvider(sceneId, pSceneAnimationProvider);
162 SceneManager::SetSceneTransitionPolicyProvider(ISceneTransitionPolicyProvider* pSceneTransitionPolicyProvider)
164 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
165 return __pSceneManagerImpl->SetSceneTransitionPolicyProvider(pSceneTransitionPolicyProvider);
169 SceneManager::SetFormTransitionAnimationDefaultValues(SceneTransitionAnimationType animationType, long duration,
170 AnimationInterpolatorType interpolatorType)
172 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
173 return __pSceneManagerImpl->SetFormTransitionAnimationDefaultValues(animationType, duration, interpolatorType);
177 SceneManager::GoForward(const ForwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs)
179 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
180 return __pSceneManagerImpl->GoForward(sceneTransition, pArgs);
184 SceneManager::GoForward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs)
186 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
187 return __pSceneManagerImpl->GoForward(transitionId, pArgs);
191 SceneManager::GoBackward(const BackwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs)
193 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
194 return __pSceneManagerImpl->GoBackward(sceneTransition, pArgs);
198 SceneManager::GoBackward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs)
200 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
201 return __pSceneManagerImpl->GoBackward(transitionId, pArgs);
205 SceneManager::GetCurrentScene(void) const
207 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
208 return __pSceneManagerImpl->GetCurrentScene();
212 SceneManager::GetCurrentSceneId(void) const
214 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
215 return __pSceneManagerImpl->GetCurrentSceneId();
219 SceneManager::IsSceneAlive(const SceneId& sceneId) const
221 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
222 return __pSceneManagerImpl->IsSceneAlive(sceneId);
226 SceneManager::DestroyScene(const SceneId& sceneId)
228 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
229 return __pSceneManagerImpl->DestroyScene(sceneId);
233 SceneManager::BringCurrentSceneToTop(void)
235 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
236 return __pSceneManagerImpl->BringCurrentSceneToTop();
240 SceneManager::ClearSceneHistory(void)
242 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
243 return __pSceneManagerImpl->ClearSceneHistory();
247 SceneManager::AddToSceneHistory(const SceneId& sceneId)
249 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
250 return __pSceneManagerImpl->AddToSceneHistory(sceneId);
254 SceneManager::GetSceneHistoryN(void) const
257 SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use");
258 return __pSceneManagerImpl->GetSceneHistoryN();
262 SceneManager::InitSingleton(void)
264 SceneManager* pInst = new (std::nothrow) SceneManager();
265 SysTryReturnVoidResult(NID_UI_SCENES, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
266 GetErrorMessage(E_OUT_OF_MEMORY));
268 result r = pInst->Construct();
269 SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
271 __pSceneManagerInstance = pInst;
272 std::atexit(DestroySingleton);
280 SceneManager::DestroySingleton(void)
282 delete __pSceneManagerInstance;
286 } } } // Tizen::Ui::Scenes