10#include <fmt/ranges.h>
23 return a.
items.as_span() ==
b.items.as_span();
44 if (key != key.
trim()) {
79 remaining = remaining.
substr(sep + 1);
90 return BundlePtr(MEM_new<Bundle>(__func__));
95 items_.add_new_as(key, value);
100 items_.add_new_as(key, std::move(value));
123 this->
add_new(key, std::move(value));
142 if (!child_bundle_ptr || !*child_bundle_ptr) {
147 current = &child_bundle_ptr->ensure_mutable_inplace();
177 if (bundle_ptr && *bundle_ptr) {
178 return bundle_ptr->ensure_mutable_inplace();
183 return new_bundle_ref;
188 return items_.lookup_ptr_as(key);
193 return items_.lookup_ptr_as(key);
204 if (path.
size() == 1) {
229 if (path.
size() == 1) {
233 if (!child_bundle_ptr) {
236 if (!*child_bundle_ptr) {
239 Bundle &child_bundle = child_bundle_ptr->ensure_mutable_inplace();
252 for (
const auto &item : other.items_.
items()) {
253 this->
add(item.key, item.value);
259 for (
const auto &item : other.items_.
items()) {
266 for (
const auto &item : items_.items()) {
267 if (
auto *socket_value = std::get_if<BundleItemSocketValue>(&item.value.value)) {
268 socket_value->value.ensure_owns_direct_data();
275 for (
const auto &item : items_.items()) {
276 if (
const auto *socket_value = std::get_if<BundleItemSocketValue>(&item.value.value)) {
277 if (!socket_value->value.owns_direct_data()) {
289 copy.items_ = items_;
295 return items_.remove_as(key);
316 current = &child_bundle_ptr->ensure_mutable_inplace();
324 return items_.contains_as(key);
339 return fmt::format(
"{}", fmt::join(path,
"/"));
344 return fmt::format(
"{}", fmt::join(path,
"/"));
360 return type ? std::optional<StringRef>(*
type) : std::nullopt;
365 for (
const auto &item : items_.items()) {
366 if (
const auto *socket_value = std::get_if<BundleItemSocketValue>(&item.value.value)) {
367 socket_value->value.count_memory(memory);
375 const bool allow_auto_structure_type)
378 return stored_structure_type;
380 if (allow_auto_structure_type) {
390 items.add({std::move(key), stype});
394 const bool allow_auto_structure_type)
406 signature.
items.add({item.
name, stype, structure_type});
413 const bool allow_auto_structure_type)
425 signature.
items.add({item.
name, stype, structure_type});
434 if (item.is_signature_definition) {
444 for (
const Item &src_signature : this->
items) {
446 if (!signature.
items.add(item)) {
466 for (
const auto &child_item : bundle.
items()) {
467 r_path.
append(child_item.key);
471 if (*child_bundle_ptr) {
472 const Bundle &child_bundle = **child_bundle_ptr;
473 if (!child_bundle.
type().has_value()) {
479 fn(r_path, child_item.value);
498 if (*child_bundle_ptr) {
499 if (
const std::optional<StringRef> type = (*child_bundle_ptr)->type()) {
500 if (type_filter_fn(*type)) {
516 if (
const auto *socket_value = std::get_if<BundleItemSocketValue>(&value.
value)) {
517 if (socket_value->type->type == data_type) {
#define BLI_SCOPED_DEFER(function_to_defer)
T & ensure_mutable_inplace()
constexpr IndexRange()=default
void remove_contained_as(const ForwardKey &key)
Value & lookup_or_add_cb_as(ForwardKey &&key, const CreateValueF &create_value)
const Value & lookup_as(const ForwardKey &key) const
bool add_overwrite_as(ForwardKey &&key, ForwardValue &&...value)
ItemIterator items() const &
constexpr Span drop_front(int64_t n) const
constexpr Span drop_back(int64_t n) const
constexpr int64_t size() const
constexpr const T & last(const int64_t n=0) const
constexpr bool is_empty() const
void append(const T &value)
static SocketValueVariant from(T &&value)
nodes::StructureType inferred_structure_type
constexpr int64_t find_first_of(StringRef chars, int64_t pos=0) const
constexpr StringRef trim() const
static constexpr int64_t not_found
constexpr bool is_empty() const
constexpr StringRef substr(int64_t start, int64_t size) const
static bool is_valid_key(StringRef key)
static constexpr StringRefNull forbidden_key_chars
static std::optional< BundleKey > from_str(StringRef key)
void ensure_owns_direct_data()
void delete_self() override
void add_path_new(StringRef path, const BundleItemValue &value)
static BundleKey type_item_name
void merge_override(const Bundle &other)
T * lookup_ptr(BundleKey key)
void count_memory(MemoryCounter &memory) const
bool add(BundleKey key, const BundleItemValue &value)
static std::string combine_path(Span< StringRef > path)
static bool is_valid_path(StringRef path)
bool contains(BundleKey key) const
bool contains_path(StringRef path) const
static BundlePtr create()
std::optional< StringRef > type() const
BundleItemValue * lookup_path_for_write(Span< BundleKey > path)
void add_override(BundleKey key, const BundleItemValue &value)
void add_path_override(StringRef path, const BundleItemValue &value)
bool remove_path(StringRef path)
bool remove(BundleKey key)
void merge(const Bundle &other)
const BundleItemValue * lookup_path(Span< BundleKey > path) const
bool owns_direct_data() const
const BundleItemValue * lookup(BundleKey key) const
static std::optional< Vector< BundleKey > > split_path(StringRef path)
Bundle & ensure_nested_bundle(StringRef path)
bool add_path(StringRef path, const BundleItemValue &value)
void add_new(BundleKey key, const BundleItemValue &value)
T * lookup_path_for_write_ptr(StringRef path)
BundleItemMap::ItemIterator items() const
#define storage(slot, qualifiers)
bNodeSocketType * node_socket_type_find_static(int type, int subtype=0)
static BundleItemValue create_nested_bundle_item()
NodeSocketInterfaceStructureType get_structure_type_for_bundle_signature(const bNodeSocket &socket, const NodeSocketInterfaceStructureType stored_structure_type, const bool allow_auto_structure_type)
static void foreach_nested_bundle_item_recursive(const Bundle &bundle, const FunctionRef< void(Span< BundleKey >, const BundleItemValue &value)> fn, Vector< BundleKey > &r_path)
Vector< std::string > gather_bundle_paths_by_bundle_type(const Bundle &bundle, const FunctionRef< bool(StringRef type)> type_filter_fn)
Vector< std::string > gather_bundle_paths_by_data_type(const Bundle &bundle, const eNodeSocketDatatype data_type)
void foreach_nested_bundle_item(const Bundle &bundle, const FunctionRef< void(Span< BundleKey >, const BundleItemValue &value)> fn)
ImplicitSharingPtr< Bundle > BundlePtr
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
NodeSocketInterfaceStructureType
NodeSocketInterfaceStructureType structure_type
eNodeSocketDatatype socket_type
eNodeSocketDatatype socket_type
NodeSocketInterfaceStructureType structure_type
bke::bNodeSocketRuntime * runtime
const CPPType * base_cpp_type
bke::SocketValueVariant value
std::variant< BundleItemSocketValue, BundleItemInternalValue > value
std::optional< T > as() const
std::optional< bke::SocketValueVariant > as_socket_value(const bke::bNodeSocketType &dst_socket_type) const
const bke::bNodeSocketType * type
NodeSocketInterfaceStructureType structure_type
void set_auto_structure_types()
static BundleSignature from_separate_bundle_node(const bNode &node, bool allow_auto_structure_type)
CustomIDVectorSet< Item, ItemKeyGetter > items
void add(std::string key, const eNodeSocketDatatype socket_type)
friend bool operator!=(const BundleSignature &a, const BundleSignature &b)
friend bool operator==(const BundleSignature &a, const BundleSignature &b)
static BundleSignature from_combine_bundle_node(const bNode &node, bool allow_auto_structure_type)
bool has_type_definition() const
std::optional< BundleSignature > get_merged_signature() const