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 META_API_CONTENT_OBJECT_H 17 #define META_API_CONTENT_OBJECT_H 18 19 #include <meta/api/property/binding.h> 20 #include <meta/interface/intf_content.h> 21 #include <meta/interface/intf_object_flags.h> 22 #include <meta/interface/intf_required_interfaces.h> 23 24 #include "object.h" 25 26 META_BEGIN_NAMESPACE() 27 28 class ContentObject final : public Internal::ObjectInterfaceAPI<ContentObject, ClassId::ContentObject> { 29 META_API(ContentObject) 30 META_API_OBJECT_CONVERTIBLE(IContent) 31 META_API_CACHE_INTERFACE(IContent, Content) 32 META_API_OBJECT_CONVERTIBLE(IRequiredInterfaces) 33 META_API_CACHE_INTERFACE(IRequiredInterfaces, RequiredInterfaces) 34 public: 35 META_API_INTERFACE_READONLY_PROPERTY_CACHED(Content, Content, IObject::Ptr) 36 META_API_INTERFACE_PROPERTY_CACHED(Content, ContentSearchable, bool) 37 META_API_INTERFACE_PROPERTY_CACHED(Content, ContentLoader, IContentLoader::Ptr) 38 SerializeContent(bool serialize)39 ContentObject& SerializeContent(bool serialize) 40 { 41 SetObjectFlags(ObjectRef(), ObjectFlagBits::SERIALIZE_HIERARCHY, serialize); 42 return *this; 43 } SetContent(const IObject::Ptr& content)44 bool SetContent(const IObject::Ptr& content) 45 { 46 return META_API_CACHED_INTERFACE(Content)->SetContent(content); 47 } SetRequiredInterfaces(const BASE_NS::vector<TypeId>& interfaces)48 bool SetRequiredInterfaces(const BASE_NS::vector<TypeId>& interfaces) 49 { 50 return META_API_CACHED_INTERFACE(RequiredInterfaces)->SetRequiredInterfaces(interfaces); 51 } GetRequiredInterfaces() const52 BASE_NS::vector<TypeId> GetRequiredInterfaces() const 53 { 54 return META_API_CACHED_INTERFACE(RequiredInterfaces)->GetRequiredInterfaces(); 55 } 56 }; 57 58 META_END_NAMESPACE() 59 60 #endif 61