1 /* 2 * Copyright (C) 2023 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 API_RENDER_IRENDER_DATA_STORE_MANAGER_H 17 #define API_RENDER_IRENDER_DATA_STORE_MANAGER_H 18 19 #include <base/containers/string_view.h> 20 #include <render/namespace.h> 21 22 BASE_BEGIN_NAMESPACE() 23 struct Uid; 24 BASE_END_NAMESPACE() 25 26 RENDER_BEGIN_NAMESPACE() 27 class IRenderDataStore; 28 /** @ingroup group_render_irenderdatastoremanager */ 29 /** IRenderDataStoreManager interface. 30 * Interface class to hold all render data stores. 31 32 * Internally synchronized 33 */ 34 class IRenderDataStoreManager { 35 public: 36 IRenderDataStoreManager(const IRenderDataStoreManager&) = delete; 37 IRenderDataStoreManager& operator=(const IRenderDataStoreManager&) = delete; 38 39 /** Get a previously created render data store 40 * Uses lock, prefer fetching once if you're certain that the data store won't be destroyed 41 * @param name Name of the render data store instance 42 * @return Pointer to the instance or nullptr if instance doesn't exist. 43 */ 44 virtual IRenderDataStore* GetRenderDataStore(const BASE_NS::string_view name) const = 0; 45 46 /** Creates a new render data store. 47 * @param dataStoreTypeUid Type UID of the render data store instance 48 * @param dataStoreName Name of the render data store instance 49 * @return Pointer to a new instance or nullptr if creation failed. 50 */ 51 virtual IRenderDataStore* Create(const BASE_NS::Uid& dataStoreTypeUid, char const* dataStoreName) = 0; 52 53 /** Destroys a render data store. 54 * @param dataStoreeUid Type UID of the render data store instance 55 * @param instance Instance to destroy 56 */ 57 virtual void Destroy(const BASE_NS::Uid& dataStoreTypeUid, IRenderDataStore* instance) = 0; 58 59 protected: 60 IRenderDataStoreManager() = default; 61 virtual ~IRenderDataStoreManager() = default; 62 }; 63 64 /** IRenderNodeRenderDataStoreManager interface. 65 * Interface class to access all render data stores. 66 67 * Safe usage without locking in render nodes. 68 */ 69 class IRenderNodeRenderDataStoreManager { 70 public: 71 IRenderNodeRenderDataStoreManager(const IRenderNodeRenderDataStoreManager&) = delete; 72 IRenderNodeRenderDataStoreManager& operator=(const IRenderNodeRenderDataStoreManager&) = delete; 73 74 /** Get a previously created render data store 75 * @param name Name of the render data store instance 76 * @return Pointer to the instance or nullptr if instance doesn't exist. 77 */ 78 virtual IRenderDataStore* GetRenderDataStore(const BASE_NS::string_view name) const = 0; 79 80 protected: 81 IRenderNodeRenderDataStoreManager() = default; 82 virtual ~IRenderNodeRenderDataStoreManager() = default; 83 }; 84 RENDER_END_NAMESPACE() 85 86 #endif // API_RENDER_IRENDER_DATA_STORE_MANAGER_H 87