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