Add internal api for c++ 67/259567/4
authorjh9216.park <jh9216.park@samsung.com>
Thu, 10 Jun 2021 00:25:43 +0000 (20:25 -0400)
committerjh9216.park <jh9216.park@samsung.com>
Wed, 23 Jun 2021 06:24:06 +0000 (02:24 -0400)
Change-Id: I17b790f64452e6bff3257c277e97a7154bb2d0e8
Signed-off-by: jh9216.park <jh9216.park@samsung.com>
CMakeLists.txt
include/app.hpp [new file with mode: 0644]
packaging/capi-appfw-application.spec

index 0c29ce8..5216a6d 100644 (file)
@@ -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 (file)
index 0000000..283c397
--- /dev/null
@@ -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 <app.h>
+
+#include <app_control.hpp>
+#include <app_common.hpp>
+
+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<UiAppBase*>(user_data);
+        return b->OnCreate();
+      },
+      terminate : [](void* user_data) {
+        UiAppBase* b = static_cast<UiAppBase*>(user_data);
+        b->OnTerminate();
+      },
+      pause : [](void* user_data) {
+        UiAppBase* b = static_cast<UiAppBase*>(user_data);
+        b->OnPause();
+      },
+      resume : [](void* user_data) {
+        UiAppBase* b = static_cast<UiAppBase*>(user_data);
+        b->OnResume();
+      },
+      app_control : [](app_control_h app_control, void* user_data) {
+        UiAppBase* b = static_cast<UiAppBase*>(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
index 31af871..2bf176e 100644 (file)
@@ -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