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 API_RENDER_IRENDER_DATA_STORE_POD_H
17 #define API_RENDER_IRENDER_DATA_STORE_POD_H
18
19 #include <cstdint>
20
21 #include <base/containers/array_view.h>
22 #include <base/containers/string.h>
23 #include <base/containers/string_view.h>
24 #include <base/util/uid.h>
25 #include <render/datastore/intf_render_data_store.h>
26 #include <render/namespace.h>
27
RENDER_BEGIN_NAMESPACE()28 RENDER_BEGIN_NAMESPACE()
29 /** @ingroup group_render_irenderdatastorepod */
30 /** RenderDataStorePod interface.
31 * Not internally synchronized.
32 *
33 * This data store is not reset.
34 * Allocated POD memory is released when the store is destroyed.
35 *
36 * Usage:
37 * CreatePodStore() with a unique name and size.
38 * Set() update named data block.
39 * Get() get array_view to named data block.
40 *
41 * Internally synchronized.
42 */
43 class IRenderDataStorePod : public IRenderDataStore {
44 public:
45 static constexpr BASE_NS::Uid UID { "b5dbde59-e733-4640-99e7-cc992840a0bd" };
46
47 /** Create a new pod store with a unique name and initial data.
48 * If pod store with a same name already created. It is updated with new data.
49 * @param typeName A typename for POD data. (e.g. "PostProcess"). This is not the RenderDataStore::TYPE_NAME
50 * @param name A unique name of the POD.
51 * @param data Data to be stored.
52 */
53 virtual void CreatePod(const BASE_NS::string_view typeName, const BASE_NS::string_view name,
54 const BASE_NS::array_view<const uint8_t> data) = 0;
55
56 /** Destroy a specific pod store.
57 * @param typeName A typename for POD data. (e.g. "PostProcess"). This is not the RenderDataStore::TYPE_NAME
58 * @param name A unique name of the POD.
59 */
60 virtual void DestroyPod(const BASE_NS::string_view typeName, const BASE_NS::string_view name) = 0;
61
62 /** Set POD data by unique name.
63 * @param name Name
64 * @param data Data
65 */
66 virtual void Set(const BASE_NS::string_view name, const BASE_NS::array_view<const uint8_t> data) = 0;
67
68 /** Get view to a POD data by unique name. Cast to own types in code.
69 * Do not hold this data. To store this data, copy it somewhere
70 * @param name Name
71 */
72 virtual BASE_NS::array_view<const uint8_t> Get(const BASE_NS::string_view name) const = 0;
73
74 /** Get view to all POD names with given type.
75 * @param typeName A name type name.
76 */
77 virtual BASE_NS::array_view<const BASE_NS::string> GetPodNames(const BASE_NS::string_view typeName) const = 0;
78
79 protected:
80 IRenderDataStorePod() = default;
81 ~IRenderDataStorePod() override = default;
82 };
83 RENDER_END_NAMESPACE()
84
85 #endif // API_RENDER_IRENDER_DATA_STORE_POD_H
86