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_JS_IMPORT_DESCRIPTOR_H 17 #define CPP_ABCKIT_JS_IMPORT_DESCRIPTOR_H 18 19 #include "../core/import_descriptor.h" 20 #include "../base_concepts.h" 21 22 namespace abckit::js { 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::js::Module; 31 /// @brief abckit::DefaultHash<ImportDescriptor> 32 friend class abckit::DefaultHash<ImportDescriptor>; 33 /// @brief to access private TargetCast 34 friend class abckit::traits::TargetCheckCast<ImportDescriptor>; 35 36 public: 37 /** 38 * @brief Constructor Arkts API ImportDescriptor from the Core API with compatibility check 39 * @param other - Core API ImportDescriptor 40 */ 41 explicit ImportDescriptor(const core::ImportDescriptor &other); 42 43 /** 44 * @brief Construct a new Import Descriptor object 45 * @param other 46 */ 47 ImportDescriptor(const ImportDescriptor &other) = default; 48 49 /** 50 * @brief Constructor 51 * @param other 52 * @return ImportDescriptor& 53 */ 54 ImportDescriptor &operator=(const ImportDescriptor &other) = default; 55 56 /** 57 * @brief Construct a new Import Descriptor object 58 * @param other 59 */ 60 ImportDescriptor(ImportDescriptor &&other) = default; 61 62 /** 63 * @brief Constructor 64 * @param other 65 * @return ImportDescriptor& 66 */ 67 ImportDescriptor &operator=(ImportDescriptor &&other) = default; 68 69 /** 70 * @brief Destroy the Import Descriptor object 71 */ 72 ~ImportDescriptor() override = default; 73 74 private: 75 /** 76 * @brief Converts underlying import descriptor from Core to Js target 77 * @return AbckitJsImportDescriptor* - converted import descriptor 78 * @note Set `ABCKIT_STATUS_WRONG_TARGET` error if `this` is does not have `ABCKIT_TARGET_JS` target. 79 */ 80 AbckitJsImportDescriptor *TargetCast() const; 81 82 ABCKIT_NO_UNIQUE_ADDRESS traits::TargetCheckCast<ImportDescriptor> targetChecker_; 83 }; 84 85 } // namespace abckit::js 86 87 #endif // CPP_ABCKIT_JS_IMPORT_DESCRIPTOR_H 88