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

An ITask represents an invocable piece of work that produces a WorkerResult. More...

#include <ITask.hpp>

Inheritance diagram for echomap::ITask:
[legend]

Public Member Functions

 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

virtual WorkerResult execute_work ()=0
 Execute the work and produce a WorkerResult.

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

An ITask represents an invocable piece of work that produces a WorkerResult.

Definition at line 22 of file ITask.hpp.

Constructor & Destructor Documentation

◆ ITask()

echomap::ITask::ITask ( const std::string_view task_name)
inlineexplicit

Definition at line 25 of file ITask.hpp.

27 :
28 Object(task_name)
29 {
30 }

Member Function Documentation

◆ execute()

WorkerResult echomap::ITask::execute ( const std::stop_token & stop_token)

Execute the work, subject to the given token, and produce a WorkerResult.

Parameters
stop_tokenToken for cancelling execution.
Returns
An owning container detaining the result of the work, or nullptr if the cancelled.

Definition at line 18 of file ITask.cpp.

18 {
19 if (stop_token.stop_requested())
20 throw std::runtime_error("Stop requested");
21
22 return execute_work();
23}
virtual WorkerResult execute_work()=0
Execute the work and produce a WorkerResult.
T stop_requested(T... args)

◆ execute_work()

virtual WorkerResult echomap::ITask::execute_work ( )
privatepure virtual

Execute the work and produce a WorkerResult.

Returns
An owning container detaining the result of the work.

Implemented in echomap::DFTTask, echomap::DownsampleTask, echomap::LoadProjectTask, and echomap::LoadSignalFileTask.

◆ operator()()

WorkerResult echomap::ITask::operator() ( )

Alias for execute with a vacuous stop token.

Returns
An owning container detaining the result of the work.

Definition at line 25 of file ITask.cpp.

26{
27 return execute({});
28}
WorkerResult execute(const std::stop_token &stop_token)
Execute the work, subject to the given token, and produce a WorkerResult.
Definition ITask.cpp:18

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