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_ELEMENT_H 17 #define CPP_ABCKIT_CORE_ANNOTATION_ELEMENT_H 18 19 #include "../base_classes.h" 20 #include "../value.h" 21 22 #include <string> 23 24 namespace abckit::core { 25 26 /** 27 * @brief AnnotationElement 28 */ 29 class AnnotationElement : public ViewInResource<AbckitCoreAnnotationElement *, const File *> { 30 /// @brief core::Annotation 31 friend class core::Annotation; 32 /// @brief arkts::Annotation 33 friend class arkts::Annotation; 34 /// @brief core::Module 35 friend class core::Module; 36 /// @brief arkts::Module 37 friend class arkts::Module; 38 /// @brief abckit::DefaultHash<AnnotationElement> 39 friend class abckit::DefaultHash<AnnotationElement>; 40 41 protected: 42 /// @brief CoreViewT - Core API View type 43 using CoreViewT = AnnotationElement; 44 45 public: 46 /** 47 * @brief Constructor 48 * @param other 49 */ 50 AnnotationElement(const AnnotationElement &other) = default; 51 52 /** 53 * @brief Constructor 54 * @param other 55 * @return this 56 */ 57 AnnotationElement &operator=(const AnnotationElement &other) = default; 58 59 /** 60 * @brief Constructor 61 * @param other 62 */ 63 AnnotationElement(AnnotationElement &&other) = default; // CC-OFF(G.CLS.07): design decision 64 65 /** 66 * @brief Constructor 67 * @param other 68 * @return AnnotationElement& 69 */ 70 AnnotationElement &operator=(AnnotationElement &&other) = default; 71 72 /** 73 * @brief Destructor 74 */ 75 ~AnnotationElement() override = default; 76 77 /** 78 * @brief Returns binary file that the Annotation Element 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 annotation element. 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 value for annotation element. 94 * @return `Value`. 95 * @note Set `ABCKIT_STATUS_BAD_ARGUMENT` error if view itself is false. 96 */ 97 Value GetValue() const; 98 99 /** 100 * @brief Returns annotation for Annotation Element. 101 * @return core::Annotation. 102 * @note Set `ABCKIT_STATUS_BAD_ARGUMENT` error if view itself is false. 103 */ 104 core::Annotation GetAnnotation() const; 105 106 private: 107 /** 108 * Constructor 109 * @param conf 110 * @param anne 111 * @param file 112 */ AnnotationElement(AbckitCoreAnnotationElement * anne,const ApiConfig * conf,const File * file)113 AnnotationElement(AbckitCoreAnnotationElement *anne, const ApiConfig *conf, const File *file) 114 : ViewInResource(anne), conf_(conf) 115 { 116 SetResource(file); 117 }; 118 const ApiConfig *conf_; 119 120 protected: 121 /** 122 * @brief Get the Api Config object 123 * @return const ApiConfig* 124 */ GetApiConfig()125 const ApiConfig *GetApiConfig() const override 126 { 127 return conf_; 128 } 129 }; 130 131 } // namespace abckit::core 132 133 #endif // CPP_ABCKIT_CORE_ANNOTATION_ELEMENT_H 134