Merge "Changed 'virtual' function override declarations to 'override' in automated...
[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) 2020 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::LanguageChangedSignal()
89    */
90   Dali::LifecycleController::LifecycleSignalType& LanguageChangedSignal();
91
92 public:
93
94   /**
95    * Called when the framework is initialised.
96    *
97    * @param[in] app The application instance
98    */
99   void OnInit( Dali::Application& app );
100
101   /**
102    * Called when the framework is terminated.
103    *
104    * @param[in] app The application instance
105    */
106   void OnTerminate( Dali::Application& app );
107
108   /**
109    * Called when the framework is paused.
110    *
111    * @param[in] app The application instance
112    */
113   void OnPause( Dali::Application& app );
114
115   /**
116    * Called when the framework resumes from a paused state.
117    *
118    * @param[in] app The application instance
119    */
120   void OnResume( Dali::Application& app );
121
122   /**
123    * Called when the framework informs the application that it should reset itself.
124    *
125    * @param[in] app The application instance
126    */
127   void OnReset( Dali::Application& app );
128
129   /**
130    * Called when the framework informs the application that the language of the device has changed.
131    *
132    * @param[in] app The application instance
133    */
134   void OnLanguageChanged( Dali::Application& app );
135
136 protected:
137
138   /**
139    * Virtual Destructor.
140    */
141   ~LifecycleController() override;
142
143 private:
144
145   /**
146    * Emit the init signal.
147    */
148   void EmitInitSignal();
149
150   /**
151    * Emit the init signal.
152    */
153   void EmitTerminateSignal();
154
155   /**
156    * Emit the init signal.
157    */
158   void EmitPauseSignal();
159
160   /**
161    * Emit the init signal.
162    */
163   void EmitResumeSignal();
164
165   /**
166    * Emit the init signal.
167    */
168   void EmitResetSignal();
169
170   /**
171    * Emit the init signal.
172    */
173   void EmitLanguageChangedSignal();
174
175 private:
176
177   // Signals
178   Dali::LifecycleController::LifecycleSignalType mInitSignal;
179   Dali::LifecycleController::LifecycleSignalType mTerminateSignal;
180   Dali::LifecycleController::LifecycleSignalType mPauseSignal;
181   Dali::LifecycleController::LifecycleSignalType mResumeSignal;
182   Dali::LifecycleController::LifecycleSignalType mResetSignal;
183   Dali::LifecycleController::LifecycleSignalType mLanguageChangedSignal;
184
185 };
186
187 } // namespace Adaptor
188
189 } // namespace Internal
190
191 // Additional Helpers for public-api forwarding methods
192
193 inline Internal::Adaptor::LifecycleController& GetImplementation(Dali::LifecycleController& controller)
194 {
195   DALI_ASSERT_ALWAYS(controller && "Controller handle is empty");
196   BaseObject& handle = controller.GetBaseObject();
197   return static_cast<Internal::Adaptor::LifecycleController&>(handle);
198 }
199
200 inline const Internal::Adaptor::LifecycleController& GetImplementation(const Dali::LifecycleController& controller)
201 {
202   DALI_ASSERT_ALWAYS(controller && "Controller handle is empty");
203   const BaseObject& handle = controller.GetBaseObject();
204   return static_cast<const Internal::Adaptor::LifecycleController&>(handle);
205 }
206
207 } // namespace Dali
208
209 #endif // DALI_INTERNAL_LIFECYCLE_CONTROLLER_H