1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef OHOS_HDI_ASTMETHOD_H 10 #define OHOS_HDI_ASTMETHOD_H 11 12 #include <vector> 13 14 #include "ast/ast_node.h" 15 #include "ast/ast_parameter.h" 16 #include "util/autoptr.h" 17 18 namespace OHOS { 19 namespace HDI { 20 class ASTMethod : public ASTNode { 21 public: SetName(const std::string & name)22 inline void SetName(const std::string &name) 23 { 24 name_ = name; 25 } 26 GetName()27 inline std::string GetName() 28 { 29 return name_; 30 } 31 SetAttribute(const AutoPtr<ASTMethodAttr> & attr)32 inline void SetAttribute(const AutoPtr<ASTMethodAttr> &attr) 33 { 34 if (attr != nullptr) { 35 attr_ = attr; 36 } 37 } 38 IsOneWay()39 inline bool IsOneWay() 40 { 41 return attr_->isOneWay_; 42 } 43 IsFull()44 inline bool IsFull() 45 { 46 return attr_->isFull_; 47 } 48 IsLite()49 inline bool IsLite() 50 { 51 return attr_->isLite_; 52 } 53 54 void AddParameter(const AutoPtr<ASTParameter> ¶meter); 55 56 AutoPtr<ASTParameter> GetParameter(size_t index); 57 GetParameterNumber()58 inline size_t GetParameterNumber() 59 { 60 return parameters_.size(); 61 } 62 63 std::string Dump(const std::string &prefix) override; 64 65 private: 66 std::string name_; 67 AutoPtr<ASTMethodAttr> attr_ = new ASTMethodAttr(); 68 std::vector<AutoPtr<ASTParameter>> parameters_; 69 }; 70 } // namespace HDI 71 } // namespace OHOS 72 73 #endif // OHOS_HDI_ASTMETHOD_H 74