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_LOADER_IRENDER_DATA_CONFIGURATION_LOADER_H
17 #define API_RENDER_LOADER_IRENDER_DATA_CONFIGURATION_LOADER_H
18 
19 #include <base/containers/string.h>
20 #include <base/containers/string_view.h>
21 #include <core/namespace.h>
22 #include <core/plugin/intf_interface.h>
23 #include <render/datastore/render_data_store_render_pods.h>
24 #include <render/namespace.h>
25 
26 CORE_BEGIN_NAMESPACE()
27 class IFileManager;
28 CORE_END_NAMESPACE()
RENDER_BEGIN_NAMESPACE()29 RENDER_BEGIN_NAMESPACE()
30 /**
31  * Render data configuration loader.
32  * A class that can be used to load vertex input declaration from json structure.
33  */
34 class IRenderDataConfigurationLoader : public CORE_NS::IInterface {
35 public:
36     static constexpr BASE_NS::Uid UID { "dca91e7e-1b03-47a8-a09e-2dbd99acaa9d" };
37 
38     /** Describes result of the parsing operation. */
39     struct LoadResult {
40         LoadResult() = default;
41         explicit LoadResult(BASE_NS::string_view error) : success(false), error(error) {}
42 
43         /** Indicates, whether the parsing operation is successful. */
44         bool success { true };
45 
46         /** In case of parsing error, contains the description of the error. */
47         BASE_NS::string error;
48     };
49 
50     struct LoadedPostProcess {
51         LoadResult loadResult;
52 
53         PostProcessConfiguration postProcessConfiguration;
54         BASE_NS::string name;
55     };
56 
57     /** Load PostProcessConfiguration.
58      * @return A post process configuration, as defined in the json file.
59      */
60     virtual LoadedPostProcess LoadPostProcess(BASE_NS::string_view jsonString) = 0;
61     virtual LoadedPostProcess LoadPostProcess(CORE_NS::IFileManager& fileManager, BASE_NS::string_view uri) = 0;
62 
63 protected:
64     IRenderDataConfigurationLoader() = default;
65     virtual ~IRenderDataConfigurationLoader() = default;
66 };
67 
GetName(const IRenderDataConfigurationLoader *)68 inline constexpr BASE_NS::string_view GetName(const IRenderDataConfigurationLoader*)
69 {
70     return "IRenderDataConfigurationLoader";
71 }
72 RENDER_END_NAMESPACE()
73 
74 #endif // LOADER_RENDER_DATA_CONFIGURATION_LOADER_H
75