You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.0 KiB

11 months ago
#pragma once
#include <data/data_center.hpp>
namespace internal
{
11 months ago
enum class eNodeOperation : uint32_t { unionOp = 0, intersectionOp = 1, differenceOp = 2, unsetOp = 3 };
struct runtime_node_t {
marked_ptr<primitive, 2> node_data{};
11 months ago
pointer_wrapper<runtime_node_t> parent{};
pointer_wrapper<runtime_node_t> left_child{};
pointer_wrapper<runtime_node_t> right_child{};
11 months ago
~runtime_node_t() noexcept;
11 months ago
bool is_operation_node() const noexcept;
bool is_primitive_node() const noexcept;
bool is_parent_null() const noexcept;
bool is_left_child_null() const noexcept;
bool is_right_child_null() const noexcept;
11 months ago
bool set_parent(pointer_wrapper<runtime_node_t> parent) noexcept;
bool remove_parent();
bool set_left_child(pointer_wrapper<runtime_node_t> child) noexcept;
bool set_right_child(pointer_wrapper<runtime_node_t> child) noexcept;
bool add_child(pointer_wrapper<runtime_node_t> child) noexcept;
bool remove_child(pointer_wrapper<runtime_node_t> child);
11 months ago
};
// ======================================================================
// Node
// ======================================================================
11 months ago
struct BS_API node_t {
uint32_t operation : 2; // 0 for union, 1 for intersection, 2 for difference, 3 for unset
uint32_t type : 6; // [0, 62] for primitive type, 63 for invalid/operation node
uint32_t primitive_index : 24;
uint32_t parent_index; // 0xFFFFFFFF for null
uint32_t left_child_index; // 0xFFFFFFFF for null
uint32_t right_child_index; // 0xFFFFFFFF for null
node_t() noexcept;
eNodeOperation get_operation() const noexcept;
void set_operation(eNodeOperation op) noexcept;
bool is_primitive_node() const noexcept;
bool is_operation_node() const noexcept;
bool is_parent_null() const noexcept;
bool is_left_child_null() const noexcept;
bool is_right_child_null() const noexcept;
11 months ago
};
} // namespace internal