| 1 |
/* |
| 2 |
* Copyright (C) 2026 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2026 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-runtime-lib |
| 6 |
* Created on: 25 янв. 2026 г. |
| 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_MM_ICOLORMAP_H_ |
| 23 |
#define LSP_PLUG_IN_MM_ICOLORMAP_H_ |
| 24 |
|
| 25 |
#include <lsp-plug.in/runtime/version.h> |
| 26 |
|
| 27 |
#include <lsp-plug.in/lltl/parray.h> |
| 28 |
#include <lsp-plug.in/runtime/Color.h> |
| 29 |
#include <lsp-plug.in/runtime/LSPString.h> |
| 30 |
|
| 31 |
namespace lsp |
| 32 |
{ |
| 33 |
namespace mm |
| 34 |
{ |
| 35 |
/** |
| 36 |
* Color map class for unmapping colors from symbolic names. |
| 37 |
*/ |
| 38 |
class IColorMap |
| 39 |
{ |
| 40 |
private: |
| 41 |
lltl::parray<IColorMap> vNested; |
| 42 |
|
| 43 |
public: |
| 44 |
IColorMap(); |
| 45 |
virtual ~IColorMap(); |
| 46 |
|
| 47 |
public: |
| 48 |
/** |
| 49 |
* Resolve color |
| 50 |
* @param c reference to color to store value |
| 51 |
* @param name color name |
| 52 |
* @return true if color has been resolved |
| 53 |
*/ |
| 54 |
virtual bool resolve(Color & c, const char *name) const noexcept; |
| 55 |
|
| 56 |
/** |
| 57 |
* Resolve color |
| 58 |
* @param c reference to color to store value |
| 59 |
* @param name color name |
| 60 |
* @return true if color has been resolved |
| 61 |
*/ |
| 62 |
virtual bool resolve(Color & c, const LSPString & name) const noexcept; |
| 63 |
|
| 64 |
public: |
| 65 |
/** |
| 66 |
* Link nested color map. If this color map does not contain color, |
| 67 |
* the added color maps will be polled in order of linkage. |
| 68 |
* |
| 69 |
* @param map pointer to color map to link |
| 70 |
* @return true if color map was linked |
| 71 |
*/ |
| 72 |
inline bool link(IColorMap *map) { return vNested.add(map); } |
| 73 |
|
| 74 |
/** |
| 75 |
* Resolve color |
| 76 |
* @param pointer to color to store value |
| 77 |
* @param name color name |
| 78 |
* @return true if color has been resolved |
| 79 |
*/ |
| 80 |
inline bool resolve(Color *c, const char *name) const noexcept { return (c != NULL) ? resolve(*c, name) : false; } |
| 81 |
|
| 82 |
/** |
| 83 |
* Resolve color |
| 84 |
* @param pointer to color to store value |
| 85 |
* @param name color name |
| 86 |
* @return true if color has been resolved |
| 87 |
*/ |
| 88 |
inline bool resolve(Color *c, const LSPString *name) const noexcept { return ((c != NULL) && (name != NULL)) ? resolve(*c, *name) : false; } |
| 89 |
|
| 90 |
/** |
| 91 |
* Resolve color |
| 92 |
* @param pointer to color to store value |
| 93 |
* @param name color name |
| 94 |
* @return true if color has been resolved |
| 95 |
*/ |
| 96 |
inline bool resolve(Color *c, const LSPString & name) const noexcept { return (c != NULL) ? resolve(*c, name) : false; } |
| 97 |
|
| 98 |
/** |
| 99 |
* Resolve color |
| 100 |
* @param pointer to color to store value |
| 101 |
* @param name color name |
| 102 |
* @return true if color has been resolved |
| 103 |
*/ |
| 104 |
inline bool resolve(Color & c, const LSPString *name) const noexcept { return (name != NULL) ? resolve(c, *name) : false; } |
| 105 |
}; |
| 106 |
|
| 107 |
} /* namespace mm */ |
| 108 |
} /* namespace lsp */ |
| 109 |
|
| 110 |
#endif /* LSP_PLUG_IN_MM_ICOLORMAP_H_ */ |