• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "stoperator.h"
16 
17 namespace OHOS {
18 namespace STtools {
19 using std::string;
20 
21 int StOperator::countChild = 0;
22 
StOperator()23 StOperator::StOperator()
24     : g_parentOperator(nullptr), g_abilityType("0"), g_bundleName(""),
25     g_abilityName(""), g_operatorName(""), g_message("")
26 {
27     g_childOperator.clear();
28     StOperator::countChild++;
29 }
30 
StOperator(const string & type,const string & bundle,const string & ability,const string & operatorName,const string & message)31 StOperator::StOperator(
32     const string &type, const string &bundle, const string &ability, const string &operatorName, const string &message)
33     : g_parentOperator(nullptr),
34       g_abilityType(type),
35       g_bundleName(bundle),
36       g_abilityName(ability),
37       g_operatorName(operatorName),
38       g_message(message)
39 {
40     g_childOperator.clear();
41     StOperator::countChild++;
42 }
43 
~StOperator()44 StOperator::~StOperator()
45 {
46     g_childOperator.clear();
47     StOperator::countChild--;
48 }
49 
GetCountChild()50 int StOperator::GetCountChild()
51 {
52     return StOperator::countChild;
53 }
54 
GetAbilityType()55 string StOperator::GetAbilityType()
56 {
57     return g_abilityType;
58 }
59 
SetAbilityType(const string & type)60 StOperator &StOperator::SetAbilityType(const string &type)
61 {
62     g_abilityType = type;
63     return *this;
64 }
65 
GetBundleName()66 string StOperator::GetBundleName()
67 {
68     return g_bundleName;
69 }
70 
SetBundleName(const string & bundleName)71 StOperator &StOperator::SetBundleName(const string &bundleName)
72 {
73     g_bundleName = bundleName;
74     return *this;
75 }
76 
GetAbilityName()77 string StOperator::GetAbilityName()
78 {
79     return g_abilityName;
80 }
81 
SetAbilityName(const string & abilityName)82 StOperator &StOperator::SetAbilityName(const string &abilityName)
83 {
84     g_abilityName = abilityName;
85     return *this;
86 }
87 
GetOperatorName()88 string StOperator::GetOperatorName()
89 {
90     return g_operatorName;
91 }
92 
SetOperatorName(const string & operatorName)93 StOperator &StOperator::SetOperatorName(const string &operatorName)
94 {
95     g_operatorName = operatorName;
96     return *this;
97 }
98 
GetMessage()99 string StOperator::GetMessage()
100 {
101     return g_message;
102 }
103 
SetMessage(const string & message)104 StOperator &StOperator::SetMessage(const string &message)
105 {
106     g_message = message;
107     return *this;
108 }
109 
AddChildOperator(std::shared_ptr<StOperator> childOperator)110 StOperator &StOperator::AddChildOperator(std::shared_ptr<StOperator> childOperator)
111 {
112     if (childOperator == nullptr) {
113         return *this;
114     }
115     childOperator->g_parentOperator = std::make_shared<StOperator>(*this);
116     g_childOperator.emplace_back(childOperator);
117     return *this;
118 }
119 
GetChildOperator()120 std::vector<std::shared_ptr<StOperator>> StOperator::GetChildOperator()
121 {
122     return g_childOperator;
123 }
124 }  // namespace STtools
125 }  // namespace OHOS