CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam > Class Template Reference

A proxy for this Field within the Bitpack's Storage. More...

#include <bitpack.hh>

Public Types

using Field = Field
 Name the Field of which we are a proxy.
using RefType = RefTypeParam
 Expose the qualified reference type we hold to the Storage.

Public Member Functions

template<typename R>
constexpr Proxy (R &r)
 Construct a proxy given a reference to the storage word.
template<typename Self>
requires ( !std::is_const_v<std::remove_reference_t<RefTypeParam>>)
constexpr Self && operator= (this Self &&self, Field::Type rhs)
 Compute and store an updated Bitpack value with a new value for this field (of the field type itself).
template<typename Self, typename RHS>
requires ( !std::is_const_v<std::remove_reference_t<RefTypeParam>> && std::is_same_v<Field::Type, Numeric<RHS>>)
constexpr Self && operator= (this Self &&self, RHS rhs)
 Compute and store an updated Bitpack value with a new value for this field, when this field's type is a Numeric wrapper, and the RHS is the underlying type inside the Numeric wrapper.
template<typename Self, typename RHS>
requires ( !std::is_const_v<std::remove_reference_t<RefTypeParam>> && std::is_scoped_enum_v<Field::Type> && std::is_same_v
<std::underlying_type_t<Field::Type>, RHS>)
constexpr Self && operator= (this Self &&self, RHS rhs)
 Compute and store an updated Bitpack value with a new value for this field, when this field's type is an enum class and the RHS is the underlying type of that enum.
template<typename Self>
requires ( !std::is_volatile_v<std::remove_reference_t<RefTypeParam>>)
constexpr operator Field::Type (this Self &&self)
 Explicit conversion of a Field::Proxy to the field value.
constexpr Field::Type raw () const
 A shorter way of spelling static_cast<Field::Type>()...
constexpr auto rawer () const
 Get the value of this enum-typed field as its underlying type.
constexpr auto rawer () const
 Get the value of this Numeric-typed field as its underlying type.
constexpr DerivedBitpack with (Field::Type rhs) const
 Construct a new Bitpack value with an updated value of this field.
constexpr DerivedBitpack with (auto &&f) const
 Construct a new Bitpack value with an updated value of this field as a function of its current value.
template<typename Self>
requires ( std:: is_invocable_r_v<Field::Type, decltype(f), Field::Type> && !std::is_const_v<std::remove_reference_t<RefTypeParam>>)
constexpr void alter (this Self &&self, auto &&f)
 Compute and store an updated Bitpack value with a new value for this field as a function of its current value.
constexpr void assign_from (auto &&f)
 Convenience function for unconditionally assigning a field when it helps to have a zero value of that field's type.
constexpr auto operator<=> (Proxy rhs) const
constexpr auto operator<=> (Field::Type rhs) const
constexpr bool operator== (Proxy rhs) const
constexpr bool operator== (Field::Type rhs) const

Detailed Description

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
requires std::is_base_of_v<Bitpack, DerivedBitpack> && std::is_lvalue_reference_v<RefTypeParam> && std::is_same_v<Storage, std::remove_cvref_t<RefTypeParam>>
class Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >

A proxy for this Field within the Bitpack's Storage.

This provides getters, setters, and mutators phrased in terms of the Field's exposed Type rather than the raw bits within the Bitpack's underlying Storage word.

Proxies are templated on their containing derived type (so that they can act "in situ" in the class hierarchy, consuming and returning the same type, which must have Bitpack as its base type) and the type of the reference they hold to their containing Bitpack's underlying Storage word (so that they can properly propagate volatile and const qualifications from the Bitpack value and the Field's properties to perceived type).

Definition at line 568 of file bitpack.hh.

Member Typedef Documentation

◆ Field

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
using Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::Field = Field

Name the Field of which we are a proxy.

Definition at line 575 of file bitpack.hh.

◆ RefType

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
using Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::RefType = RefTypeParam

Expose the qualified reference type we hold to the Storage.

Definition at line 578 of file bitpack.hh.

Constructor & Destructor Documentation

◆ Proxy()

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
template<typename R>
Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::Proxy ( R & r)
inlineconstexpr

Construct a proxy given a reference to the storage word.

May take any reference type implicitly convertible to RefType, not just RefType itself.

Definition at line 587 of file bitpack.hh.

Member Function Documentation

◆ alter()

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
template<typename Self>
requires ( std:: is_invocable_r_v<Field::Type, decltype(f), Field::Type> && !std::is_const_v<std::remove_reference_t<RefTypeParam>>)
void Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::alter ( this Self && self,
auto && f )
inlineconstexpr

Compute and store an updated Bitpack value with a new value for this field as a function of its current value.

For volatile Bitpacks, this will perform a load and store.

Definition at line 723 of file bitpack.hh.

References Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_view(), and Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_with().

◆ assign_from()

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
void Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::assign_from ( auto && f)
inlineconstexpr

Convenience function for unconditionally assigning a field when it helps to have a zero value of that field's type.

Use .alter() if the current value of the field is required.

Because this requires a read of the whole Bitpack to update, we refuse to operate on volatile values, and because it's an assignment, we don't operate on const values either.

Definition at line 743 of file bitpack.hh.

References Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_view(), and Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_with().

◆ operator Field::Type()

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
template<typename Self>
requires ( !std::is_volatile_v<std::remove_reference_t<RefTypeParam>>)
Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::operator Field::Type ( this Self && self)
inlineconstexpr

Explicit conversion of a Field::Proxy to the field value.

The Proxy must not have a volatile reference to Storage. Use .read() on the containing Bitpack, first.

Definition at line 653 of file bitpack.hh.

References Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_view().

Referenced by rawer().

◆ operator<=>() [1/2]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
auto Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::operator<=> ( Field::Type rhs) const
inlineconstexpr

Definition at line 758 of file bitpack.hh.

◆ operator<=>() [2/2]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
auto Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::operator<=> ( Proxy< DerivedBitpack, RefTypeParam > rhs) const
inlineconstexpr

Definition at line 750 of file bitpack.hh.

◆ operator=() [1/3]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
template<typename Self>
requires ( !std::is_const_v<std::remove_reference_t<RefTypeParam>>)
Self && Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::operator= ( this Self && self,
Field::Type rhs )
inlineconstexpr

Compute and store an updated Bitpack value with a new value for this field (of the field type itself).

For volatile Bitpacks, this will perform a load and store.

Definition at line 601 of file bitpack.hh.

References Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_with().

◆ operator=() [2/3]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
template<typename Self, typename RHS>
requires ( !std::is_const_v<std::remove_reference_t<RefTypeParam>> && std::is_scoped_enum_v<Field::Type> && std::is_same_v
<std::underlying_type_t<Field::Type>, RHS>)
Self && Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::operator= ( this Self && self,
RHS rhs )
inlineconstexpr

Compute and store an updated Bitpack value with a new value for this field, when this field's type is an enum class and the RHS is the underlying type of that enum.

For volatile Bitpacks, this will perform a load and store.

Definition at line 638 of file bitpack.hh.

References Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_with().

◆ operator=() [3/3]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
template<typename Self, typename RHS>
requires ( !std::is_const_v<std::remove_reference_t<RefTypeParam>> && std::is_same_v<Field::Type, Numeric<RHS>>)
Self && Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::operator= ( this Self && self,
RHS rhs )
inlineconstexpr

Compute and store an updated Bitpack value with a new value for this field, when this field's type is a Numeric wrapper, and the RHS is the underlying type inside the Numeric wrapper.

For volatile Bitpacks, this will perform a load and store.

Definition at line 619 of file bitpack.hh.

References Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_with().

◆ operator==() [1/2]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
bool Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::operator== ( Field::Type rhs) const
inlineconstexpr

Definition at line 774 of file bitpack.hh.

◆ operator==() [2/2]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
bool Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::operator== ( Proxy< DerivedBitpack, RefTypeParam > rhs) const
inlineconstexpr

Definition at line 766 of file bitpack.hh.

◆ raw()

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
Field::Type Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::raw ( ) const
inlinenodiscardconstexpr

A shorter way of spelling static_cast<Field::Type>()...

Definition at line 659 of file bitpack.hh.

Referenced by rawer().

◆ rawer() [1/2]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
auto Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::rawer ( ) const
inlinenodiscardconstexpr

Get the value of this Numeric-typed field as its underlying type.

Definition at line 674 of file bitpack.hh.

References operator Field::Type(), and raw().

◆ rawer() [2/2]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
auto Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::rawer ( ) const
inlinenodiscardconstexpr

Get the value of this enum-typed field as its underlying type.

Definition at line 665 of file bitpack.hh.

References operator Field::Type(), and raw().

◆ with() [1/2]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
DerivedBitpack Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::with ( auto && f) const
inlineconstexpr

Construct a new Bitpack value with an updated value of this field as a function of its current value.

This is emphatically not volatile-qualified, and has no volatile-qualified overload. .read() the containing Bitpack, first.

Definition at line 704 of file bitpack.hh.

References Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_view(), and Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_with().

◆ with() [2/2]

template<typename StorageParam>
template<typename TypeParam, FieldInfo InfoParam>
template<typename DerivedBitpack, typename RefTypeParam>
DerivedBitpack Bitpack< StorageParam >::Field< TypeParam, InfoParam >::Proxy< DerivedBitpack, RefTypeParam >::with ( Field::Type rhs) const
inlinenodiscardconstexpr

Construct a new Bitpack value with an updated value of this field.

This is emphatically not volatile-qualified, and has no volatile-qualified overload. .read() the containing Bitpack, first.

Definition at line 691 of file bitpack.hh.

References Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_with().


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