• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_IDL_ASTINTERFACETYPE_H
17 #define OHOS_IDL_ASTINTERFACETYPE_H
18 
19 #include <cstddef>
20 #include <vector>
21 
22 #include "ast/ast_method.h"
23 #include "ast/ast_namespace.h"
24 #include "ast/ast_type.h"
25 #include "util/autoptr.h"
26 #include "util/string.h"
27 
28 namespace OHOS {
29 namespace Idl {
30 class ASTInterfaceType : public ASTType {
31 public:
32     void SetNamespace(ASTNamespace* nspace) override;
33 
SetLicense(const String & license)34     void SetLicense(const String& license)
35     {
36         license_ = license;
37     }
38 
GetLicense()39     String GetLicense() const
40     {
41         return license_;
42     }
43 
SetOneway(bool oneway)44     void SetOneway(bool oneway)
45     {
46         oneway_ = oneway;
47     }
48 
IsOneway()49     bool IsOneway()
50     {
51         return oneway_;
52     }
53 
54     void AddMethod(ASTMethod* method);
55 
56     AutoPtr<ASTMethod> GetMethod(size_t index);
57 
GetMethodNumber()58     size_t GetMethodNumber()
59     {
60         return methods_.size();
61     }
62 
SetExternal(bool external)63     void SetExternal(bool external)
64     {
65         isExternal_ = external;
66     }
67 
IsExternal()68     bool IsExternal() const
69     {
70         return isExternal_;
71     }
72 
73     String GetSignature() override;
74 
75     bool IsInterfaceType() override;
76 
77     String ToString() override;
78 
79     String Dump(const String& prefix) override;
80 
81 private:
82     String license_;
83     bool oneway_ = false;
84     std::vector<AutoPtr<ASTMethod>> methods_;
85     bool isExternal_ = false;
86 };
87 } // namespace Idl
88 } // namespace OHOS
89 #endif // OHOS_IDL_ASTINTERFACETYPE_H
90