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