Add move semantics to BaseHandle derived classes in Adaptor public API
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / application.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/adaptor-framework/application.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/object-registry.h>
23 #include <dali/integration-api/debug.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/internal/adaptor/common/application-impl.h>
27
28 namespace Dali
29 {
30
31 Application Application::New()
32 {
33   return New( NULL, NULL );
34 }
35
36 Application Application::New( int* argc, char **argv[] )
37 {
38   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
39   if( internal )
40   {
41     // pre-initialized application
42     internal->SetCommandLineOptions( argc, argv );
43     if( argc && ( *argc > 0 ) )
44     {
45       internal->GetWindow().SetClass( (*argv)[0], "" );
46     }
47
48     return Application( internal.Get() );
49   }
50   else
51   {
52     internal = Internal::Adaptor::Application::New( argc, argv, "", OPAQUE, PositionSize(),
53       Internal::Adaptor::Framework::NORMAL);
54     return Application(internal.Get());
55   }
56 }
57
58 Application Application::New( int* argc, char **argv[], const std::string& stylesheet )
59 {
60   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
61   if( internal )
62   {
63     // pre-initialized application
64     internal->SetCommandLineOptions( argc, argv );
65     if( argc && ( *argc > 0 ) )
66     {
67       internal->GetWindow().SetClass( (*argv)[0], "" );
68     }
69     internal->SetStyleSheet( stylesheet );
70
71     return Application( internal.Get() );
72   }
73   else
74   {
75     internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, OPAQUE, PositionSize(),
76       Internal::Adaptor::Framework::NORMAL);
77     return Application(internal.Get());
78   }
79 }
80
81 Application Application::New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode )
82 {
83   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
84   if( internal )
85   {
86     // pre-initialized application
87     internal->SetCommandLineOptions( argc, argv );
88     if( argc && ( *argc > 0 ) )
89     {
90       internal->GetWindow().SetClass( (*argv)[0], "" );
91     }
92     internal->SetStyleSheet( stylesheet );
93
94     internal->GetWindow().SetTransparency( ( windowMode == Application::OPAQUE ? false : true ) );
95
96     return Application( internal.Get() );
97   }
98   else
99   {
100     internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, PositionSize(),
101       Internal::Adaptor::Framework::NORMAL);
102     return Application(internal.Get());
103   }
104 }
105
106 Application Application::New( int* argc, char **argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize )
107 {
108   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
109   if( internal )
110   {
111     // pre-initialized application
112     internal->SetCommandLineOptions( argc, argv );
113     if( argc && ( *argc > 0 ) )
114     {
115       internal->GetWindow().SetClass( (*argv)[0], "" );
116     }
117     internal->SetStyleSheet( stylesheet );
118
119     internal->GetWindow().SetTransparency( ( windowMode == Application::OPAQUE ? false : true ) );
120     internal->GetWindow().SetSize( Window::WindowSize( positionSize.width, positionSize.height ) );
121     internal->GetWindow().SetPosition( Window::WindowPosition( positionSize.x, positionSize.y ) );
122
123     return Application( internal.Get() );
124   }
125   else
126   {
127     internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL );
128     return Application( internal.Get() );
129   }
130 }
131
132 Application::~Application()
133 {
134 }
135
136 Application::Application()
137 {
138 }
139
140 Application::Application( const Application& copy ) = default;
141
142 Application& Application::operator=( const Application& rhs ) = default;
143
144 Application::Application( Application&& rhs ) = default;
145
146 Application& Application::operator=( Application&& rhs ) = default;
147
148 void Application::MainLoop()
149 {
150   Internal::Adaptor::GetImplementation(*this).MainLoop(Configuration::APPLICATION_HANDLES_CONTEXT_LOSS);
151 }
152
153 void Application::MainLoop(Configuration::ContextLoss configuration)
154 {
155   Internal::Adaptor::GetImplementation(*this).MainLoop(configuration);
156 }
157
158 void Application::Lower()
159 {
160   Internal::Adaptor::GetImplementation(*this).Lower();
161 }
162
163 void Application::Quit()
164 {
165   Internal::Adaptor::GetImplementation(*this).Quit();
166 }
167
168 bool Application::AddIdle( CallbackBase* callback )
169 {
170   return Internal::Adaptor::GetImplementation(*this).AddIdle( callback, false );
171 }
172
173 Window Application::GetWindow()
174 {
175   return Internal::Adaptor::GetImplementation(*this).GetWindow();
176 }
177
178 std::string Application::GetResourcePath()
179 {
180   return Internal::Adaptor::Application::GetResourcePath();
181 }
182
183 std::string Application::GetRegion() const
184 {
185   return Internal::Adaptor::GetImplementation(*this).GetRegion();
186 }
187
188 std::string Application::GetLanguage() const
189 {
190   return Internal::Adaptor::GetImplementation(*this).GetLanguage();
191 }
192
193 ObjectRegistry Application::GetObjectRegistry() const
194 {
195   return Internal::Adaptor::GetImplementation(*this).GetObjectRegistry();
196 }
197
198 Application::AppSignalType& Application::InitSignal()
199 {
200   return Internal::Adaptor::GetImplementation(*this).InitSignal();
201 }
202
203 Application::AppSignalType& Application::TerminateSignal()
204 {
205   return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
206 }
207
208 Application::AppSignalType& Application::PauseSignal()
209 {
210   return Internal::Adaptor::GetImplementation(*this).PauseSignal();
211 }
212
213 Application::AppSignalType& Application::ResumeSignal()
214 {
215   return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
216 }
217
218 Application::AppSignalType& Application::ResetSignal()
219 {
220   return Internal::Adaptor::GetImplementation(*this).ResetSignal();
221 }
222
223 Application::AppControlSignalType & Application::AppControlSignal()
224 {
225   return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
226 }
227
228 Application::AppSignalType& Application::LanguageChangedSignal()
229 {
230   return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
231 }
232
233 Application::AppSignalType& Application::RegionChangedSignal()
234 {
235   return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
236 }
237
238 Application::LowBatterySignalType& Application::LowBatterySignal()
239 {
240   return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
241 }
242
243 Application::LowMemorySignalType& Application::LowMemorySignal()
244 {
245   return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
246 }
247
248 Application::Application(Internal::Adaptor::Application* application)
249 : BaseHandle(application)
250 {
251 }
252
253
254 } // namespace Dali