[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / lifecycle-controller.h
1 #ifndef DALI_LIFECYCLE_CONTROLLER_H
2 #define DALI_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/base-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/dali-adaptor-common.h>
27
28 namespace Dali
29 {
30 namespace Internal DALI_INTERNAL
31 {
32 namespace Adaptor
33 {
34 class LifecycleController;
35 }
36 } // namespace DALI_INTERNAL
37
38 /**
39  * @brief Provides application lifecycle events.
40  *
41  * Connect to the signals of this class to receive notification of events in the lifecycle
42  * of the application. The following example shows how to connect to the Init signal. This
43  * could be done for example in the constructor of a singleton that is known to be created
44  * at startup.
45  *
46  * @code
47  * void MyClass::MyClass()
48  * {
49  *   LifecycleController::Get().InitSignal().Connect( this, &MyClass::OnApplicationInit );
50  * }
51  *
52  * void MyClass::OnApplicationInit()
53  * {
54  *   // ... Do something on init
55  * }
56  * @endcode
57  */
58 class DALI_ADAPTOR_API LifecycleController : public BaseHandle
59 {
60 public:                                           // Typedefs
61   typedef Signal<void(void)> LifecycleSignalType; ///< Lifecycle Signal type
62
63 public: // Creation & Destruction
64   /**
65    * @brief Create an uninitialized LifecycleController handle.
66    *
67    * Calling member functions when uninitialized is not allowed.
68    */
69   LifecycleController();
70
71   /**
72    * @brief Creates a copy of the handle.
73    *
74    * The copy will point to the same implementation as the original.
75    * @param[in]  monitor  The LifecycleController to copy from.
76    */
77   LifecycleController(const LifecycleController& monitor);
78
79   /**
80    * @brief Retrieve the initialized instance of the LifecycleController.
81    * @return Handle to LifecycleController.
82    */
83   static LifecycleController Get();
84
85   /**
86    * @brief Destructor
87    *
88    * This is non-virtual since derived Handle types must not contain data or virtual methods.
89    */
90   ~LifecycleController();
91
92 public: // Signals
93   /**
94    * The user should connect to this signal to determine when they should initialise
95    * their application.
96    */
97   LifecycleSignalType& InitSignal();
98
99   /**
100    * The user should connect to this signal to determine when they should terminate
101    * their application
102    */
103   LifecycleSignalType& TerminateSignal();
104
105   /**
106    * The user should connect to this signal if they need to perform any special
107    * activities when the application is about to be paused.
108    */
109   LifecycleSignalType& PauseSignal();
110
111   /**
112    * The user should connect to this signal if they need to perform any special
113    * activities when the application has resumed.
114    */
115   LifecycleSignalType& ResumeSignal();
116
117   /**
118    * This signal is sent when the system requires the user to reinitialise itself.
119    */
120   LifecycleSignalType& ResetSignal();
121
122   /**
123    * This signal is emitted when the language is changed on the device.
124    */
125   LifecycleSignalType& LanguageChangedSignal();
126
127 public: // Operators
128   /**
129    * @brief Assignment operator.
130    *
131    * The handle points to the same implementation as the one being copied from.
132    * @param[in]  controller  The LifecycleController to copy from.
133    * @return reference to this object
134    */
135   LifecycleController& operator=(const LifecycleController& controller);
136
137 public: // Not intended for application developers
138   /**
139    * @brief This constructor is used internally to create a handle from an object pointer.
140    * @param [in] lifecycleController A pointer to the internal LifecycleController.
141    */
142   explicit DALI_INTERNAL LifecycleController(Internal::Adaptor::LifecycleController* lifecycleController);
143 };
144
145 } // namespace Dali
146
147 #endif // DALI_LIFECYCLE_CONTROLLER_H