Add move semantics to BaseHandle derived classes in Adaptor public API
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / widget-application.h
1 #ifndef DALI_WIDGET_APPLICATION_H
2 #define DALI_WIDGET_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 // INTERNAL INCLUDES
22 #include <dali/public-api/adaptor-framework/application.h>
23
24 namespace Dali
25 {
26 /**
27  * @addtogroup dali_adaptor_framework
28  * @{
29  */
30
31 namespace Internal DALI_INTERNAL
32 {
33
34 namespace Adaptor
35 {
36 class WidgetApplication;
37 }
38
39 }
40
41 class Widget;
42
43 /**
44  * @brief An WidgetApplication class object should be created by every widget application
45  * that wishes to use Dali.
46  *
47  * It provides a means for initializing the
48  * resources required by the Dali::Core.
49  *
50  * The WidgetApplication class emits several signals which the user can
51  * connect to.  The user should not create any Dali objects in the main
52  * function and instead should connect to the Init signal of the
53  * WidgetApplication and create the Dali Widget object in the connected callback.
54  *
55  * WidgetApplications should follow the example below:
56  *
57  * @code
58  *
59  * //Widget header which
60  * #include <my-widget.h>
61  *
62  * class ExampleController: public ConnectionTracker
63  * {
64  * public:
65  *   ExampleController( Application& application )
66  *   : mWidgetApplication( application )
67  *   {
68  *     mApplication.InitSignal().Connect( this, &ExampleController::Create );
69  *   }
70  *
71  *   static Widget CreateWidgetFunction(const std::string& widgetName)
72  *   {
73  *     MyWidget widget = MyWidget::New();
74  *     return widget;
75  *   }
76  *
77  *   void Create( Application& application )
78  *   {
79  *     mApplication.RegisterWidgetCreatingFunction( "myWidget", &ExampleController::CreateWidgetFunction );
80  *   }
81  *
82  * private:
83  *   WidgetApplication& mWidgetApplication;
84  * };
85  *
86  * int main (int argc, char **argv)
87  * {
88  *   WidgetApplication app = WidgetApplication::New(&argc, &argv);
89  *   ExampleController example( app );
90  *   app.MainLoop();
91  * }
92  * @endcode
93  *
94  * If required, you can also connect class member functions to a signal:
95  *
96  * @code
97  * MyWidgetApplication app;
98  * app.ResumeSignal().Connect(&app, &MyWidgetApplication::Resume);
99  * @endcode
100  *
101  * @SINCE_1_3_5
102  */
103 class DALI_ADAPTOR_API WidgetApplication : public Application
104 {
105 public:
106
107   /**
108    * @brief This is the typedef for Widget creator.
109    * @SINCE_1_3_5
110    */
111   typedef Widget(*CreateWidgetFunction)(const std::string&);
112
113 public:
114
115   /**
116    * @brief This is the constructor for WidgetApplications with a name.
117    *
118    * @SINCE_1_3_5
119    * @param[in,out]  argc        A pointer to the number of arguments
120    * @param[in,out]  argv        A pointer to the argument list
121    * @param[in]      stylesheet  The path to user defined theme file
122    * @return A handle to the WidgetApplication
123    * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
124    */
125   static WidgetApplication New( int* argc, char **argv[], const std::string& stylesheet );
126
127   /**
128    * @brief The default constructor.
129    * @SINCE_1_3_5
130    */
131   WidgetApplication();
132
133   /**
134    * @brief Copy Constructor.
135    *
136    * @SINCE_1_3_5
137    * @param[in] widgetApplication Handle to an object
138    */
139   WidgetApplication( const WidgetApplication& widgetApplication );
140
141   /**
142    * @brief Assignment operator.
143    *
144    * @SINCE_1_3_5
145    * @param[in] widgetApplication Handle to an object
146    * @return A reference to this
147    */
148   WidgetApplication& operator=( const WidgetApplication& widgetApplication );
149
150   /**
151    * @brief Move constructor.
152    *
153    * @SINCE_1_9.24
154    * @param[in] rhs A reference to the moved handle
155    */
156   WidgetApplication( WidgetApplication&& rhs );
157
158   /**
159    * @brief Move assignment operator.
160    *
161    * @SINCE_1_9.24
162    * @param[in] rhs A reference to the moved handle
163    * @return A reference to this handle
164    */
165   WidgetApplication& operator=( WidgetApplication&& rhs );
166
167  /**
168    * @brief Destructor
169    * @SINCE_1_3_5
170    */
171   ~WidgetApplication();
172
173   /**
174    * @brief Register create function for widget.
175    *
176    * @SINCE_1_3_5
177    * @param[in] widgetName  Name of widget
178    * @param[in] createFunction     Function pointer for widget creation.
179    */
180   void RegisterWidgetCreatingFunction( const std::string& widgetName, CreateWidgetFunction createFunction );
181
182 public: // Not intended for application developers
183   /// @cond internal
184   /**
185    * @brief Internal constructor.
186    */
187   explicit DALI_INTERNAL WidgetApplication(Internal::Adaptor::WidgetApplication* widgetApplication);
188   /// @endcond
189 };
190
191 /**
192  * @}
193  */
194 } // namespace Dali
195
196 #endif // DALI_WIDGET_APPLICATION_H