• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 CPP_ABCKIT_ARKTS_ANNOTATION_ELEMENT_H
17 #define CPP_ABCKIT_ARKTS_ANNOTATION_ELEMENT_H
18 
19 #include "../core/annotation_element.h"
20 #include "../base_concepts.h"
21 
22 namespace abckit::arkts {
23 
24 /**
25  * @brief AnnotationElement
26  */
27 class AnnotationElement : public core::AnnotationElement {
28     // We restrict constructors in order to prevent C/C++ API mix-up by user.
29     /// @brief to access private constructor
30     friend class arkts::Class;
31     /// @brief to access private constructor
32     friend class arkts::Function;
33     /// @brief to access private constructor
34     friend class arkts::Annotation;
35     /// @brief abckit::DefaultHash<AnnotationElement>
36     friend class abckit::DefaultHash<AnnotationElement>;
37     /// @brief to access private TargetCast
38     friend class abckit::traits::TargetCheckCast<AnnotationElement>;
39 
40 public:
41     /**
42      * @brief Constructor Arkts API AnnotationElement from the Core API with compatibility check
43      * @param coreOther - Core API AnnotationElement
44      */
45     explicit AnnotationElement(const core::AnnotationElement &coreOther);
46 
47     /**
48      * @brief Construct a new Annotation Element object
49      * @param other
50      */
51     AnnotationElement(const AnnotationElement &other) = default;
52 
53     /**
54      * @brief Constructor
55      * @param other
56      * @return AnnotationElement&
57      */
58     AnnotationElement &operator=(const AnnotationElement &other) = default;
59 
60     /**
61      * @brief Construct a new Annotation Element object
62      * @param other
63      */
64     AnnotationElement(AnnotationElement &&other) = default;
65 
66     /**
67      * @brief Constructor
68      * @param other
69      * @return AnnotationElement&
70      */
71     AnnotationElement &operator=(AnnotationElement &&other) = default;
72 
73     /**
74      * @brief Destroy the Annotation Element object
75      */
76     ~AnnotationElement() override = default;
77 
78     /**
79      * @brief Get the Name object
80      * @return std::string
81      */
82     std::string GetName() const;
83 
84 private:
85     /**
86      * @brief Converts annotation element from Core to Arkts target
87      * @return AbckitArktsAnnotationElement* - converted annotation element
88      * @note Set `ABCKIT_STATUS_WRONG_TARGET` error if `this` is does not have `ABCKIT_TARGET_ARK_TS_V1` or
89      * `ABCKIT_TARGET_ARK_TS_V2` target.
90      */
91     AbckitArktsAnnotationElement *TargetCast() const;
92 
93     ABCKIT_NO_UNIQUE_ADDRESS traits::TargetCheckCast<AnnotationElement> targetChecker_;
94 };
95 
96 }  // namespace abckit::arkts
97 
98 #endif  // CPP_ABCKIT_ARKTS_ANNOTATION_ELEMENT_H
99