1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_CONTROLLER_INTERFACE_H 17 #define CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_CONTROLLER_INTERFACE_H 18 19 #include <mutex> 20 21 #include "json/json.h" 22 #include "json/value.h" 23 24 #include "concurrent_task_type.h" 25 #include "func_loader.h" 26 #include "qos_policy.h" 27 28 namespace OHOS { 29 namespace ConcurrentTask { 30 using ReportDataFunc = void (*)(uint32_t resType, int64_t value, const Json::Value& payload); 31 using ReportSceneInfoFunc = void (*)(uint32_t type, const Json::Value& payload); 32 using QueryIntervalFunc = void (*)(int queryItem, IntervalReply& queryRs); 33 using QueryDeadlineFunc = void (*)(int queryItem, DeadlineReply& ddlReply, const Json::Value& payload); 34 using RequestAuthFunc = void (*)(const Json::Value& payload); 35 using InitFunc = void (*)(); 36 using ReleaseFunc = void (*)(); 37 using CreateNewRtgGrpFunc = int (*)(int prioType, int rtNum); 38 39 class TaskControllerInterface { 40 public: 41 static TaskControllerInterface& GetInstance(); 42 TaskControllerInterface(); 43 virtual ~TaskControllerInterface() = default; 44 void RequestAuth(const Json::Value& payload); 45 void ReportData(uint32_t resType, int64_t value, const Json::Value& payload); 46 void ReportSceneInfo(uint32_t type, const Json::Value& payload); 47 void QueryInterval(int queryItem, IntervalReply& queryRs); 48 void QueryDeadline(int queryItem, DeadlineReply& ddlReply, const Json::Value& payload); 49 void Init(); 50 void Release(); 51 52 private: 53 bool LoadFunc(); 54 FuncLoader funcLoader_; 55 std::mutex funcLoaderLock_; 56 bool inited_ = false; 57 QosPolicy qosPolicy_; 58 59 ReportDataFunc reportDataFunc_ = nullptr; 60 ReportSceneInfoFunc reportSceneInfoFunc_ = nullptr; 61 QueryIntervalFunc queryIntervalFunc_ = nullptr; 62 QueryDeadlineFunc queryDeadlineFunc_ = nullptr; 63 RequestAuthFunc requestAuthFunc_ = nullptr; 64 InitFunc initFunc_ = nullptr; 65 ReleaseFunc releaseFunc_ = nullptr; 66 }; 67 } // namespace ConcurrentTask 68 } // namespace OHOS 69 70 #endif