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_CORE_ANNOTATION_INTERFACE_FIELD_H 17 #define CPP_ABCKIT_CORE_ANNOTATION_INTERFACE_FIELD_H 18 19 #include "../base_classes.h" 20 #include "../type.h" 21 22 #include <string> 23 24 namespace abckit::core { 25 26 /** 27 * @brief AnnotationInterfaceField 28 */ 29 class AnnotationInterfaceField : public ViewInResource<AbckitCoreAnnotationInterfaceField *, const File *> { 30 /// @brief core::Annotation 31 friend class core::Annotation; 32 /// @brief arkts::Annotation 33 friend class arkts::Annotation; 34 /// @brief core::AnnotationInterface 35 friend class core::AnnotationInterface; 36 /// @brief arkts::AnnotationInterface 37 friend class arkts::AnnotationInterface; 38 /// @brief abckit::DefaultHash<AnnotationInterfaceField> 39 friend class abckit::DefaultHash<AnnotationInterfaceField>; 40 41 protected: 42 /// @brief Core API View type 43 using CoreViewT = AnnotationInterfaceField; 44 45 public: 46 /** 47 * @brief Construct a new Annotation Interface Field object 48 * @param other 49 */ 50 AnnotationInterfaceField(const AnnotationInterfaceField &other) = default; 51 52 /** 53 * @brief Constructor 54 * @param other 55 * @return AnnotationInterfaceField& 56 */ 57 AnnotationInterfaceField &operator=(const AnnotationInterfaceField &other) = default; 58 59 /** 60 * @brief Construct a new Annotation Interface Field object 61 * @param other 62 */ 63 AnnotationInterfaceField(AnnotationInterfaceField &&other) = default; // CC-OFF(G.CLS.07): design decision 64 65 /** 66 * @brief Constructor 67 * @param other 68 * @return AnnotationInterfaceField& 69 */ 70 AnnotationInterfaceField &operator=(AnnotationInterfaceField &&other) = default; 71 72 /** 73 * @brief Destroy the Annotation Interface Field object 74 */ 75 ~AnnotationInterfaceField() override = default; 76 77 /** 78 * @brief Returns binary file that the given interface field is a part of. 79 * @return `const File *`. 80 * @note Set `ABCKIT_STATUS_BAD_ARGUMENT` error if view itself is false. 81 */ 82 const File *GetFile() const; 83 84 /** 85 * @brief Returns name for interface field. 86 * @return `std::string`. 87 * @note Set `ABCKIT_STATUS_BAD_ARGUMENT` error if view itself is false. 88 * @note Allocates 89 */ 90 std::string GetName() const; 91 92 /** 93 * @brief Returns interface for interface field. 94 * @return `core::AnnotationInterface`. 95 * @note Set `ABCKIT_STATUS_BAD_ARGUMENT` error if view itself is false. 96 */ 97 core::AnnotationInterface GetInterface() const; 98 99 /** 100 * @brief Returns type for interface field. 101 * @return `Type`. 102 * @note Set `ABCKIT_STATUS_BAD_ARGUMENT` error if view itself is false. 103 */ 104 Type GetType() const; 105 106 /** 107 * @brief Returns default value for interface field. 108 * @return `Value`. 109 * @note Set `ABCKIT_STATUS_BAD_ARGUMENT` error if view itself is false. 110 */ 111 Value GetDefaultValue() const; 112 113 private: AnnotationInterfaceField(AbckitCoreAnnotationInterfaceField * anni,const ApiConfig * conf,const File * file)114 AnnotationInterfaceField(AbckitCoreAnnotationInterfaceField *anni, const ApiConfig *conf, const File *file) 115 : ViewInResource(anni), conf_(conf) 116 { 117 SetResource(file); 118 }; 119 const ApiConfig *conf_; 120 121 protected: 122 /** 123 * @brief Get the Api Config object 124 * @return const ApiConfig* 125 */ GetApiConfig()126 const ApiConfig *GetApiConfig() const override 127 { 128 return conf_; 129 } 130 }; 131 132 } // namespace abckit::core 133 134 #endif // CPP_ABCKIT_CORE_ANNOTATION_INTERFACE_FIELD_H 135