Adaptor refactor
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / lifecycle-controller-impl.h
1 #ifndef __DALI_INTERNAL_LIFECYCLE_CONTROLLER_H__
2 #define __DALI_INTERNAL_LIFECYCLE_CONTROLLER_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/public-api/object/base-object.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/devel-api/adaptor-framework/lifecycle-controller.h>
27 #include <dali/public-api/adaptor-framework/application.h>
28
29 namespace Dali
30 {
31
32 class Adaptor;
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39
40 /**
41  * This provides signals that are emitted according the lifecylce of the program.
42  */
43 class LifecycleController : public BaseObject, public ConnectionTracker
44 {
45 public:
46
47   // Creation & Destruction
48
49   /**
50    * Constructor.
51    */
52   LifecycleController();
53
54   /**
55    * Retrieve the initialized instance of the LifecycleController.
56    * @return Handle to LifecycleController.
57    */
58   static Dali::LifecycleController Get();
59
60   // Signals
61
62   /**
63    * @copydoc Dali::StyleMonitor::InitSignal()
64    */
65   Dali::LifecycleController::LifecycleSignalType& InitSignal();
66
67   /**
68    * @copydoc Dali::StyleMonitor::TerminateSignal()
69    */
70   Dali::LifecycleController::LifecycleSignalType& TerminateSignal();
71
72   /**
73    * @copydoc Dali::StyleMonitor::PauseSignal()
74    */
75   Dali::LifecycleController::LifecycleSignalType& PauseSignal();
76
77   /**
78    * @copydoc Dali::StyleMonitor::ResumeSignal()
79    */
80   Dali::LifecycleController::LifecycleSignalType& ResumeSignal();
81
82   /**
83    * @copydoc Dali::StyleMonitor::ResetSignal()
84    */
85   Dali::LifecycleController::LifecycleSignalType& ResetSignal();
86
87   /**
88    * @copydoc Dali::StyleMonitor::ResizeSignal()
89    */
90   Dali::LifecycleController::LifecycleSignalType& ResizeSignal();
91
92   /**
93    * @copydoc Dali::StyleMonitor::LanguageChangedSignal()
94    */
95   Dali::LifecycleController::LifecycleSignalType& LanguageChangedSignal();
96
97 public:
98
99   /**
100    * Called when the framework is initialised.
101    *
102    * @param[in] app The application instance
103    */
104   void OnInit( Dali::Application& app );
105
106   /**
107    * Called when the framework is terminated.
108    *
109    * @param[in] app The application instance
110    */
111   void OnTerminate( Dali::Application& app );
112
113   /**
114    * Called when the framework is paused.
115    *
116    * @param[in] app The application instance
117    */
118   void OnPause( Dali::Application& app );
119
120   /**
121    * Called when the framework resumes from a paused state.
122    *
123    * @param[in] app The application instance
124    */
125   void OnResume( Dali::Application& app );
126
127   /**
128    * Called when the framework informs the application that it should reset itself.
129    *
130    * @param[in] app The application instance
131    */
132   void OnReset( Dali::Application& app );
133
134   /**
135    * Called when the framework informs the application that the language of the device has changed.
136    *
137    * @param[in] app The application instance
138    */
139   void OnLanguageChanged( Dali::Application& app );
140
141   /**
142    * Signal handler when the adaptor's window resizes itself.
143    *
144    * @param[in] app The application instance
145    */
146   void OnResize( Dali::Application& app );
147
148 protected:
149
150   /**
151    * Virtual Destructor.
152    */
153   virtual ~LifecycleController();
154
155 private:
156
157   /**
158    * Emit the init signal.
159    */
160   void EmitInitSignal();
161
162   /**
163    * Emit the init signal.
164    */
165   void EmitTerminateSignal();
166
167   /**
168    * Emit the init signal.
169    */
170   void EmitPauseSignal();
171
172   /**
173    * Emit the init signal.
174    */
175   void EmitResumeSignal();
176
177   /**
178    * Emit the init signal.
179    */
180   void EmitResetSignal();
181
182   /**
183    * Emit the init signal.
184    */
185   void EmitResizeSignal();
186
187   /**
188    * Emit the init signal.
189    */
190   void EmitLanguageChangedSignal();
191
192 private:
193
194   // Signals
195   Dali::LifecycleController::LifecycleSignalType mInitSignal;
196   Dali::LifecycleController::LifecycleSignalType mTerminateSignal;
197   Dali::LifecycleController::LifecycleSignalType mPauseSignal;
198   Dali::LifecycleController::LifecycleSignalType mResumeSignal;
199   Dali::LifecycleController::LifecycleSignalType mResetSignal;
200   Dali::LifecycleController::LifecycleSignalType mResizeSignal;
201   Dali::LifecycleController::LifecycleSignalType mLanguageChangedSignal;
202
203 };
204
205 } // namespace Adaptor
206
207 } // namespace Internal
208
209 // Additional Helpers for public-api forwarding methods
210
211 inline Internal::Adaptor::LifecycleController& GetImplementation(Dali::LifecycleController& controller)
212 {
213   DALI_ASSERT_ALWAYS(controller && "Controller handle is empty");
214   BaseObject& handle = controller.GetBaseObject();
215   return static_cast<Internal::Adaptor::LifecycleController&>(handle);
216 }
217
218 inline const Internal::Adaptor::LifecycleController& GetImplementation(const Dali::LifecycleController& controller)
219 {
220   DALI_ASSERT_ALWAYS(controller && "Controller handle is empty");
221   const BaseObject& handle = controller.GetBaseObject();
222   return static_cast<const Internal::Adaptor::LifecycleController&>(handle);
223 }
224
225 } // namespace Dali
226
227 #endif // __DALI_INTERNAL_LIFECYCLE_CONTROLLER_H__