From: jh9216.park Date: Thu, 10 Jun 2021 00:25:43 +0000 (-0400) Subject: Add internal api for c++ X-Git-Tag: submit/tizen/20210702.001428~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88e1c4680a965aef8bb12c74efa3936ca660f0ee;p=platform%2Fcore%2Fapi%2Fapplication.git Add internal api for c++ Change-Id: I17b790f64452e6bff3257c277e97a7154bb2d0e8 Signed-off-by: jh9216.park --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c29ce8..5216a6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ INSTALL( DIRECTORY ${INC_DIR}/ DESTINATION include/appfw FILES_MATCHING PATTERN "*_private.h" EXCLUDE - PATTERN "${INC_DIR}/*.h" + PATTERN "${INC_DIR}/*.h*" ) IF(UNIX) diff --git a/include/app.hpp b/include/app.hpp new file mode 100644 index 0000000..283c397 --- /dev/null +++ b/include/app.hpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TIZEN_APPFW_APP_HPP_ +#define TIZEN_APPFW_APP_HPP_ + +#include + +#include +#include + +namespace tizen_appfw { + +class UiAppBase : public app_common::AppBase< + decltype(ui_app_add_event_handler)*, + decltype(ui_app_remove_event_handler)*> { + public: + using Remover = decltype(ui_app_remove_event_handler)*; + + UiAppBase() + : AppBase(ui_app_add_event_handler, ui_app_remove_event_handler) {} + + virtual bool OnCreate() { return true; } + virtual void OnTerminate() {} + virtual void OnResume() {} + virtual void OnPause() {} + virtual void OnAppControl(const ReceivedAppControl& ctrl) {} + + int Run(int argc, char **argv) { + ui_app_lifecycle_callback_s callback = { + create : [](void* user_data) -> bool { + UiAppBase* b = static_cast(user_data); + return b->OnCreate(); + }, + terminate : [](void* user_data) { + UiAppBase* b = static_cast(user_data); + b->OnTerminate(); + }, + pause : [](void* user_data) { + UiAppBase* b = static_cast(user_data); + b->OnPause(); + }, + resume : [](void* user_data) { + UiAppBase* b = static_cast(user_data); + b->OnResume(); + }, + app_control : [](app_control_h app_control, void* user_data) { + UiAppBase* b = static_cast(user_data); + b->OnAppControl(ReceivedAppControl(app_control)); + } + }; + + return ui_app_main(argc, argv, &callback, this); + } + + void Exit() noexcept { + ui_app_exit(); + } +}; + +} // namespace tizen_appfw + +#endif // TIZEN_APPFW_APP_HPP_ \ No newline at end of file diff --git a/packaging/capi-appfw-application.spec b/packaging/capi-appfw-application.spec index 31af871..2bf176e 100644 --- a/packaging/capi-appfw-application.spec +++ b/packaging/capi-appfw-application.spec @@ -136,6 +136,7 @@ Header & package configuration of appcore-ui-app-ambient %files devel %manifest %{name}.manifest %{_includedir}/appfw/app.h +%{_includedir}/appfw/app.hpp %{_includedir}/appfw/app_internal.h %{_includedir}/appfw/app_extension.h %{_includedir}/appfw/app_i18n.h