MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
MTXbit< T, bits, toggled > Class Template Reference

#include <maiatypes.h>

Inheritance diagram for MTXbit< T, bits, toggled >:
[legend]

Public Types

using type = T
 

Public Member Functions

constexpr MTXbit (T val) noexcept
 
constexpr MTXbit ()=default
 
void set (const MInt index, const MUint value)
 
MInt get (const MInt index) const
 
MBool any () const
 
MBool all () const
 
MTXbitoperator&= (const MTXbit &rhs)
 
MTXbitoperator|= (const MTXbit &rhs)
 
data () const
 

Static Public Attributes

static constexpr const MInt MAX = (1 << bits) - 1
 

Private Attributes

storage = toggled ? (T)~0 : 0
 

Detailed Description

template<class T, MInt bits, MBool toggled = false>
class MTXbit< T, bits, toggled >

Definition at line 77 of file maiatypes.h.

Member Typedef Documentation

◆ type

template<class T , MInt bits, MBool toggled = false>
using MTXbit< T, bits, toggled >::type = T

Definition at line 82 of file maiatypes.h.

Constructor & Destructor Documentation

◆ MTXbit() [1/2]

template<class T , MInt bits, MBool toggled = false>
constexpr MTXbit< T, bits, toggled >::MTXbit ( val)
inlineconstexprnoexcept

Definition at line 84 of file maiatypes.h.

84: storage(val) {}
T storage
Definition: maiatypes.h:79

◆ MTXbit() [2/2]

template<class T , MInt bits, MBool toggled = false>
constexpr MTXbit< T, bits, toggled >::MTXbit ( )
constexprdefault

Member Function Documentation

◆ all()

template<class T , MInt bits, MBool toggled = false>
MBool MTXbit< T, bits, toggled >::all ( ) const
inline

Definition at line 96 of file maiatypes.h.

96{ return storage == static_cast<T>(~0); }

◆ any()

template<class T , MInt bits, MBool toggled = false>
MBool MTXbit< T, bits, toggled >::any ( ) const
inline

Definition at line 95 of file maiatypes.h.

95{ return storage != 0; }

◆ data()

template<class T , MInt bits, MBool toggled = false>
T MTXbit< T, bits, toggled >::data ( ) const
inline

Definition at line 105 of file maiatypes.h.

105{ return storage; }

◆ get()

template<class T , MInt bits, MBool toggled = false>
MInt MTXbit< T, bits, toggled >::get ( const MInt  index) const
inline

Definition at line 91 of file maiatypes.h.

91 {
92 assert((int)sizeof(T) * 8 / bits > index);
93 return (storage >> (bits * index)) & MAX;
94 }
static constexpr const MInt MAX
Definition: maiatypes.h:83

◆ operator&=()

template<class T , MInt bits, MBool toggled = false>
MTXbit & MTXbit< T, bits, toggled >::operator&= ( const MTXbit< T, bits, toggled > &  rhs)
inline

Definition at line 97 of file maiatypes.h.

97 {
98 this->storage &= rhs.storage;
99 return *this;
100 }

◆ operator|=()

template<class T , MInt bits, MBool toggled = false>
MTXbit & MTXbit< T, bits, toggled >::operator|= ( const MTXbit< T, bits, toggled > &  rhs)
inline

Definition at line 101 of file maiatypes.h.

101 {
102 this->storage |= rhs.storage;
103 return *this;
104 }

◆ set()

template<class T , MInt bits, MBool toggled = false>
void MTXbit< T, bits, toggled >::set ( const MInt  index,
const MUint  value 
)
inline

Definition at line 86 of file maiatypes.h.

86 {
87 assert((int)sizeof(T) * 8 / bits > index);
88 assert(value <= MAX);
89 storage = (storage & (T) ~(MAX << bits * index)) | (value << bits * index);
90 }

Member Data Documentation

◆ MAX

template<class T , MInt bits, MBool toggled = false>
constexpr const MInt MTXbit< T, bits, toggled >::MAX = (1 << bits) - 1
staticconstexpr

Definition at line 83 of file maiatypes.h.

◆ storage

template<class T , MInt bits, MBool toggled = false>
T MTXbit< T, bits, toggled >::storage = toggled ? (T)~0 : 0
private

Definition at line 79 of file maiatypes.h.


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