powerd++  0.4.4
Public Member Functions | Private Attributes | List of all members
sys::ctl::Sync< T, SysctlT > Class Template Reference

This is a wrapper around Sysctl that allows semantically transparent use of a sysctl. More...

#include <sysctl.hpp>

Public Member Functions

constexpr Sync ()
 The default constructor. More...
 
constexpr Sync (SysctlT const &sysctl) noexcept
 The constructor copies the given Sysctl instance. More...
 
Syncoperator= (T const &value)
 Transparently assiges values of type T to the represented Sysctl instance. More...
 
 operator T () const
 Implicitly cast to the represented type. More...
 

Private Attributes

SysctlT sysctl
 A sysctl to represent.
 

Detailed Description

template<typename T, class SysctlT>
class sys::ctl::Sync< T, SysctlT >

This is a wrapper around Sysctl that allows semantically transparent use of a sysctl.

Sync<int, Sysctl<0>> sndUnit{{"hw.snd.default_unit"}};
if (sndUnit != 3) { // read from sysctl
sndUnit = 3; // assign to sysctl
}

Note that both assignment and read access (implemented through type casting to T) may throw an exception.

Template Parameters
TThe type to represent the sysctl as
SysctlTThe Sysctl type

Constructor & Destructor Documentation

◆ Sync() [1/2]

template<typename T , class SysctlT >
constexpr sys::ctl::Sync< T, SysctlT >::Sync ( )
inlineconstexpr

The default constructor.

This is available to defer initialisation to a later moment. This might be useful when initialising global or static instances by a character string repesented name.

◆ Sync() [2/2]

template<typename T , class SysctlT >
constexpr sys::ctl::Sync< T, SysctlT >::Sync ( SysctlT const &  sysctl)
inlineconstexprnoexcept

The constructor copies the given Sysctl instance.

Parameters
sysctlThe Sysctl instance to represent

Member Function Documentation

◆ operator T()

template<typename T , class SysctlT >
sys::ctl::Sync< T, SysctlT >::operator T ( ) const
inline

Implicitly cast to the represented type.

Returns
Returns the value from the sysctl

◆ operator=()

template<typename T , class SysctlT >
Sync& sys::ctl::Sync< T, SysctlT >::operator= ( T const &  value)
inline

Transparently assiges values of type T to the represented Sysctl instance.

Parameters
valueThe value to assign
Returns
A self reference

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