1 /* 2 * Copyright (c) 2021-2022 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_ABILITY_BASE_OPERATION_BUILDER_H 17 #define OHOS_ABILITY_BASE_OPERATION_BUILDER_H 18 #include <string> 19 #include <vector> 20 #include <memory> 21 #include "uri.h" 22 23 namespace OHOS { 24 namespace AAFwk { 25 class Operation; 26 class OperationBuilder { 27 public: 28 OperationBuilder(); 29 ~OperationBuilder(); 30 31 /** 32 * @description: Sets a AbilityName in an OperationBuilder. 33 * @return Returns this OperationBuilder object containing the AbilityName. 34 */ 35 OperationBuilder &WithAbilityName(const std::string &abilityName); 36 37 /** 38 * @description: Sets a BundleName in an OperationBuilder. 39 * @return Returns this OperationBuilder object containing the BundleName. 40 */ 41 OperationBuilder &WithBundleName(const std::string &bundleName); 42 43 /** 44 * @description: Sets a DeviceId in an OperationBuilder. 45 * @return Returns this OperationBuilder object containing the DeviceId. 46 */ 47 OperationBuilder &WithDeviceId(const std::string &deviceID); 48 49 /** 50 * @description: Sets a Action in an OperationBuilder. 51 * @return Returns this OperationBuilder object containing the Action. 52 */ 53 OperationBuilder &WithAction(const std::string &action); 54 55 /** 56 * @description: Sets a Entities in an OperationBuilder. 57 * @return Returns this OperationBuilder object containing the Entities. 58 */ 59 OperationBuilder &WithEntities(const std::vector<std::string> &entities); 60 61 /** 62 * @description: Sets a Flags in an OperationBuilder. 63 * @return Returns this OperationBuilder object containing the Flags. 64 */ 65 OperationBuilder &WithFlags(unsigned int flags); 66 67 /** 68 * @description: Sets a Uri in an OperationBuilder. 69 * @return Returns this OperationBuilder object containing the Uri. 70 */ 71 OperationBuilder &WithUri(const Uri &uri); 72 std::shared_ptr<Operation> build(); 73 74 private: 75 std::string abilityName_ = ""; 76 std::string action_ = ""; 77 std::string bundleName_ = ""; 78 std::string deviceId_ = ""; 79 std::vector<std::string> entities_ = {}; 80 unsigned int flags_ = 0; 81 Uri uri_; 82 }; 83 } // namespace AAFwk 84 } // namespace OHOS 85 86 #endif // OHOS_ABILITY_BASE_OPERATION_BUILDER_H