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

Query modifier which simply inverts the bits. More...

#include <Not.hpp>

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

Public Types

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

Public Member Functions

 Not (Q &internal)
 Construct a new Not Queryable modifier.
 
constexpr const util::BitSetgetMask () const noexcept
 Get the flipped mask of the internal queryable.
 
QueryData getQueryData (size_t index)
 Get the internal query data at the given index.
 
void reloadMask ()
 Update the mask to be up to date with the internal bitmask.
 
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::Not< Q, AutoLock >

Query modifier which simply inverts the bits.

Warning
Since it returns all entities that haven't the requested data, a call to getQueryData() is undefined behavior and will cause errors or exceptions depending on the Queryable implementation. Therefore you should never select this queryable.
Template Parameters
QType 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 35 of file Not.hpp.

Member Typedef Documentation

◆ Internal

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

Wrapped queryable.

Definition at line 38 of file Not.hpp.

◆ Operands

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

Modifier constraint.

Definition at line 41 of file Not.hpp.

◆ QueryData

template<Queryable Q, bool AutoLock = false>
using ecstasy::query::modifier::Not< Q, AutoLock >::QueryData = queryable_data_t<Q>

Queryable constaint.

Definition at line 44 of file Not.hpp.

Constructor & Destructor Documentation

◆ Not()

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

Construct a new Not 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 54 of file Not.hpp.

54 : _internal(internal), _mask(getQueryableMask(internal))
55 {
56 _mask.flip();
57 }
util::BitSet _mask
Mask of the internal queryable.
Definition Not.hpp:128
Internal _internal
Wrapped queryable.
Definition Not.hpp:126
BitSet & flip() noexcept
Flips all the bits in the set.
Definition BitSet.cpp:52
constexpr const util::BitSet & getQueryableMask(const Q &queryable)
Get the mask of the queryable object.

Member Function Documentation

◆ adjustMask()

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

Adjust the mask to be at least the maxSize.

Note
All bits exceeding the internal queryable mask size are set to 1.
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 115 of file Not.hpp.

116 {
117 if (maxSize > _mask.size()) {
118 _mask.resize(maxSize);
119 _mask.setAll();
121 }
122 }
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
BitSet & inplaceXor(BitSet const &other) noexcept
Performs a bitwise XOR with this set and other in place without resizing this.
Definition BitSet.cpp:144

◆ getMask()

template<Queryable Q, bool AutoLock = false>
constexpr const util::BitSet & ecstasy::query::modifier::Not< 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 69 of file Not.hpp.

70 {
71 return _mask;
72 }

◆ getQueryData()

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

Get the internal query data at the given index.

Note
Queryable constraint.
Warning
May throw exceptions, look at the Internal type equivalent method documentation.
Since this is a not modifier, all bit set to true in the masks means there isn't data at the associated index. Therefore you must not call this method for bits set to true in the mask.
Parameters
[in]indexIndex of the entity.
Returns
QueryData internal queryable data.
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 89 of file Not.hpp.

90 {
91 return getQueryableData(_internal, index);
92 }
constexpr queryable_data_t< Q > getQueryableData(Q &queryable, size_t index)
Get the query data at the given index.

◆ reloadMask()

template<Queryable Q, bool AutoLock = false>
void ecstasy::query::modifier::Not< Q, AutoLock >::reloadMask ( )
inline

Update the mask to be up to date with the internal bitmask.

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 100 of file Not.hpp.

101 {
102 _mask = ~getQueryableMask(_internal);
103 }

Member Data Documentation

◆ _internal

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

Wrapped queryable.

Definition at line 126 of file Not.hpp.

◆ _mask

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

Mask of the internal queryable.

Definition at line 128 of file Not.hpp.


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