/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef META_API_CONTAINER_OBSERVER_H #define META_API_CONTAINER_OBSERVER_H #include #include #include #include META_BEGIN_NAMESPACE() /** * @brief The ContainerObserver class provides a wrapper for META_NS::ClassId::ContainerObserver. */ class ContainerObserver final : public Internal::ObjectInterfaceAPI { META_API(ContainerObserver) META_API_CACHE_INTERFACE(META_NS::IContainerObserver, Observer) public: /** * @brief See IContainerObserver::SetContainer. */ auto& Container(const IContainer::Ptr& container) { META_API_CACHED_INTERFACE(Observer)->SetContainer(container); return *this; } /** * @brief See IContainerObserver::OnDescendantAdded. */ template auto& OnDescendantAdded(Callback&& callback) { META_API_CACHED_INTERFACE(Observer)->OnDescendantAdded()->AddHandler( META_NS::MakeCallback(BASE_NS::forward(callback))); return *this; } /** * @brief See IContainerObserver::OnDescendantRemoved. */ template auto& OnDescendantRemoved(Callback&& callback) { META_API_CACHED_INTERFACE(Observer)->OnDescendantRemoved()->AddHandler( META_NS::MakeCallback(BASE_NS::forward(callback))); return *this; } /** * @brief See IContainerObserver::OnDescendantMoved. */ template auto& OnDescendantMoved(Callback&& callback) { META_API_CACHED_INTERFACE(Observer)->OnDescendantMoved()->AddHandler( META_NS::MakeCallback(BASE_NS::forward(callback))); return *this; } }; META_END_NAMESPACE() #endif // META_API_CONTAINER_OBSERVER_H