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 LOADER_RENDER_DATA_LOADER_H 17 #define LOADER_RENDER_DATA_LOADER_H 18 19 #include <base/containers/string_view.h> 20 #include <core/namespace.h> 21 #include <render/namespace.h> 22 23 CORE_BEGIN_NAMESPACE() 24 class IFileManager; 25 class IDirectory; 26 CORE_END_NAMESPACE() 27 RENDER_BEGIN_NAMESPACE() 28 class IRenderDataStorePod; 29 30 /** RenderDataLoader. 31 * A class that can be used to load all render data configuration from renderdataconfigurations://. 32 */ 33 class RenderDataLoader { 34 public: 35 static constexpr char const* const RENDER_CONFIG_PATH = "renderdataconfigurations://"; 36 static constexpr char const* const POST_PROCESS_PATH = "postprocess"; 37 38 /** Constructor. 39 * @param fileManager File manager to be used when loading files. 40 */ 41 explicit RenderDataLoader(CORE_NS::IFileManager& fileManager); 42 43 ~RenderDataLoader() = default; 44 45 /** Looks for json files under pathPrefix + RENDER_CONFIG_PATH, parses them, and loads the files. */ 46 void Load(BASE_NS::string_view pathPrefix, IRenderDataStorePod& renderDataStorePod); 47 48 private: 49 CORE_NS::IFileManager& fileManager_; 50 51 enum class ConfigurationType : uint8_t { 52 POST_PROCESS = 0, 53 }; 54 55 void RecurseDirectory(BASE_NS::string_view currentPath, const CORE_NS::IDirectory& dir, 56 const ConfigurationType configurationType, IRenderDataStorePod& renderDataStorePod); 57 }; 58 RENDER_END_NAMESPACE() 59 60 #endif // LOADER_RENDER_DATA_LOADER_H 61