2 * Copyright (c) 2014 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.
19 #include "lifecycle-controller-impl.h"
22 #include <dali/public-api/object/type-registry.h>
25 #include <adaptor-impl.h>
26 #include <singleton-service-impl.h>
42 BaseHandle handle( LifecycleController::Get() );
44 if ( !handle && Adaptor::IsAvailable() )
46 Dali::SingletonService service( SingletonService::Get() );
49 Dali::LifecycleController lifecycleController = Dali::LifecycleController( new LifecycleController() );
50 service.Register( typeid( lifecycleController ), lifecycleController );
51 handle = lifecycleController;
57 TypeRegistration LIFECYCLE_CONTROLLER_TYPE( typeid(Dali::LifecycleController), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
59 } // unnamed namespace
61 Dali::LifecycleController LifecycleController::Get()
63 Dali::LifecycleController lifecycleController;
65 Dali::SingletonService service( SingletonService::Get() );
68 // Check whether the singleton is already created
69 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::LifecycleController ) );
72 // If so, downcast the handle
73 lifecycleController = Dali::LifecycleController( dynamic_cast< LifecycleController* >( handle.GetObjectPtr() ) );
77 lifecycleController = Dali::LifecycleController( new LifecycleController() );
78 service.Register( typeid( lifecycleController ), lifecycleController );
82 return lifecycleController;
85 LifecycleController::LifecycleController()
89 LifecycleController::~LifecycleController()
93 Dali::LifecycleController::LifecycleSignalType& LifecycleController::InitSignal()
98 void LifecycleController::EmitInitSignal()
100 if( !mInitSignal.Empty() )
106 Dali::LifecycleController::LifecycleSignalType& LifecycleController::TerminateSignal()
108 return mTerminateSignal;
111 void LifecycleController::EmitTerminateSignal()
113 if( !mTerminateSignal.Empty() )
115 mTerminateSignal.Emit();
119 Dali::LifecycleController::LifecycleSignalType& LifecycleController::PauseSignal()
124 void LifecycleController::EmitPauseSignal()
126 if( !mPauseSignal.Empty() )
132 Dali::LifecycleController::LifecycleSignalType& LifecycleController::ResumeSignal()
134 return mResumeSignal;
137 void LifecycleController::EmitResumeSignal()
139 if( !mResumeSignal.Empty() )
141 mResumeSignal.Emit();
145 Dali::LifecycleController::LifecycleSignalType& LifecycleController::ResetSignal()
150 void LifecycleController::EmitResetSignal()
152 if( !mResetSignal.Empty() )
158 Dali::LifecycleController::LifecycleSignalType& LifecycleController::ResizeSignal()
160 return mResizeSignal;
163 void LifecycleController::EmitResizeSignal()
165 if( !mResizeSignal.Empty() )
167 mResizeSignal.Emit();
171 Dali::LifecycleController::LifecycleSignalType& LifecycleController::LanguageChangedSignal()
173 return mLanguageChangedSignal;
176 void LifecycleController::EmitLanguageChangedSignal()
178 if( !mLanguageChangedSignal.Empty() )
180 mLanguageChangedSignal.Emit();
184 void LifecycleController::OnInit( Dali::Application& app )
189 void LifecycleController::OnTerminate( Dali::Application& app )
191 EmitTerminateSignal();
194 void LifecycleController::OnPause( Dali::Application& app )
199 void LifecycleController::OnResume( Dali::Application& app )
204 void LifecycleController::OnReset( Dali::Application& app )
209 void LifecycleController::OnLanguageChanged( Dali::Application& app )
211 EmitLanguageChangedSignal();
214 void LifecycleController::OnResize( Dali::Application& app )
219 } // namespace Adaptor
221 } // namespace Internal