• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "operation_builder.h"
16 #include "operation.h"
17 
18 namespace OHOS {
19 namespace AAFwk {
OperationBuilder()20 OperationBuilder::OperationBuilder()
21     : abilityName_(""), action_(""), bundleName_(""), deviceId_(""), flags_(0), uri_("")
22 {
23     entities_.clear();
24 }
25 
~OperationBuilder()26 OperationBuilder::~OperationBuilder()
27 {}
28 
WithAbilityName(const std::string & abilityName)29 OperationBuilder &OperationBuilder::WithAbilityName(const std::string &abilityName)
30 {
31     abilityName_ = abilityName;
32     return *this;
33 }
34 
WithBundleName(const std::string & bundleName)35 OperationBuilder &OperationBuilder::WithBundleName(const std::string &bundleName)
36 {
37     bundleName_ = bundleName;
38     return *this;
39 }
40 
WithDeviceId(const std::string & deviceID)41 OperationBuilder &OperationBuilder::WithDeviceId(const std::string &deviceID)
42 {
43     deviceId_ = deviceID;
44     return *this;
45 }
46 
WithAction(const std::string & action)47 OperationBuilder &OperationBuilder::WithAction(const std::string &action)
48 {
49     action_ = action;
50     return *this;
51 }
52 
WithEntities(const std::vector<std::string> & entities)53 OperationBuilder &OperationBuilder::WithEntities(const std::vector<std::string> &entities)
54 {
55     entities_ = entities;
56     return *this;
57 }
58 
WithFlags(uint8_t flags)59 OperationBuilder &OperationBuilder::WithFlags(uint8_t flags)
60 {
61     flags_ = flags;
62     return *this;
63 }
64 
WithUri(const Uri & uri)65 OperationBuilder &OperationBuilder::WithUri(const Uri &uri)
66 {
67     uri_ = uri;
68     return *this;
69 }
70 
Build()71 std::shared_ptr<Operation> OperationBuilder::Build()
72 {
73     std::shared_ptr<Operation> operation = std::make_shared<Operation>();
74     operation->abilityName_ = abilityName_;
75     operation->bundleName_ = bundleName_;
76     operation->deviceId_ = deviceId_;
77     operation->action_ = action_;
78     operation->entities_ = entities_;
79     operation->flags_ = flags_;
80     operation->uri_ = uri_;
81 
82     return operation;
83 }
84 }  // namespace AAFwk
85 }  // namespace OHOS
86