Add move semantics to BaseHandle derived classes in Adaptor public API
[platform/core/uifw/dali-adaptor.git] / dali / public-api / watch / watch-application.h
1 #ifndef DALI_WATCH_APPLICATION_H
2 #define DALI_WATCH_APPLICATION_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 <string>
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/signals/callback.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/dali-adaptor-common.h>
28 #include <dali/public-api/adaptor-framework/application.h>
29 #include <dali/public-api/watch/watch-time.h>
30
31 namespace Dali
32 {
33 /**
34  * @addtogroup dali_adaptor_framework
35  * @{
36  */
37 namespace Internal DALI_INTERNAL
38 {
39 namespace Adaptor
40 {
41 class WatchApplication;
42 }
43 }
44
45 /**
46  * @brief A WatchApplication class object should be created by every watch application
47  * that wishes to use Dali.
48  *
49  * It provides a means for initialising the resources required by the Dali::Core.
50  * Like Application class, the WatchApplication class manages Tizen watch application life cycle.
51  *
52  * The WatchApplication class emits additional signals which are availalble only in the watch application
53  * (TimeTick, AmbientTick, AmbientChanged)
54  *
55  * This feature is supported in wearable applications only.
56  *
57  * WatchApplication should follow the example below:
58  *
59  * @code
60  * class ExampleController: public ConnectionTracker
61  * {
62  * public:
63  *   ExampleController( WatchApplication& application )
64  *   : mApplication( application )
65  *   {
66  *     mApplication.InitSignal().Connect( this, &ExampleController::Create );
67  *   }
68  *
69  *   void Create( Application& application )
70  *   {
71  *     // Create Dali components...
72  *   }
73  *  ...
74  * private:
75  *   WatchApplication&  mApplication;
76  * };
77  *
78  * int DALI_ADAPTOR_API main (int argc, char **argv)
79  * {
80  *   WatchApplication app = WatchApplication::New(&argc, &argv);
81  *   ExampleController example( app );
82  *   app.MainLoop();
83  * }
84  * @endcode
85  *
86  * If required, you can also connect class member functions to a signal:
87  *
88  * @code
89  * MyApplication app;
90  * app.ResumeSignal().Connect(&app, &MyApplication::Resume);
91  * @endcode
92  *
93  * When the above options are found, they are stripped from argv, and argc is updated appropriately.
94  * @SINCE_1_1.37
95  */
96
97 class DALI_ADAPTOR_API WatchApplication : public Application
98 {
99 public:
100   typedef Signal< void (Application&, const WatchTime&) > WatchTimeSignal; ///< Watch pointer signal callback type @SINCE_1_1.37
101   typedef Signal< void (Application&, bool) > WatchBoolSignal; ///< Watch bool signal callback type @SINCE_1_1.37
102
103 public:
104
105   /**
106    * @brief This is the constructor for applications without an argument list.
107    * @SINCE_1_1.37
108    * @return A handle to the WatchApplication
109    */
110   static WatchApplication New();
111
112   /**
113    * @brief This is the constructor for applications.
114    *
115    * @SINCE_1_1.37
116    * @param[in,out]  argc        A pointer to the number of arguments
117    * @param[in,out]  argv        A pointer the the argument list
118    * @return A handle to the WatchApplication
119    */
120   static WatchApplication New( int* argc, char **argv[] );
121
122   /**
123    * @brief This is the constructor for applications with a name
124    *
125    * @SINCE_1_1.37
126    * @param[in,out]  argc        A pointer to the number of arguments
127    * @param[in,out]  argv        A pointer the the argument list
128    * @param[in]      stylesheet  The path to user defined theme file
129    * @return A handle to the WatchApplication
130    */
131   static WatchApplication New( int* argc, char **argv[], const std::string& stylesheet );
132
133   /**
134    * @brief Construct an empty handle
135    * @SINCE_1_1.37
136    */
137   WatchApplication();
138
139   /**
140    * @brief Copy Constructor
141    * @SINCE_1_1.37
142    * @param[in] implementation The WatchApplication implementation
143    */
144   WatchApplication( const WatchApplication& implementation );
145
146   /**
147    * @brief Assignment operator
148    * @SINCE_1_1.37
149    * @param[in] application Handle to an object
150    * @return A reference to this
151    */
152   WatchApplication& operator=( const WatchApplication& application );
153
154   /**
155    * @brief Move constructor.
156    *
157    * @SINCE_1_9.24
158    * @param[in] rhs A reference to the moved handle
159    */
160   WatchApplication( WatchApplication&& rhs );
161
162   /**
163    * @brief Move assignment operator.
164    *
165    * @SINCE_1_9.24
166    * @param[in] rhs A reference to the moved handle
167    * @return A reference to this handle
168    */
169   WatchApplication& operator=( WatchApplication&& rhs );
170
171   /**
172    * @brief Destructor
173    *
174    * This is non-virtual since derived Handle types must not contain data or virtual methods.
175    * @SINCE_1_1.37
176    */
177   ~WatchApplication();
178
179 public:
180   /**
181    * @brief This signal is emitted at every second
182    * A callback of the following type may be connected:
183    * @code
184    *   void YourCallbackName(Application& application, const WatchTime& time);
185    * @endcode
186    * time(watch time handle) will not be available after returning this callback. It will be freed by the framework.
187    * @SINCE_1_1.37
188    * @return The signal to connect to
189    */
190   WatchTimeSignal& TimeTickSignal();
191
192   /**
193    * @brief This signal is emitted at each minute in ambient mode
194    * A callback of the following type may be connected:
195    * @code
196    *   void YourCallbackName(Application& application, const WatchTime& time);
197    * @endcode
198    * time(watch time handle) will not be available after returning this callback. It will be freed by the framework.
199    * @SINCE_1_1.37
200    * @remarks http://tizen.org/privilege/alarm.set privilege is needed to receive ambient ticks at each minute.
201    * The AmbientTickSignal() will be ignored if your app doesn't have the privilege
202    * @return The signal to connect to
203    */
204   WatchTimeSignal& AmbientTickSignal();
205
206   /**
207    * @brief This signal is emitted when the device enters or exits ambient mode
208    * A callback of the following type may be connected:
209    * @code
210    *   void YourCallbackName(Application& application, bool ambient);
211    * @endcode
212    * ambient_mode If true the device enters the ambient mode, otherwise false
213    * @SINCE_1_1.37
214    * @return The signal to connect to
215    */
216   WatchBoolSignal& AmbientChangedSignal();
217
218 public: // Not intended for application developers
219   /// @cond internal
220   /**
221    * @brief Internal constructor
222    * @SINCE_1_1.37
223    */
224   explicit DALI_INTERNAL WatchApplication(Internal::Adaptor::WatchApplication* implementation);
225   /// @endcond
226 };
227
228 /**
229  * @}
230  */
231 } // namespace Dali
232
233 #endif // DALI_WATCH_APPLICATION_H