Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::state::StateTree::ValidatedTransaction Class Reference

A transaction whose edits are checked and return TreeEditResult instead of being silently ignored. More...

#include <state_tree.hpp>

Public Member Functions

 ValidatedTransaction (ValidatedTransaction &&other) noexcept=default
ValidatedTransaction & operator= (ValidatedTransaction &&other) noexcept
 ValidatedTransaction (const ValidatedTransaction &)=delete
ValidatedTransaction & operator= (const ValidatedTransaction &)=delete
 ~ValidatedTransaction ()
TreeEditResult set (StateTree &node, std::string_view name, PropertyValue value)
TreeEditResult remove (StateTree &node, std::string_view name)
TreeEditResult add_child (StateTree &parent, Ptr child)
TreeEditResult insert_child (StateTree &parent, int index, Ptr child)
TreeEditResult remove_child (StateTree &parent, int index)
TreeEditResult move_child (StateTree &from_parent, int from_index, StateTree &to_parent, int to_index)
TreeEditResult commit ()
 Commit when every edit succeeded; otherwise abort and return the first error.
bool abort ()
 Revert every edit and end the transaction. Returns false when inactive.
bool is_active () const
bool has_error () const
const std::optional< TreeEditError > & first_error () const

Friends

class StateTree

Detailed Description

A transaction whose edits are checked and return TreeEditResult instead of being silently ignored.

Every edit must target a node of the tree the transaction was begun on (kNotInTransaction otherwise). A refused edit changes nothing; the first refusal is remembered, and commit() then aborts the whole transaction and returns that error. Destroying an active ValidatedTransaction calls commit().

Move-only. NOT thread-safe — message thread only.

Constructor & Destructor Documentation

◆ ValidatedTransaction() [1/2]

pulp::state::StateTree::ValidatedTransaction::ValidatedTransaction ( ValidatedTransaction && other)
defaultnoexcept

◆ ValidatedTransaction() [2/2]

pulp::state::StateTree::ValidatedTransaction::ValidatedTransaction ( const ValidatedTransaction & )
delete

◆ ~ValidatedTransaction()

pulp::state::StateTree::ValidatedTransaction::~ValidatedTransaction ( )

Member Function Documentation

◆ abort()

bool pulp::state::StateTree::ValidatedTransaction::abort ( )

Revert every edit and end the transaction. Returns false when inactive.

◆ add_child()

TreeEditResult pulp::state::StateTree::ValidatedTransaction::add_child ( StateTree & parent,
Ptr child )

◆ commit()

TreeEditResult pulp::state::StateTree::ValidatedTransaction::commit ( )

Commit when every edit succeeded; otherwise abort and return the first error.

kTransactionClosed when already ended.

◆ first_error()

const std::optional< TreeEditError > & pulp::state::StateTree::ValidatedTransaction::first_error ( ) const
inline

◆ has_error()

bool pulp::state::StateTree::ValidatedTransaction::has_error ( ) const
inline

◆ insert_child()

TreeEditResult pulp::state::StateTree::ValidatedTransaction::insert_child ( StateTree & parent,
int index,
Ptr child )

◆ is_active()

bool pulp::state::StateTree::ValidatedTransaction::is_active ( ) const
inline

◆ move_child()

TreeEditResult pulp::state::StateTree::ValidatedTransaction::move_child ( StateTree & from_parent,
int from_index,
StateTree & to_parent,
int to_index )

◆ operator=() [1/2]

ValidatedTransaction & pulp::state::StateTree::ValidatedTransaction::operator= ( const ValidatedTransaction & )
delete

◆ operator=() [2/2]

ValidatedTransaction & pulp::state::StateTree::ValidatedTransaction::operator= ( ValidatedTransaction && other)
noexcept

◆ remove()

TreeEditResult pulp::state::StateTree::ValidatedTransaction::remove ( StateTree & node,
std::string_view name )

◆ remove_child()

TreeEditResult pulp::state::StateTree::ValidatedTransaction::remove_child ( StateTree & parent,
int index )

◆ set()

TreeEditResult pulp::state::StateTree::ValidatedTransaction::set ( StateTree & node,
std::string_view name,
PropertyValue value )

◆ StateTree

friend class StateTree
friend

The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/state/include/pulp/state/state_tree.hpp