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