Modify AppCoreUiThreadBase class
[platform/core/appfw/app-core.git] / tizen-cpp / app-core-ui-cpp / app_core_task_base.hh
1 /*
2  * Copyright (c) 2022 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_TASK_BASE_HH_
18 #define TIZEN_CPP_APP_CORE_UI_CPP_APP_CORE_TASK_BASE_HH_
19
20 #include <memory>
21
22 #include <app_core_base.hh>
23 #include <interface_app_core_ui_event.hh>
24
25 #undef EXPORT_API
26 #define EXPORT_API __attribute__((visibility("default")))
27
28 namespace tizen_cpp {
29
30 class EXPORT_API AppCoreTaskBase : public AppCoreBase,
31                                    public IAppCoreUiEvent {
32  public:
33   enum LowMemoryState {
34     LOW_MEMORY_STATE_UNKNOWN,
35     LOW_MEMORY_STATE_NORMAL = 0x01,
36     LOW_MEMORY_STATE_SOFT_WARNING = 0x02,
37     LOW_MEMORY_STATE_HARD_WARNING = 0x04,
38   };
39
40   enum LowBatteryState {
41     LOW_BATTERY_STATE_UNKNOWN,
42     LOW_BATTERY_STATE_POWER_OFF = 1,
43     LOW_BATTERY_STATE_CRITICAL_LOW = 2,
44   };
45
46   enum DeviceOrientationState {
47     DEVICE_ORIENTATION_STATE_UNKNOWN = -1,
48     DEVICE_ORIENTATION_STATE_0 = 0,
49     DEVICE_ORIENTATION_STATE_90 = 90,
50     DEVICE_ORIENTATION_STATE_180 = 180,
51     DEVICE_ORIENTATION_STATE_270 = 270,
52   };
53
54   AppCoreTaskBase();
55   virtual ~AppCoreTaskBase();
56
57   int OnReceive(aul_type type, tizen_base::Bundle b) override;
58   int OnCreate() override;
59   int OnTerminate() override;
60   int OnControl(tizen_base::Bundle b) override;
61
62   int OnTrimMemory() override;
63   void OnLoopInit(int argc, char** argv) override;
64   void OnLoopRun() override;
65   void OnLoopExit() override;
66   void OnLoopFinish() override;
67
68   virtual void OnLowMemory(LowMemoryState state);
69   virtual void OnLowBattery(LowBatteryState state);
70   virtual void OnLangChanged(const std::string& lang);
71   virtual void OnDeviceOrientationChanged(DeviceOrientationState state);
72   virtual void OnRegionChanged(const std::string& region);
73
74   void Run(int argc, char** argv) override;
75
76   void OnUiEvent(UiState state) override;
77   void Post(UiState state) override;
78
79  private:
80   class Impl;
81   std::unique_ptr<Impl> impl_;
82 };
83
84 }  // namespace tizen_cpp
85
86 #endif  // TIZEN_CPP_APP_CORE_UI_CPP_APP_CORE_TASK_BASE_HH_