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