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_SRC_MODEL_OBJECT_PROVIDER_BASE_H 17 #define META_SRC_MODEL_OBJECT_PROVIDER_BASE_H 18 19 #include <meta/interface/model/intf_object_provider.h> 20 21 #include "../object.h" 22 23 META_BEGIN_NAMESPACE() 24 25 META_REGISTER_CLASS(ObjectProviderBase, "13656d27-e228-4fd7-a4ce-5bb051cdaafc", ObjectCategory::NO_CATEGORY); 26 27 class ObjectProviderBase 28 : public Internal::ObjectFwd<ObjectProviderBase, ClassId::ObjectProviderBase, IModelObjectProvider> { 29 public: 30 ~ObjectProviderBase() override; 31 META_NO_COPY_MOVE(ObjectProviderBase) 32 33 ObjectProviderBase() = default; 34 35 IObject::Ptr CreateObject(const DataModelIndex& index) override; 36 bool DisposeObject(const META_NS::IObject::Ptr& item) override; 37 size_t GetObjectCount(const DataModelIndex& index) const override; 38 39 META_IMPLEMENT_INTERFACE_EVENT(IObjectProvider, IOnDataAdded, OnDataAdded) 40 META_IMPLEMENT_INTERFACE_EVENT(IObjectProvider, IOnDataRemoved, OnDataRemoved) 41 META_IMPLEMENT_INTERFACE_EVENT(IObjectProvider, IOnDataMoved, OnDataMoved) 42 43 META_IMPLEMENT_INTERFACE_PROPERTY(IObjectProvider, size_t, CacheHint, 10); 44 45 bool SetDataModel(const IDataModel::Ptr& model) override; 46 IDataModel::Ptr GetDataModel() const override; 47 48 protected: 49 virtual IObject::Ptr Construct(const IMetadata::Ptr& data); 50 51 private: 52 void BindProperties(const IObject::Ptr& object, const IMetadata::Ptr& data) const; 53 54 private: 55 IDataModel::Ptr model_; 56 BASE_NS::vector<IObject::Ptr> recyclebin_; 57 }; 58 59 META_END_NAMESPACE() 60 61 #endif 62