ECSTASY
All in the name
Loading...
Searching...
No Matches
ecstasy::query::modifier::Maybe< Q, AutoLock > Class Template Reference

Query modifier which returns a std::optional filled when the data if existing. More...

#include <Maybe.hpp>

Inheritance diagram for ecstasy::query::modifier::Maybe< Q, AutoLock >:
Collaboration diagram for ecstasy::query::modifier::Maybe< Q, AutoLock >:

Public Types

using Internal = queryable_qualifiers_t< Q, AutoLock >
 Wrapped queryable.
 
using Operands = util::meta::Traits< Q >
 Modifier constraint.
 
using QueryData = util::meta::add_optional_t< queryable_data_t< Q > >
 Queryable constaint.
 

Public Member Functions

 Maybe (Q &internal)
 Construct a new Maybe Queryable modifier.
 
constexpr const util::BitSetgetMask () const noexcept
 Get the flipped mask of the internal queryable.
 
constexpr QueryData getQueryData (size_t index)
 Get a std::optional filled with the data at index index if existing.
 
constexpr void adjustMask (size_t maxSize)
 Adjust the mask to be at least the maxSize.
 
- Public Member Functions inherited from ecstasy::query::modifier::Modifier< AutoLock >
virtual ~Modifier ()=default
 Destroy the modifier base object.
 
- Public Member Functions inherited from ecstasy::query::modifier::ModifierBase
virtual ~ModifierBase ()=default
 Destroy the modifier base object.
 

Private Attributes

Internal _internal
 Wrapped queryable.
 
util::BitSet _mask
 Mask of the internal queryable.
 

Detailed Description

template<Queryable Q, bool AutoLock = false>
class ecstasy::query::modifier::Maybe< Q, AutoLock >

Query modifier which returns a std::optional filled when the data if existing.

Note
All bits are set to true.
Template Parameters
InternalType of the wrapped queryable.
AutoLockLock the Lockable queryables if true.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-24)

Definition at line 38 of file Maybe.hpp.

Member Typedef Documentation

◆ Internal

template<Queryable Q, bool AutoLock = false>
using ecstasy::query::modifier::Maybe< Q, AutoLock >::Internal = queryable_qualifiers_t<Q, AutoLock>

Wrapped queryable.

Definition at line 41 of file Maybe.hpp.

◆ Operands

template<Queryable Q, bool AutoLock = false>
using ecstasy::query::modifier::Maybe< Q, AutoLock >::Operands = util::meta::Traits<Q>

Modifier constraint.

Definition at line 44 of file Maybe.hpp.

◆ QueryData

template<Queryable Q, bool AutoLock = false>
using ecstasy::query::modifier::Maybe< Q, AutoLock >::QueryData = util::meta::add_optional_t<queryable_data_t<Q> >

Queryable constaint.

Definition at line 47 of file Maybe.hpp.

Constructor & Destructor Documentation

◆ Maybe()

template<Queryable Q, bool AutoLock = false>
ecstasy::query::modifier::Maybe< Q, AutoLock >::Maybe ( Q &  internal)
inline

Construct a new Maybe Queryable modifier.

Parameters
[in]internalwrapped queryable.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-24)

Definition at line 57 of file Maybe.hpp.

57 : _internal(internal)
58 {
59 adjustMask(getQueryableMask(internal).size());
60 }
constexpr void adjustMask(size_t maxSize)
Adjust the mask to be at least the maxSize.
Definition Maybe.hpp:105
Internal _internal
Wrapped queryable.
Definition Maybe.hpp:115
constexpr const util::BitSet & getQueryableMask(const Q &queryable)
Get the mask of the queryable object.
T size(T... args)

Member Function Documentation

◆ adjustMask()

template<Queryable Q, bool AutoLock = false>
constexpr void ecstasy::query::modifier::Maybe< Q, AutoLock >::adjustMask ( size_t  maxSize)
inlineconstexpr

Adjust the mask to be at least the maxSize.

Parameters
[in]maxSizemaximum size of the masks compared with it.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-25)

Definition at line 105 of file Maybe.hpp.

106 {
107 if (maxSize > _mask.size()) {
108 _mask.resize(maxSize);
109 _mask.setAll();
110 }
111 }
util::BitSet _mask
Mask of the internal queryable.
Definition Maybe.hpp:117
void resize(std::size_t size)
Changes the number of bits stored in this set.
Definition BitSet.hpp:199
constexpr std::size_t size() const noexcept
Definition BitSet.hpp:87
BitSet & setAll(bool value=true) noexcept
Sets all bits to the given value.
Definition BitSet.cpp:34

◆ getMask()

template<Queryable Q, bool AutoLock = false>
constexpr const util::BitSet & ecstasy::query::modifier::Maybe< Q, AutoLock >::getMask ( ) const
inlineconstexprnoexcept

Get the flipped mask of the internal queryable.

Note
Queryable constraint.
Returns
const util::BitSet& Flipped bitset.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-24)

Definition at line 72 of file Maybe.hpp.

73 {
74 return _mask;
75 }

◆ getQueryData()

template<Queryable Q, bool AutoLock = false>
constexpr QueryData ecstasy::query::modifier::Maybe< Q, AutoLock >::getQueryData ( size_t  index)
inlineconstexpr

Get a std::optional filled with the data at index index if existing.

Note
Queryable constraint.
Warning
May throw exceptions, look at the Internal type equivalent method documentation.
Parameters
[in]indexIndex of the entity.
Returns
QueryData A std::optional filled with the data at index index if existing.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-24)

Definition at line 90 of file Maybe.hpp.

91 {
93 return QueryData{getQueryableData(_internal, index)};
94 return std::nullopt;
95 }
util::meta::add_optional_t< queryable_data_t< Q > > QueryData
Queryable constaint.
Definition Maybe.hpp:47
constexpr queryable_data_t< Q > getQueryableData(Q &queryable, size_t index)
Get the query data at the given index.

Member Data Documentation

◆ _internal

template<Queryable Q, bool AutoLock = false>
Internal ecstasy::query::modifier::Maybe< Q, AutoLock >::_internal
private

Wrapped queryable.

Definition at line 115 of file Maybe.hpp.

◆ _mask

template<Queryable Q, bool AutoLock = false>
util::BitSet ecstasy::query::modifier::Maybe< Q, AutoLock >::_mask
private

Mask of the internal queryable.

Definition at line 117 of file Maybe.hpp.


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