Skip to main content

EditorLib::OperationResult

EditorLib::OperationResult

Result payload from an operation. More…

#include <OperationResult.hpp>

Public Functions

Name
OperationResult() =default
Default constructor creates empty result.
template <typename T >
OperationResult(DataChannel channel, T && payload)
Construct with channel and payload.
OperationResult(OperationResult const & ) =default
OperationResult & operator=(OperationResult const & ) =default
OperationResult(OperationResult && ) =default
OperationResult & operator=(OperationResult && ) =default
DataChannel const & channel() const
Get the data channel.
bool hasPayload() const
Check if payload has a value.
bool isValid() const
Check if this result is valid (has channel and payload).
template <typename T >
T
take()
Extract payload as specific type (consuming).
template <typename T >
std::optional< T >
tryTake()
Try to extract payload as specific type.
template <typename T >
T const *
peek() const
Peek at payload without consuming.
template <typename T >
std::optional< T >
get() const
Get a copy of the payload.
template <typename T >
OperationResult
create(DataChannel channel, T && value)
Factory method with explicit channel.

Detailed Description

class EditorLib::OperationResult;

Result payload from an operation.

Copyable container for operation results. Uses std::any internally for type flexibility. The DataChannel indicates what type to expect.

Thread Safety

OperationResult is not thread-safe. All operations should occur on the Qt main thread.

Public Functions Documentation

function OperationResult

OperationResult() =default

Default constructor creates empty result.

function OperationResult

template <typename T >
inline OperationResult(
    DataChannel channel,
    T && payload
)

Construct with channel and payload.

function OperationResult

OperationResult(
    OperationResult const & 
) =default

function operator=

OperationResult & operator=(
    OperationResult const & 
) =default

function OperationResult

OperationResult(
    OperationResult && 
) =default

function operator=

OperationResult & operator=(
    OperationResult && 
) =default

function channel

inline DataChannel const & channel() const

Get the data channel.

function hasPayload

inline bool hasPayload() const

Check if payload has a value.

function isValid

inline bool isValid() const

Check if this result is valid (has channel and payload).

function take

template <typename T >
inline T take()

Extract payload as specific type (consuming).

Exceptions:

Template Parameters:

  • T Expected type

Return: The value

After calling this, the payload is moved out and hasPayload() will return false.

function tryTake

template <typename T >
inline std::optional< T > tryTake()

Try to extract payload as specific type.

Template Parameters:

  • T Expected type

Return: The value if type matches, or nullopt

function peek

template <typename T >
inline T const * peek() const

Peek at payload without consuming.

Template Parameters:

  • T Expected type

Return: Pointer to value if type matches, nullptr otherwise

function get

template <typename T >
inline std::optional< T > get() const

Get a copy of the payload.

Template Parameters:

  • T Expected type

Return: Copy of value if type matches, or nullopt

function create

template <typename T >
static inline OperationResult create(
    DataChannel channel,
    T && value
)

Factory method with explicit channel.


Updated on 2026-11-13 at 20:25:42 +0000