Blender V5.3
multi_function_registry.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
12
13#include "CLG_log.h"
14
15static CLG_LogRef LOG = {"functions.mf_registry"};
16
18
20
24
26{
27 static Registry registry;
28 return registry;
29}
30
32{
35 const UString id = UString(fn.name());
36 if (registry.map.add(accessor, id)) {
37 accessor->second = &fn;
38 }
39 else {
40 /* A function can only be registered once. */
41 CLOG_ERROR(&LOG, "Multi-function already registered: '%s'", id.c_str());
43 }
44}
45
47{
50 if (registry.map.lookup(accessor, id)) {
51 return *accessor->second;
52 }
53 /* The function is expected to exist when using the #lookup function. */
54 CLOG_ERROR(&LOG, "Multi-function does not exist: '%s'", id.c_str());
56 return *accessor->second;
57}
58
59} // namespace blender::fn::multi_function::registry
#define CLOG_ERROR(clg_ref,...)
Definition CLG_log.h:188
#define BLI_assert_unreachable()
UString()=default
#define LOG(level)
Definition log.h:97
ConcurrentMap< UString, const MultiFunction * > RegistryMap
const MultiFunction & lookup(UString id)