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