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 API_CORE_PROPERTY_IPROPERTY_API_H 17 #define API_CORE_PROPERTY_IPROPERTY_API_H 18 19 #include <cstddef> 20 #include <cstdint> 21 22 #include <base/containers/array_view.h> 23 #include <base/namespace.h> 24 #include <core/namespace.h> 25 26 CORE_BEGIN_NAMESPACE() 27 struct Property; 28 class IPropertyHandle; 29 30 /** @ingroup group_property_ipropertyapi */ 31 /** IProperty api */ 32 class IPropertyApi { 33 public: 34 /** Property count of component. 35 */ 36 virtual size_t PropertyCount() const = 0; 37 38 /** Metadata for property. 39 */ 40 virtual const Property* MetaData(size_t index) const = 0; 41 42 /** Metadata for properties. 43 */ 44 virtual BASE_NS::array_view<const Property> MetaData() const = 0; 45 46 /** Create a new handle (default initialized data) 47 */ 48 virtual IPropertyHandle* Create() const = 0; 49 50 /** Create a new handle with a copy of srcHandle data 51 */ 52 virtual IPropertyHandle* Clone(const IPropertyHandle* srcHandle) const = 0; 53 54 /** Fully destruct the handle. The handle will be completely released and no calls to it shall be made anymore. 55 */ 56 virtual void Release(IPropertyHandle* handle) const = 0; 57 58 /* Type hash, can be used to see if the data is of matching type, without comparing the MetaDatas. 59 */ 60 virtual uint64_t Type() const = 0; 61 62 protected: 63 IPropertyApi() = default; 64 virtual ~IPropertyApi() = default; 65 IPropertyApi(const IPropertyApi&) = delete; 66 IPropertyApi(IPropertyApi&&) = delete; 67 IPropertyApi& operator=(const IPropertyApi&) = delete; 68 }; 69 CORE_END_NAMESPACE() 70 #endif // API_CORE_PROPERTY_IPROPERTY_API_H 71