HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields | Static Public Attributes | Friends
v1::observer< T >::_proxy< IsWriting > Class Template Reference

#include <hikogui/observer/observer.hpp>

Public Types

using void_pointer = std::conditional_t<is_writing, void *, void const *>
 
using const_void_pointer = void const *
 
using reference = std::conditional_t<is_writing, value_type&, value_type const&>
 
using const_reference = value_type const&
 
using pointer = std::conditional_t<is_writing, value_type *, value_type const *>
 
using const_pointer = value_type const *
 

Public Member Functions

 ~_proxy () noexcept
 Commits and destruct the proxy object.
 
 _proxy (_proxy const &)=delete
 
_proxyoperator= (_proxy const &)=delete
 
 _proxy (_proxy const &other) noexcept
 
_proxyoperator= (_proxy const &other) noexcept
 
 _proxy (_proxy &&other) noexcept
 
_proxyoperator= (_proxy &&other) noexcept
 
constexpr _proxy () noexcept=default
 Construct an empty proxy object.
 
reference operator* () noexcept
 Dereference the value.
 
const_reference operator* () const noexcept
 Dereference the value.
 
pointer operator-> () noexcept
 Pointer dereference the value.
 
pointer operator& () noexcept
 Pointer dereference the value.
 
const_pointer operator-> () const noexcept
 Pointer dereference the value.
 
void commit () noexcept
 Commit the changes to the value early.
 
void abort () noexcept
 Revert any changes to the value.
 
 X (++) X(--) X(++) X(--) X(+
 
 _proxy (observer const *observer, void_pointer base, pointer value) noexcept
 Create a proxy object.
 
void _commit () noexcept
 
void _abort () noexcept
 

Data Fields

void_pointer _base = nullptr
 
pointer _value = nullptr
 

Static Public Attributes

static constexpr bool is_writing = IsWriting
 

Friends

class observer
 

Detailed Description

template<typename T>
template<bool IsWriting>
class v1::observer< T >::_proxy< IsWriting >

A proxy object of the observer.

The proxy is a RAII object that manages a transaction with the shared-state as a whole, while giving access to only a sub-object of the shared-state.

Template Parameters
IsWritingThe proxy is being used to write

Constructor & Destructor Documentation

◆ ~_proxy()

template<typename T >
template<bool IsWriting>
v1::observer< T >::_proxy< IsWriting >::~_proxy ( )
inlinenoexcept

Commits and destruct the proxy object.

If commit() or abort() are called or the proxy object is empty then the destructor does not commit the changes.

◆ _proxy() [1/2]

template<typename T >
template<bool IsWriting>
constexpr v1::observer< T >::_proxy< IsWriting >::_proxy ( )
constexprdefaultnoexcept

Construct an empty proxy object.

◆ _proxy() [2/2]

template<typename T >
template<bool IsWriting>
v1::observer< T >::_proxy< IsWriting >::_proxy ( observer const * observer,
void_pointer base,
pointer value )
inlinenoexcept

Create a proxy object.

Parameters
observera pointer to the observer.
basea pointer to the dereference rcu-object from the shared_state. This is needed to commit or abort the shared_state as a whole.
valuea pointer to the sub-object of the shared_state that the observer is pointing to.

Member Function Documentation

◆ abort()

template<typename T >
template<bool IsWriting>
void v1::observer< T >::_proxy< IsWriting >::abort ( )
inlinenoexcept

Revert any changes to the value.

Calling this function allows to abort any changes in the value.

Note
It is undefined behavior to change the value after aborting.

◆ commit()

template<typename T >
template<bool IsWriting>
void v1::observer< T >::_proxy< IsWriting >::commit ( )
inlinenoexcept

Commit the changes to the value early.

Calling this function allows to commit earlier than the destructor.

Note
It is undefined behavior to change the value after committing.

◆ operator&()

template<typename T >
template<bool IsWriting>
pointer v1::observer< T >::_proxy< IsWriting >::operator& ( )
inlinenoexcept

Pointer dereference the value.

This function allows reads and modification to the value, including calling member functions on the value.

Note
It is undefined behavior to call this function after calling commit() or abort()

◆ operator*() [1/2]

template<typename T >
template<bool IsWriting>
const_reference v1::observer< T >::_proxy< IsWriting >::operator* ( ) const
inlinenoexcept

Dereference the value.

This function allows reads and modification to the value

Note
It is undefined behavior to call this function after calling commit() or abort()

◆ operator*() [2/2]

template<typename T >
template<bool IsWriting>
reference v1::observer< T >::_proxy< IsWriting >::operator* ( )
inlinenoexcept

Dereference the value.

This function allows reads and modification to the value

Note
It is undefined behavior to call this function after calling commit() or abort()

◆ operator->() [1/2]

template<typename T >
template<bool IsWriting>
const_pointer v1::observer< T >::_proxy< IsWriting >::operator-> ( ) const
inlinenoexcept

Pointer dereference the value.

This function allows reads and modification to the value, including calling member functions on the value.

Note
It is undefined behavior to call this function after calling commit() or abort()

◆ operator->() [2/2]

template<typename T >
template<bool IsWriting>
pointer v1::observer< T >::_proxy< IsWriting >::operator-> ( )
inlinenoexcept

Pointer dereference the value.

This function allows reads and modification to the value, including calling member functions on the value.

Note
It is undefined behavior to call this function after calling commit() or abort()

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