Blender  V3.3
BKE_type_conversions.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
5 #include "FN_field.hh"
6 #include "FN_multi_function.hh"
7 
8 namespace blender::bke {
9 
12  void (*convert_single_to_initialized)(const void *src, void *dst);
13  void (*convert_single_to_uninitialized)(const void *src, void *dst);
14 };
15 
17  private:
19 
20  public:
21  void add(fn::MFDataType from_type,
23  const fn::MultiFunction &fn,
24  void (*convert_single_to_initialized)(const void *src, void *dst),
25  void (*convert_single_to_uninitialized)(const void *src, void *dst))
26  {
27  conversions_.add_new({from_type, to_type},
28  {&fn, convert_single_to_initialized, convert_single_to_uninitialized});
29  }
30 
32  {
33  return conversions_.lookup_ptr({from, to});
34  }
35 
37  {
40  }
41 
43  fn::MFDataType to) const
44  {
46  return functions ? functions->multi_function : nullptr;
47  }
48 
49  bool is_convertible(const CPPType &from_type, const CPPType &to_type) const
50  {
51  return conversions_.contains(
53  }
54 
55  void convert_to_uninitialized(const CPPType &from_type,
56  const CPPType &to_type,
57  const void *from_value,
58  void *to_value) const;
59 
60  void convert_to_initialized_n(GSpan from_span, GMutableSpan to_span) const;
61 
62  GVArray try_convert(GVArray varray, const CPPType &to_type) const;
64  fn::GField try_convert(fn::GField field, const CPPType &to_type) const;
65 };
66 
67 const DataTypeConversions &get_implicit_type_conversions();
68 
69 } // namespace blender::bke
long functions
void add_new(const Key &key, const Value &value)
Definition: BLI_map.hh:220
bool contains(const Key &key) const
Definition: BLI_map.hh:308
const Value * lookup_ptr(const Key &key) const
Definition: BLI_map.hh:463
void convert_to_uninitialized(const CPPType &from_type, const CPPType &to_type, const void *from_value, void *to_value) const
const ConversionFunctions * get_conversion_functions(const CPPType &from, const CPPType &to) const
const ConversionFunctions * get_conversion_functions(fn::MFDataType from, fn::MFDataType to) const
void convert_to_initialized_n(GSpan from_span, GMutableSpan to_span) const
void add(fn::MFDataType from_type, fn::MFDataType to_type, const fn::MultiFunction &fn, void(*convert_single_to_initialized)(const void *src, void *dst), void(*convert_single_to_uninitialized)(const void *src, void *dst))
bool is_convertible(const CPPType &from_type, const CPPType &to_type) const
const fn::MultiFunction * get_conversion_multi_function(fn::MFDataType from, fn::MFDataType to) const
GVArray try_convert(GVArray varray, const CPPType &to_type) const
StackEntry * from
SyclQueue void void * src
SyclQueue void void size_t num_bytes void
const DataTypeConversions & get_implicit_type_conversions()
static Type to_type(const eGPUType type)
const fn::MultiFunction * multi_function
void(* convert_single_to_uninitialized)(const void *src, void *dst)
void(* convert_single_to_initialized)(const void *src, void *dst)