Modify AppCoreUiThreadBase class
[platform/core/appfw/app-core.git] / tizen-cpp / app-core-ui-cpp / app_core_ui_thread_base.hh
1 /*
2  * Copyright (c) 2023 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 #ifndef TIZEN_CPP_APP_CORE_UI_CPP_APP_CORE_UI_THREAD_BASE_HH_
18 #define TIZEN_CPP_APP_CORE_UI_CPP_APP_CORE_UI_THREAD_BASE_HH_
19
20 #include <functional>
21 #include <memory>
22
23 #include <interface_main_loop.hh>
24
25 #undef EXPORT_API
26 #define EXPORT_API __attribute__((visibility("default")))
27
28 namespace tizen_cpp {
29
30 class EXPORT_API AppCoreUiThreadBase : public IMainLoop {
31  public:
32   using Runner = std::function<void()>;
33
34   AppCoreUiThreadBase();
35   virtual ~AppCoreUiThreadBase();
36
37   void Run(int argc, char** argv);
38   void Exit();
39   void Post(Runner runner);
40
41   void OnLoopInit(int argc, char** argv) override;
42   void OnLoopRun() override;
43   void OnLoopExit() override;
44   void OnLoopFinish() override;
45
46   static AppCoreUiThreadBase* GetContext();
47
48  private:
49   class Impl;
50   std::unique_ptr<Impl> impl_;
51 };
52
53 }  // namespace tizen_cpp
54
55 #endif  // TIZEN_CPP_APP_CORE_UI_CPP_APP_CORE_UI_THREAD_BASE_HH_