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