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 OHOS_REQUEST_CJ_EVENT_H 17 #define OHOS_REQUEST_CJ_EVENT_H 18 19 #include <string> 20 #include <unordered_set> 21 #include "cj_request_task.h" 22 23 namespace OHOS::CJSystemapi::Request { 24 using OHOS::Request::ExceptionErrorCode; 25 26 class CJRequestEvent final { 27 public: 28 CJRequestEvent() = default; 29 ~CJRequestEvent() = default; 30 CJRequestEvent(CJRequestEvent const &) = delete; 31 void operator=(CJRequestEvent const &) = delete; 32 CJRequestEvent(CJRequestEvent &&) = delete; 33 CJRequestEvent &operator=(CJRequestEvent &&) = delete; 34 35 static ExceptionErrorCode Exec(std::string execType, const CJTask *task); 36 static SubscribeType StringToSubscribeType(const std::string &type); 37 38 private: 39 using Event = std::function<int32_t(const CJTask *)>; 40 static std::map<std::string, Event> requestEvent_; 41 42 static ExceptionErrorCode StartExec(const CJTask *task); 43 static ExceptionErrorCode StopExec(const CJTask *task); 44 static ExceptionErrorCode PauseExec(const CJTask *task); 45 static ExceptionErrorCode ResumeExec(const CJTask *task); 46 static std::map<std::string, SubscribeType> supportEventsV10_; 47 }; 48 49 } // namespace OHOS::CJSystemapi::Request 50 51 #endif // OHOS_REQUEST_CJ_EVENT_H