EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Loading...
Searching...
No Matches
echomap::LoadProjectTask Class Reference

Denotes a unit of work for loading and constructing an EchoMap Project from its serialised form on the filesystem. More...

#include <LoadProjectTask.hpp>

Inheritance diagram for echomap::LoadProjectTask:
[legend]

Public Member Functions

 LoadProjectTask (std::filesystem::path path, Worker *worker)
 Create a new LoadProjectTask for a serialised Project.
Public Member Functions inherited from echomap::ITask
 ITask (const std::string_view task_name)
virtual ~ITask () noexcept=default
 Destruct the ITask base.
WorkerResult execute (const std::stop_token &stop_token)
 Execute the work, subject to the given token, and produce a WorkerResult.
WorkerResult operator() ()
 Alias for execute with a vacuous stop token.
Public Member Functions inherited from echomap::Object< ITask >
 ~Object ()=default
 Non-virtual base destructor.
id_type get_id () const noexcept
bool is_valid () const noexcept
void set_name (const std::string_view new_name)
std::string_view get_name () const noexcept
const char * get_imgui_name () const noexcept
 Object (const Object &)=delete
Object & operator= (const Object &)=delete
bool operator== (const Object &other) const noexcept
 Determine shallow equality between two Object instances.

Private Member Functions

WorkerResult execute_work () override
 Loads, deserialises, constructs, and validates the serialised Project file at the provided path.

Private Attributes

std::filesystem::path project_file_path
 The deserialiser takes just strings for paths, so we "downgrade" the typed path to a string.
Workerworker

Static Private Attributes

static JSONDeserialiser deserialiser {}
 Shared instance of the deserialiser.

Additional Inherited Members

Static Public Member Functions inherited from echomap::Object< ITask >
static std::string_view get_class_name () noexcept
Protected Member Functions inherited from echomap::Object< ITask >
void move_identity_from (Object &&other) noexcept
 Helper for derived classes to provide move-assignment operations.

Detailed Description

Denotes a unit of work for loading and constructing an EchoMap Project from its serialised form on the filesystem.

Warning
The LoadProjectTask is not thread-safe due to persisting global state of the parser for re-use across Project loads. It should be called only a single thread.
See also
JSONDeserialiser::deserialise_project(std::string_view)

Definition at line 27 of file LoadProjectTask.hpp.

Constructor & Destructor Documentation

◆ LoadProjectTask()

echomap::LoadProjectTask::LoadProjectTask ( std::filesystem::path path,
Worker * worker )
explicit

Create a new LoadProjectTask for a serialised Project.

Parameters
pathThe path of the serialised Project file.
workerA thread-safe Worker capable of accepting sub-work requests.

Definition at line 23 of file LoadProjectTask.cpp.

26 :
27 ITask(std::format("LoadProjectTask: {}", path.c_str())),
28 project_file_path(std::move(path)),
29 worker(worker)
30{
31}
std::filesystem::path project_file_path
The deserialiser takes just strings for paths, so we "downgrade" the typed path to a string.
T format(T... args)

Member Function Documentation

◆ execute_work()

WorkerResult echomap::LoadProjectTask::execute_work ( )
overrideprivatevirtual

Loads, deserialises, constructs, and validates the serialised Project file at the provided path.

Returns
A LoadProjectResult detaining the loaded Project.
Exceptions
std::runtime_errorIf the Project could not be fully loaded and validated.
See also
JSONDeserialiser::deserialise_project

Implements echomap::ITask.

Definition at line 33 of file LoadProjectTask.cpp.

34{
35 return LoadProjectResult(deserialiser.deserialise_project(project_file_path, worker));
36}
static JSONDeserialiser deserialiser
Shared instance of the deserialiser.

Member Data Documentation

◆ deserialiser

JSONDeserialiser echomap::LoadProjectTask::deserialiser {}
staticprivate

Shared instance of the deserialiser.

It is useful to persist the deserialiser object across numerous Project loads, since we may re-use the parser. See https://github.com/simdjson/simdjson/blob/b485fb2af4862176f291a6fc9d2cb1cfd05631ac/doc/performance.md#reusing-the-parser-for-maximum-efficiency. This comes at the small cost of making the LoadProjectTask not thread safe, as noted in the API docs.

Definition at line 60 of file LoadProjectTask.hpp.

◆ project_file_path

std::filesystem::path echomap::LoadProjectTask::project_file_path
private

The deserialiser takes just strings for paths, so we "downgrade" the typed path to a string.

Definition at line 65 of file LoadProjectTask.hpp.

◆ worker

Worker* echomap::LoadProjectTask::worker
private

Definition at line 67 of file LoadProjectTask.hpp.


The documentation for this class was generated from the following files: