dxd - dynax driver framework 3.0.1d223
cross platform open source driver development framework
Loading...
Searching...
No Matches
dx::promoted< _value_t > Class Template Reference

promoted value More...

#include <dx_value.h>

Inheritance diagram for dx::promoted< _value_t >:
Collaboration diagram for dx::promoted< _value_t >:

Classes

class  chain
 a server that keeps the one it replaces: a derived class prepends its own step (the device's request to the hardware) and hands the rest to the server its base installed More...
class  preference

Public Types

typedef std::unique_lock< mutex_t > lock_t
typedef std::mutex mutex_t
typedef _value_t value_t

Public Member Functions

void commit (lock_t &&lock, const value_t &value)
 the server's answer: the value stands, the transition ends and the listeners are told - outside the lock, so a listener may read the promoted back
 operator const value_t & ()
promoted & operator++ () noexcept
value_t operator++ (int) noexcept
promoted & operator+= (const value_t &value) noexcept
promoted & operator-- () noexcept
value_t operator-- (int) noexcept
promoted & operator-= (const value_t &value) noexcept
const value_t & operator-> ()
promoted & operator= (const value_t &value)
promoted & operator= (promoted &promoted) noexcept
bool operator== (const value_t &value)
bool operator== (promoted &promoted) noexcept
 promoted ()=delete
 a value stands either behind a server, asked on the first access, or on a value given at construction: neither is no promoted
 promoted (const value_t &value)
 promoted (const value_t &value, decltype(listen)::listeners &&listeners)
 promoted (decltype(server)&&server)
 promoted (decltype(server)&&server, decltype(listen)::listeners &&listeners)

Public Attributes

bool initialized {}
listen< std::function< void(const value_t &)> > listen
std::function< void(lock_t &&, const value_t &, const value_t &)> server {}
 \ indicate the value is in transition - does not have the new value yet
bool transient {}
 \ indicate the value has been initialized

Protected Attributes

value_t value {}

Detailed Description

template<typename _value_t>
class dx::promoted< _value_t >

promoted value

This works like any value_t except that interested parties can subscribe to get notified about changes. If a server has been given assigning a value forwards it to the server and expects the value to be commit()ed back, then all parties are notified. It features caching but ensures that always the actual server value are returned, if the server behaves correctly and promotes all value changes via commit() on its own. If the value has not been initialized the promoted value makes sure to request it from the server. A promoted is never born empty: it is constructed with a server, asked on the first access, or with a value - there is no default constructor, so a value that could be asked without either does not compile (dxd/CLAUDE.md, "A promoted with a server asks it first"). The listener need to make sure to unsubscribe when deleted.

usage: dx::promoted<value_t> promoted_value{server}; // or {value} promoted_value= new value assignment; current value= promoted_value;

using value_t= decltype(promoted<value_t>::value); using server_t= decltype(promoted<value_t>::server); using listen_t= decltype(promoted<value_t>::listen::value_t);

promoted_value.listen[id]= std::function<void(const value_t&)>; promoted_value.server(server);

The server needs to take ownership of the unique_lock and has to make sure to callback commit() and unlock the lock.

Member Typedef Documentation

◆ lock_t

template<typename _value_t>
typedef std::unique_lock<mutex_t> dx::promoted< _value_t >::lock_t

◆ mutex_t

template<typename _value_t>
typedef std::mutex dx::promoted< _value_t >::mutex_t

◆ value_t

template<typename _value_t>
typedef _value_t dx::promoted< _value_t >::value_t

Constructor & Destructor Documentation

◆ promoted() [1/5]

template<typename _value_t>
dx::promoted< _value_t >::promoted ( decltype(server)&& server)
inline
Here is the caller graph for this function:

◆ promoted() [2/5]

template<typename _value_t>
dx::promoted< _value_t >::promoted ( decltype(server)&& server,
decltype(listen)::listeners && listeners )
inline

◆ promoted() [3/5]

template<typename _value_t>
dx::promoted< _value_t >::promoted ( )
delete

a value stands either behind a server, asked on the first access, or on a value given at construction: neither is no promoted

◆ promoted() [4/5]

template<typename _value_t>
dx::promoted< _value_t >::promoted ( const value_t & value)
inline

◆ promoted() [5/5]

template<typename _value_t>
dx::promoted< _value_t >::promoted ( const value_t & value,
decltype(listen)::listeners && listeners )
inline

Member Function Documentation

◆ commit()

template<typename _value_t>
void dx::promoted< _value_t >::commit ( lock_t && lock,
const value_t & value )
inline

the server's answer: the value stands, the transition ends and the listeners are told - outside the lock, so a listener may read the promoted back

Here is the caller graph for this function:

◆ operator const value_t &()

template<typename _value_t>
dx::promoted< _value_t >::operator const value_t & ( )
inline

◆ operator++() [1/2]

template<typename _value_t>
promoted & dx::promoted< _value_t >::operator++ ( )
inlinenoexcept

◆ operator++() [2/2]

template<typename _value_t>
value_t dx::promoted< _value_t >::operator++ ( int )
inlinenoexcept

◆ operator+=()

template<typename _value_t>
promoted & dx::promoted< _value_t >::operator+= ( const value_t & value)
inlinenoexcept

◆ operator--() [1/2]

template<typename _value_t>
promoted & dx::promoted< _value_t >::operator-- ( )
inlinenoexcept

◆ operator--() [2/2]

template<typename _value_t>
value_t dx::promoted< _value_t >::operator-- ( int )
inlinenoexcept

◆ operator-=()

template<typename _value_t>
promoted & dx::promoted< _value_t >::operator-= ( const value_t & value)
inlinenoexcept

◆ operator->()

template<typename _value_t>
const value_t & dx::promoted< _value_t >::operator-> ( )
inline

◆ operator=() [1/2]

template<typename _value_t>
promoted & dx::promoted< _value_t >::operator= ( const value_t & value)
inline
Here is the caller graph for this function:

◆ operator=() [2/2]

template<typename _value_t>
promoted & dx::promoted< _value_t >::operator= ( promoted< _value_t > & promoted)
inlinenoexcept

◆ operator==() [1/2]

template<typename _value_t>
bool dx::promoted< _value_t >::operator== ( const value_t & value)
inline
Here is the caller graph for this function:

◆ operator==() [2/2]

template<typename _value_t>
bool dx::promoted< _value_t >::operator== ( promoted< _value_t > & promoted)
inlinenoexcept

Member Data Documentation

◆ initialized

template<typename _value_t>
bool dx::promoted< _value_t >::initialized {}

◆ listen

template<typename _value_t>
listen<std::function<void(const value_t&)> > dx::promoted< _value_t >::listen

◆ server

template<typename _value_t>
std::function<void(lock_t&&, const value_t&, const value_t&)> dx::promoted< _value_t >::server {}

\ indicate the value is in transition - does not have the new value yet

server: handle synchronous and asynchronous value updates and initialization lock: lock promoted value from access during update value: new value (if in transition) current: current value to allow discarding update and reverting to current value if update is not permitted

it needs to handle these case: not initialized and not in transition: initialze and commit the value not initialized and in transition: if dependent on external settings initialize a temporary and compare it with the new value and update the external setting if required make sure to commit the new value so listeners get notified either synchronously or asynchronously by external notification initialized and in transition: update external settings if any and make sure to commit the new value so listeners get notified either synchronously or asynchronousl by external notification

server will not be called with this state: initialized and not in transation

for synchronous operation: move lock to commit for asynchronous operation: store lock and at asynchronous response restore and move lock to commit

◆ transient

template<typename _value_t>
bool dx::promoted< _value_t >::transient {}

\ indicate the value has been initialized

◆ value

template<typename _value_t>
value_t dx::promoted< _value_t >::value {}
protected

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

(c) copyright 2009 dynamic acoustics e.U. generated on

a closed source license may be obtained by requesting a written permission from dynamic acoustics e.U.
however - governmental use generally and military use especially is strictly prohibited though.