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_INTERFACE_ICONTENT_H 17 #define META_INTERFACE_ICONTENT_H 18 19 #include <meta/base/interface_macros.h> 20 #include <meta/base/namespace.h> 21 #include <meta/interface/interface_macros.h> 22 #include <meta/interface/loaders/intf_content_loader.h> 23 24 META_BEGIN_NAMESPACE() 25 26 REGISTER_INTERFACE(IContent, "837cb3bf-df9d-4585-9293-82e782778db3") 27 28 /** 29 * @brief The IContent interface defines an interface which can be implemented by objects 30 * that contain an internal object hierarchy which should not be visible in the 31 * application object hierarchy. 32 */ 33 class IContent : public CORE_NS::IInterface { 34 META_INTERFACE(CORE_NS::IInterface, IContent) 35 public: 36 /** 37 * @brief The object content. The implementer forwards all appropriate calls 38 * to content, which means that in practise the object set to Content will 39 * behave as it would be a child of the object implementing IContent. 40 * 41 * The difference is that the object hierarchy under Content is not available 42 * as a child of the object. 43 * @note The implementer shall use IObjectFlags::SERIALIZE_HIERARCHY flag to determine 44 * if the Content property should be serialized when exporting the object. By default 45 * IContent implementations should not serialize their content. 46 */ 47 META_READONLY_PROPERTY(IObject::Ptr, Content) 48 /** 49 * @brief Set value of Content property. This will also reset the ContentLoader property to null. 50 * @param content The object to set as content. 51 * @return True if content was successfully set, false otherwise. 52 * @note This function can fail e.g. if the implementer also implements IRequiredInterfaces 53 * and the content does not fulfil interface requirements. 54 */ 55 virtual bool SetContent(const IObject::Ptr& content) = 0; 56 /** 57 * @brief If true, the object hierarchy contained within the Content property should be 58 * searched when finding items from a object hierarchy (see IContainer::Find* methods). 59 * When false, the content hierarchy should be considered internal and not traversed 60 * by external users. 61 * 62 * The default value is true. 63 */ 64 META_PROPERTY(bool, ContentSearchable) 65 /** 66 * @brief If set, the Content property should be automatically populated by using the 67 * specified IContentLoader. 68 */ 69 META_PROPERTY(META_NS::IContentLoader::Ptr, ContentLoader) 70 }; 71 72 META_END_NAMESPACE() 73 74 #endif 75