18bf80f4bSopenharmony_ci/* 28bf80f4bSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 38bf80f4bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48bf80f4bSopenharmony_ci * you may not use this file except in compliance with the License. 58bf80f4bSopenharmony_ci * You may obtain a copy of the License at 68bf80f4bSopenharmony_ci * 78bf80f4bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88bf80f4bSopenharmony_ci * 98bf80f4bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108bf80f4bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118bf80f4bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128bf80f4bSopenharmony_ci * See the License for the specific language governing permissions and 138bf80f4bSopenharmony_ci * limitations under the License. 148bf80f4bSopenharmony_ci */ 158bf80f4bSopenharmony_ci#ifndef META_SRC_METADATA_H 168bf80f4bSopenharmony_ci#define META_SRC_METADATA_H 178bf80f4bSopenharmony_ci 188bf80f4bSopenharmony_ci#include <base/containers/array_view.h> 198bf80f4bSopenharmony_ci#include <base/containers/vector.h> 208bf80f4bSopenharmony_ci 218bf80f4bSopenharmony_ci#include <meta/base/types.h> 228bf80f4bSopenharmony_ci#include <meta/ext/implementation_macros.h> 238bf80f4bSopenharmony_ci#include <meta/interface/interface_helpers.h> 248bf80f4bSopenharmony_ci#include <meta/interface/intf_container.h> 258bf80f4bSopenharmony_ci#include <meta/interface/intf_metadata.h> 268bf80f4bSopenharmony_ci 278bf80f4bSopenharmony_ci#include "container/flat_container.h" 288bf80f4bSopenharmony_ci 298bf80f4bSopenharmony_ciMETA_BEGIN_NAMESPACE() 308bf80f4bSopenharmony_ci 318bf80f4bSopenharmony_cinamespace Internal { 328bf80f4bSopenharmony_ci 338bf80f4bSopenharmony_ciclass Metadata : public IntroduceInterfaces<IMetadata> { 348bf80f4bSopenharmony_cipublic: 358bf80f4bSopenharmony_ci Metadata(); 368bf80f4bSopenharmony_ci Metadata(const IMetadata& data); 378bf80f4bSopenharmony_ci ~Metadata() override = default; 388bf80f4bSopenharmony_ci 398bf80f4bSopenharmony_ci IMetadata::Ptr CloneMetadata() const override; 408bf80f4bSopenharmony_ci 418bf80f4bSopenharmony_ciprotected: 428bf80f4bSopenharmony_ci IContainer::Ptr GetPropertyContainer() override; 438bf80f4bSopenharmony_ci IContainer::ConstPtr GetPropertyContainer() const override; 448bf80f4bSopenharmony_ci 458bf80f4bSopenharmony_ci void AddFunction(const IFunction::Ptr&) override; 468bf80f4bSopenharmony_ci void RemoveFunction(const IFunction::Ptr&) override; 478bf80f4bSopenharmony_ci 488bf80f4bSopenharmony_ci void AddProperty(const IProperty::Ptr&) override; 498bf80f4bSopenharmony_ci void RemoveProperty(const IProperty::Ptr&) override; 508bf80f4bSopenharmony_ci 518bf80f4bSopenharmony_ci void AddEvent(const IEvent::Ptr&) override; 528bf80f4bSopenharmony_ci void RemoveEvent(const IEvent::Ptr&) override; 538bf80f4bSopenharmony_ci 548bf80f4bSopenharmony_ci void SetProperties(const BASE_NS::vector<IProperty::Ptr>&) override; 558bf80f4bSopenharmony_ci 568bf80f4bSopenharmony_ci void Merge(const IMetadata::Ptr&) override; 578bf80f4bSopenharmony_ci 588bf80f4bSopenharmony_ci BASE_NS::vector<IProperty::Ptr> GetAllProperties() override; 598bf80f4bSopenharmony_ci BASE_NS::vector<IProperty::ConstPtr> GetAllProperties() const override; 608bf80f4bSopenharmony_ci BASE_NS::vector<IFunction::Ptr> GetAllFunctions() override; 618bf80f4bSopenharmony_ci BASE_NS::vector<IFunction::ConstPtr> GetAllFunctions() const override; 628bf80f4bSopenharmony_ci BASE_NS::vector<IEvent::Ptr> GetAllEvents() override; 638bf80f4bSopenharmony_ci BASE_NS::vector<IEvent::ConstPtr> GetAllEvents() const override; 648bf80f4bSopenharmony_ci 658bf80f4bSopenharmony_ci IProperty::Ptr GetPropertyByName(BASE_NS::string_view name) override; 668bf80f4bSopenharmony_ci IProperty::ConstPtr GetPropertyByName(BASE_NS::string_view name) const override; 678bf80f4bSopenharmony_ci IFunction::Ptr GetFunctionByName(BASE_NS::string_view name) override; 688bf80f4bSopenharmony_ci IFunction::ConstPtr GetFunctionByName(BASE_NS::string_view name) const override; 698bf80f4bSopenharmony_ci IEvent::ConstPtr GetEventByName(BASE_NS::string_view name) const override; 708bf80f4bSopenharmony_ci IEvent::Ptr GetEventByName(BASE_NS::string_view name) override; 718bf80f4bSopenharmony_ci 728bf80f4bSopenharmony_ciprivate: 738bf80f4bSopenharmony_ci BASE_NS::shared_ptr<class MetadataPropertyContainer> propertyContainer_; 748bf80f4bSopenharmony_ci IContainer::Ptr properties_; 758bf80f4bSopenharmony_ci BASE_NS::vector<IFunction::Ptr> functionMetadata_; 768bf80f4bSopenharmony_ci BASE_NS::vector<IEvent::Ptr> eventMetadata_; 778bf80f4bSopenharmony_ci}; 788bf80f4bSopenharmony_ci 798bf80f4bSopenharmony_ciclass MetadataPropertyContainer 808bf80f4bSopenharmony_ci : public IntroduceInterfaces<IObject, IContainer, IRequiredInterfaces, IContainerPreTransaction, IIterable> { 818bf80f4bSopenharmony_cipublic: 828bf80f4bSopenharmony_ci MetadataPropertyContainer(); 838bf80f4bSopenharmony_ci ~MetadataPropertyContainer() override = default; 848bf80f4bSopenharmony_ci META_NO_COPY_MOVE(MetadataPropertyContainer); 858bf80f4bSopenharmony_ci 868bf80f4bSopenharmony_ci BASE_NS::vector<IObject::Ptr> GetAll() const override; 878bf80f4bSopenharmony_ci IObject::Ptr GetAt(SizeType index) const override; 888bf80f4bSopenharmony_ci SizeType GetSize() const override; 898bf80f4bSopenharmony_ci BASE_NS::vector<IObject::Ptr> FindAll(const FindOptions& options) const override; 908bf80f4bSopenharmony_ci IObject::Ptr FindAny(const FindOptions& options) const override; 918bf80f4bSopenharmony_ci IObject::Ptr FindByName(BASE_NS::string_view name) const override; 928bf80f4bSopenharmony_ci bool Add(const IObject::Ptr& object) override; 938bf80f4bSopenharmony_ci bool Insert(SizeType index, const IObject::Ptr& object) override; 948bf80f4bSopenharmony_ci bool Remove(SizeType index) override; 958bf80f4bSopenharmony_ci bool Remove(const IObject::Ptr& child) override; 968bf80f4bSopenharmony_ci bool Move(SizeType fromIndex, SizeType toIndex) override; 978bf80f4bSopenharmony_ci bool Move(const IObject::Ptr& child, SizeType toIndex) override; 988bf80f4bSopenharmony_ci bool Replace(const IObject::Ptr& child, const IObject::Ptr& replaceWith, bool addAlways) override; 998bf80f4bSopenharmony_ci void RemoveAll() override; 1008bf80f4bSopenharmony_ci bool SetRequiredInterfaces(const BASE_NS::vector<TypeId>& interfaces) override; 1018bf80f4bSopenharmony_ci bool IsAncestorOf(const IObject::ConstPtr& object) const override; 1028bf80f4bSopenharmony_ci BASE_NS::vector<TypeId> GetRequiredInterfaces() const override; 1038bf80f4bSopenharmony_ci BASE_NS::shared_ptr<IEvent> EventOnAdded() const override; 1048bf80f4bSopenharmony_ci BASE_NS::shared_ptr<IEvent> EventOnRemoved() const override; 1058bf80f4bSopenharmony_ci BASE_NS::shared_ptr<IEvent> EventOnMoved() const override; 1068bf80f4bSopenharmony_ci BASE_NS::shared_ptr<IEvent> EventOnAdding() const override; 1078bf80f4bSopenharmony_ci BASE_NS::shared_ptr<IEvent> EventOnRemoving() const override; 1088bf80f4bSopenharmony_ci IterationResult Iterate(const IterationParameters& params) override; 1098bf80f4bSopenharmony_ci IterationResult Iterate(const IterationParameters& params) const override; 1108bf80f4bSopenharmony_ci 1118bf80f4bSopenharmony_ci ObjectId GetClassId() const override 1128bf80f4bSopenharmony_ci { 1138bf80f4bSopenharmony_ci return {}; 1148bf80f4bSopenharmony_ci } 1158bf80f4bSopenharmony_ci BASE_NS::string_view GetClassName() const override 1168bf80f4bSopenharmony_ci { 1178bf80f4bSopenharmony_ci return "MetadataPropertyContainer"; 1188bf80f4bSopenharmony_ci } 1198bf80f4bSopenharmony_ci BASE_NS::string GetName() const override 1208bf80f4bSopenharmony_ci { 1218bf80f4bSopenharmony_ci return ""; 1228bf80f4bSopenharmony_ci } 1238bf80f4bSopenharmony_ci BASE_NS::vector<BASE_NS::Uid> GetInterfaces() const override 1248bf80f4bSopenharmony_ci { 1258bf80f4bSopenharmony_ci return GetInterfacesVector(); 1268bf80f4bSopenharmony_ci } 1278bf80f4bSopenharmony_ci 1288bf80f4bSopenharmony_ciprivate: 1298bf80f4bSopenharmony_ci FlatContainer impl_; 1308bf80f4bSopenharmony_ci mutable BASE_NS::shared_ptr<EventImpl<IOnChildChanged>> onAdded_ { CreateShared<EventImpl<IOnChildChanged>>( 1318bf80f4bSopenharmony_ci "OnAdded") }; 1328bf80f4bSopenharmony_ci mutable BASE_NS::shared_ptr<EventImpl<IOnChildChanged>> onRemoved_ { CreateShared<EventImpl<IOnChildChanged>>( 1338bf80f4bSopenharmony_ci "OnRemoved") }; 1348bf80f4bSopenharmony_ci mutable BASE_NS::shared_ptr<EventImpl<IOnChildMoved>> onMoved_ { CreateShared<EventImpl<IOnChildMoved>>( 1358bf80f4bSopenharmony_ci "OnMoved") }; 1368bf80f4bSopenharmony_ci mutable BASE_NS::shared_ptr<EventImpl<IOnChildChanging>> onAdding_ { CreateShared<EventImpl<IOnChildChanging>>( 1378bf80f4bSopenharmony_ci "OnAdding") }; 1388bf80f4bSopenharmony_ci mutable BASE_NS::shared_ptr<EventImpl<IOnChildChanging>> onRemoving_ { CreateShared<EventImpl<IOnChildChanging>>( 1398bf80f4bSopenharmony_ci "OnRemoving") }; 1408bf80f4bSopenharmony_ci}; 1418bf80f4bSopenharmony_ci 1428bf80f4bSopenharmony_ci} // namespace Internal 1438bf80f4bSopenharmony_ci 1448bf80f4bSopenharmony_ciMETA_END_NAMESPACE() 1458bf80f4bSopenharmony_ci#endif 146