Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/resource/BuiltinLoader.h

raw
1 /*
2 * Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2024 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 15 мар. 2021 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_RESOURCE_BUILTINLOADER_H_
23 #define LSP_PLUG_IN_RESOURCE_BUILTINLOADER_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26 #include <lsp-plug.in/common/types.h>
27 #include <lsp-plug.in/runtime/LSPString.h>
28 #include <lsp-plug.in/io/Path.h>
29
30 #include <lsp-plug.in/resource/types.h>
31 #include <lsp-plug.in/resource/ILoader.h>
32
33 namespace lsp
34 {
35 namespace resource
36 {
37 /**
38 * Loader for built-in resources
39 */
40 class BuiltinLoader: public ILoader
41 {
42 protected:
43 const uint8_t *pData; // Compressed data
44 size_t nDataSize; // Data size
45 const raw_resource_t *pCatalog; // Catalog
46 size_t nCatSize; // Catalog size
47 size_t nBufRank; // Size of compression buffer
48
49 protected:
50 status_t find_entry(ssize_t *out, const io::Path *path);
51
52 public:
53 explicit BuiltinLoader();
54 BuiltinLoader(const BuiltinLoader &) = delete;
55 BuiltinLoader(BuiltinLoader &&) = delete;
56 virtual ~BuiltinLoader() override;
57
58 BuiltinLoader & operator = (const BuiltinLoader & ) = delete;
59 BuiltinLoader & operator = (BuiltinLoader && ) = delete;
60
61 public:
62 /**
63 * Initialize builtin loader
64 *
65 * @param data compression data
66 * @param data_size size of compression data
67 * @param catalog catalog with entries
68 * @param catalog_size size of catalog
69 * @param log_buf_size size of compression buffer (the exponent of power-of-two value)
70 * @return status of operation
71 */
72 status_t init(
73 const void *data, size_t data_size,
74 const raw_resource_t *catalog, size_t catalog_size,
75 size_t log_buf_size);
76
77 public:
78 virtual io::IInStream *read_stream(const io::Path *name) override;
79
80 virtual ssize_t enumerate(const io::Path *path, resource_t **list) override;
81 };
82 } /* namespace resource */
83 } /* namespace lsp */
84
85 #endif /* LSP_PLUG_IN_RESOURCE_BUILTINLOADER_H_ */