Class loader_t

Nested Relationships

Nested Types

Inheritance Relationships

Derived Type

Class Documentation

class loader_t

Handles queueing and synchronizing the loading of scene element. Generic class: overloads are expected to provide the data source.

Subclassed by wt::scene::loader::xml::xml_loader_t

Public Types

using shared_element_ptr_t = std::shared_ptr<scene::scene_element_t>
using shared_scene_element_task_t = std::shared_future<shared_element_ptr_t>

Public Functions

loader_t(std::string name, const wt_context_t &ctx, std::optional<progress_callback_t> callbacks = {})
inline virtual ~loader_t()
void wait_shapes() const

Block and wait for loading of all shapes to complete.

std::vector<std::shared_ptr<shape_t>> &get_shapes()

Block and retrieve list of all shapes.

inline const auto &get_name() const noexcept
inline bool has_errors() const noexcept

Returns TRUE if errors occurred during loading.

std::unique_ptr<scene_t> get()

Blocks and wait for loader to complete, then constructs the scene. Only thread safe with sensors’, sampler’s and shapes’ waiters and getter. NOT thread safe with wait().

void wait() const

Blocks and wait for loader to complete. Only thread safe with sensors’, sampler’s and shapes’ waiters and getter. NOT thread safe with get().

inline std::optional<const node_t*> get_node_with_id(const std::string &id) const noexcept

Get the node with specified id. Nested nodes are ignored.

template<std::derived_from<scene::scene_element_t> T>
inline std::shared_ptr<T> get_scene_element(const std::string &id)
template<std::invocable F>
inline void enqueue_loading_task(const scene_element_t *resource, const std::string&, F &&func)

Enqueues an arbitrary auxiliary task as part of scene loading. Scene loading will wait for these auxiliary tasks to complete. These tasks are not scheduled on the threadpool to wait deadlocks on waits.

inline void register_resource_dependency(const scene_element_t *resource, const scene_element_t *dependency)

Notifies the loader that resource depends on dependency. When complete_loading_tasks_for_resource() is called on resource, it will also block and wait for any tasks queued by dependency.

inline void complete_loading_tasks_for_resource(const scene_element_t *resource)

Waits and completes all auxiliary deferred loading tasks for a particular resource are done. Blocking operation.

virtual std::string node_description(const node_t &node) const noexcept = 0

Protected Functions

void load(node_t *scene_node, const defaults_defines_t &user_defines)

Enqueues the loading tasks. Subclasses should call this when ready, passing the root node of the scene data. scene_node must remain valid for the lifetime of the loader.

inline void set_fail() noexcept

Marks that loading has failed.

std::optional<shared_scene_element_task_t> get_shared_task(const std::string &id)

Protected Attributes

const wt_context_t &context
const std::string name