[dali_2.3.28] Merge branch 'devel/master'
[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) 2021 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/base-object.h>
23 #include <dali/public-api/object/ref-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 class Adaptor;
32
33 namespace Internal
34 {
35 namespace Adaptor
36 {
37 /**
38  * This provides signals that are emitted according the lifecylce of the program.
39  */
40 class LifecycleController : public BaseObject, public ConnectionTracker
41 {
42 public:
43   // Creation & Destruction
44
45   /**
46    * Constructor.
47    */
48   LifecycleController();
49
50   /**
51    * Retrieve the initialized instance of the LifecycleController.
52    * @return Handle to LifecycleController.
53    */
54   static Dali::LifecycleController Get();
55
56   // Signals
57
58   /**
59    * @copydoc Dali::StyleMonitor::InitSignal()
60    */
61   Dali::LifecycleController::LifecycleSignalType& InitSignal();
62
63   /**
64    * @copydoc Dali::StyleMonitor::TerminateSignal()
65    */
66   Dali::LifecycleController::LifecycleSignalType& TerminateSignal();
67
68   /**
69    * @copydoc Dali::StyleMonitor::PauseSignal()
70    */
71   Dali::LifecycleController::LifecycleSignalType& PauseSignal();
72
73   /**
74    * @copydoc Dali::StyleMonitor::ResumeSignal()
75    */
76   Dali::LifecycleController::LifecycleSignalType& ResumeSignal();
77
78   /**
79    * @copydoc Dali::StyleMonitor::ResetSignal()
80    */
81   Dali::LifecycleController::LifecycleSignalType& ResetSignal();
82
83   /**
84    * @copydoc Dali::StyleMonitor::LanguageChangedSignal()
85    */
86   Dali::LifecycleController::LifecycleSignalType& LanguageChangedSignal();
87
88 public:
89   /**
90    * Called when the framework is initialised.
91    *
92    * @param[in] app The application instance
93    */
94   void OnInit(Dali::Application& app);
95
96   /**
97    * Called when the framework is terminated.
98    *
99    * @param[in] app The application instance
100    */
101   void OnTerminate(Dali::Application& app);
102
103   /**
104    * Called when the framework is paused.
105    *
106    * @param[in] app The application instance
107    */
108   void OnPause(Dali::Application& app);
109
110   /**
111    * Called when the framework resumes from a paused state.
112    *
113    * @param[in] app The application instance
114    */
115   void OnResume(Dali::Application& app);
116
117   /**
118    * Called when the framework informs the application that it should reset itself.
119    *
120    * @param[in] app The application instance
121    */
122   void OnReset(Dali::Application& app);
123
124   /**
125    * Called when the framework informs the application that the language of the device has changed.
126    *
127    * @param[in] app The application instance
128    */
129   void OnLanguageChanged(Dali::Application& app);
130
131 protected:
132   /**
133    * Virtual Destructor.
134    */
135   ~LifecycleController() override;
136
137 private:
138   /**
139    * Emit the init signal.
140    */
141   void EmitInitSignal();
142
143   /**
144    * Emit the init signal.
145    */
146   void EmitTerminateSignal();
147
148   /**
149    * Emit the init signal.
150    */
151   void EmitPauseSignal();
152
153   /**
154    * Emit the init signal.
155    */
156   void EmitResumeSignal();
157
158   /**
159    * Emit the init signal.
160    */
161   void EmitResetSignal();
162
163   /**
164    * Emit the init signal.
165    */
166   void EmitLanguageChangedSignal();
167
168 private:
169   // Signals
170   Dali::LifecycleController::LifecycleSignalType mInitSignal;
171   Dali::LifecycleController::LifecycleSignalType mTerminateSignal;
172   Dali::LifecycleController::LifecycleSignalType mPauseSignal;
173   Dali::LifecycleController::LifecycleSignalType mResumeSignal;
174   Dali::LifecycleController::LifecycleSignalType mResetSignal;
175   Dali::LifecycleController::LifecycleSignalType mLanguageChangedSignal;
176 };
177
178 } // namespace Adaptor
179
180 } // namespace Internal
181
182 // Additional Helpers for public-api forwarding methods
183
184 inline Internal::Adaptor::LifecycleController& GetImplementation(Dali::LifecycleController& controller)
185 {
186   DALI_ASSERT_ALWAYS(controller && "Controller handle is empty");
187   BaseObject& handle = controller.GetBaseObject();
188   return static_cast<Internal::Adaptor::LifecycleController&>(handle);
189 }
190
191 inline const Internal::Adaptor::LifecycleController& GetImplementation(const Dali::LifecycleController& controller)
192 {
193   DALI_ASSERT_ALWAYS(controller && "Controller handle is empty");
194   const BaseObject& handle = controller.GetBaseObject();
195   return static_cast<const Internal::Adaptor::LifecycleController&>(handle);
196 }
197
198 } // namespace Dali
199
200 #endif // DALI_INTERNAL_LIFECYCLE_CONTROLLER_H