Blender
V2.93
source
blender
functions
FN_multi_function_context.hh
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or
3
* modify it under the terms of the GNU General Public License
4
* as published by the Free Software Foundation; either version 2
5
* of the License, or (at your option) any later version.
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software Foundation,
14
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
*/
16
17
#pragma once
18
29
#include "
BLI_utildefines.h
"
30
31
#include "
BLI_map.hh
"
32
33
namespace
blender::fn
{
34
35
class
MFContext;
36
37
class
MFContextBuilder
{
38
private
:
39
Map<std::string, const void *>
global_contexts_;
40
41
friend
MFContext
;
42
43
public
:
44
template
<
typename
T>
void
add_global_context
(std::string name,
const
T
*
context
)
45
{
46
global_contexts_.
add_new
(std::move(name),
static_cast<
const
void
*
>
(
context
));
47
}
48
};
49
50
class
MFContext
{
51
private
:
52
MFContextBuilder
&builder_;
53
54
public
:
55
MFContext
(
MFContextBuilder
&builder) : builder_(builder)
56
{
57
}
58
59
template
<
typename
T>
const
T
*
get_global_context
(
StringRef
name)
const
60
{
61
const
void
*
context
= builder_.global_contexts_.
lookup_default_as
(name,
nullptr
);
62
/* TODO: Implement type checking. */
63
return
static_cast<
const
T
*
>
(
context
);
64
}
65
};
66
67
}
// namespace blender::fn
BLI_map.hh
BLI_utildefines.h
blender::Map< std::string, const void * >
blender::Map::add_new
void add_new(const Key &key, const Value &value)
Definition:
BLI_map.hh:234
blender::Map::lookup_default_as
Value lookup_default_as(const ForwardKey &key, ForwardValue &&default_value) const
Definition:
BLI_map.hh:529
blender::StringRef
Definition:
BLI_string_ref.hh:275
blender::fn::MFContextBuilder
Definition:
FN_multi_function_context.hh:37
blender::fn::MFContextBuilder::add_global_context
void add_global_context(std::string name, const T *context)
Definition:
FN_multi_function_context.hh:44
blender::fn::MFContext
Definition:
FN_multi_function_context.hh:50
blender::fn::MFContext::MFContext
MFContext(MFContextBuilder &builder)
Definition:
FN_multi_function_context.hh:55
blender::fn::MFContext::get_global_context
const T * get_global_context(StringRef name) const
Definition:
FN_multi_function_context.hh:59
T
#define T
Definition:
mball_tessellate.c:278
blender::fn
Definition:
FN_cpp_type.hh:74
context
struct SELECTID_Context context
Definition:
select_engine.c:47
Generated on Tue Jan 31 2023 14:37:24 for Blender by
doxygen
1.9.1