Welcome to mirror list, hosted at ThFree Co, Russian Federation.

field_cpp_type.cc « intern « functions « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9057bbb887acb8ea897f5d268b7730fcc898f066 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include "FN_field_cpp_type.hh"

namespace blender::fn {

static auto &get_from_self_map()
{
  static Map<const CPPType *, const ValueOrFieldCPPType *> map;
  return map;
}

static auto &get_from_value_map()
{
  static Map<const CPPType *, const ValueOrFieldCPPType *> map;
  return map;
}

void ValueOrFieldCPPType::register_self()
{
  get_from_value_map().add_new(&this->value, this);
  get_from_self_map().add_new(&this->self, this);
}

const ValueOrFieldCPPType *ValueOrFieldCPPType::get_from_self(const CPPType &self)
{
  const ValueOrFieldCPPType *type = get_from_self_map().lookup_default(&self, nullptr);
  BLI_assert(type == nullptr || type->self == self);
  return type;
}

const ValueOrFieldCPPType *ValueOrFieldCPPType::get_from_value(const CPPType &value)
{
  const ValueOrFieldCPPType *type = get_from_value_map().lookup_default(&value, nullptr);
  BLI_assert(type == nullptr || type->value == value);
  return type;
}

}  // namespace blender::fn