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_ICONTAINER_OBSERVER_H 17 #define META_INTERFACE_ICONTAINER_OBSERVER_H 18 19 #include <meta/interface/intf_container.h> 20 21 META_BEGIN_NAMESPACE() 22 23 META_REGISTER_INTERFACE(IContainerObserver, "19ddad68-4743-4902-a816-a5f4d5812c7e") 24 25 /** 26 * @brief The IContainerObserver interface can be implemented by classes which 27 * can be used to monitor the container hierarchy of an IContainer. 28 * 29 * The difference between IContainerObserver events and IContainer events 30 * is that IContainer defines events only for the immediate children of 31 * the IContainer, while IContainerObserver events are fired as a response 32 * to changes in the entire child hierarchy. 33 */ 34 class IContainerObserver : public CORE_NS::IInterface { 35 META_INTERFACE(CORE_NS::IInterface, IContainerObserver) 36 public: 37 /** 38 * @brief Sets the container to observe. 39 * @param container The target container. 40 */ 41 virtual void SetContainer(const IContainer::Ptr& container) = 0; 42 /** 43 * @brief Invoked when a child is added to any container in the hierarchy. 44 */ 45 META_EVENT(IOnChildChanged, OnDescendantAdded) 46 /** 47 * @brief Invoked when a child is removed from any container in the hierarchy. 48 */ 49 META_EVENT(IOnChildChanged, OnDescendantRemoved) 50 /** 51 * @brief Invoked when a child is moved within any container in the hierarchy. 52 */ 53 META_EVENT(IOnChildMoved, OnDescendantMoved) 54 }; 55 56 META_END_NAMESPACE() 57 58 #endif // META_INTERFACE_ICONTAINER_OBSERVER_H 59